Skip to content

Commit 33f47e3

Browse files
committed
Upgrade Coding Standard
1 parent 820e7b0 commit 33f47e3

File tree

8 files changed

+29
-29
lines changed

8 files changed

+29
-29
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
},
6464
"require-dev": {
6565
"ext-xdebug": "*",
66-
"aplus/coding-standard": "^1.14",
66+
"aplus/coding-standard": "^2.0",
6767
"ergebnis/composer-normalize": "^2.28",
6868
"jetbrains/phpstorm-attributes": "^1.0",
6969
"phpmd/phpmd": "^2.13",

src/App.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function __construct(Config | array | string $config = null, bool $debug
117117
if (isset(static::$config)) {
118118
throw new LogicException('App already initialized');
119119
}
120-
if ( ! $config instanceof Config) {
120+
if (!$config instanceof Config) {
121121
$config = new Config($config);
122122
}
123123
static::$config = $config;
@@ -178,7 +178,7 @@ protected function loadExceptionHandler() : void
178178
if ($config->getDir() !== null) {
179179
$exceptionHandlerConfigs ??= $this->loadConfigs('exceptionHandler');
180180
}
181-
if ( ! isset($exceptionHandlerConfigs['default'])) {
181+
if (!isset($exceptionHandlerConfigs['default'])) {
182182
$environment = static::isDebugging()
183183
? ExceptionHandler::DEVELOPMENT
184184
: ExceptionHandler::PRODUCTION;
@@ -230,8 +230,8 @@ protected function debugEnd() : void
230230
{
231231
static::$debugCollector->setEndTime()->setEndMemory();
232232
$response = static::router()->getResponse();
233-
if ( ! $response->hasDownload()
234-
&& ! $response->getRequest()->isAjax()
233+
if (!$response->hasDownload()
234+
&& !$response->getRequest()->isAjax()
235235
&& \str_contains(
236236
(string) $response->getHeader('Content-Type'),
237237
'text/html'
@@ -492,7 +492,7 @@ protected static function addCommand(string $file, Console $console, Locator $lo
492492
if ($className === null) {
493493
return false;
494494
}
495-
if ( ! \class_exists($className)) {
495+
if (!\class_exists($className)) {
496496
Isolation::require($file);
497497
}
498498
$class = new ReflectionClass($className); // @phpstan-ignore-line
@@ -1033,7 +1033,7 @@ protected static function setRouter(string $instance, array $config = null) : Ro
10331033
if (isset($config['auto_methods']) && $config['auto_methods'] === true) {
10341034
$service->setAutoMethods();
10351035
}
1036-
if ( ! empty($config['placeholders'])) {
1036+
if (!empty($config['placeholders'])) {
10371037
$service->addPlaceholder($config['placeholders']);
10381038
}
10391039
if ($requireFiles && isset($config['files'])) {
@@ -1050,7 +1050,7 @@ protected static function setRouter(string $instance, array $config = null) : Ro
10501050
protected static function requireRouterFiles(array $files) : void
10511051
{
10521052
foreach ($files as $file) {
1053-
if ( ! \is_file($file)) {
1053+
if (!\is_file($file)) {
10541054
throw new LogicException('Invalid router file: ' . $file);
10551055
}
10561056
Isolation::require($file);
@@ -1158,10 +1158,10 @@ protected static function setResponse(string $instance) : Response
11581158
{
11591159
$config = static::config()->get('response', $instance);
11601160
$service = new Response(static::request($config['request_instance'] ?? 'default'));
1161-
if ( ! empty($config['headers'])) {
1161+
if (!empty($config['headers'])) {
11621162
$service->setHeaders($config['headers']);
11631163
}
1164-
if ( ! empty($config['auto_etag'])) {
1164+
if (!empty($config['auto_etag'])) {
11651165
$service->setAutoEtag(
11661166
$config['auto_etag']['active'] ?? true,
11671167
$config['auto_etag']['hash_algo'] ?? null

src/Debug/AppCollector.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ class AppCollector extends Collector
3131
public function setApp(App $app) : static
3232
{
3333
$this->app = $app;
34-
if ( ! isset($this->startTime)) {
34+
if (!isset($this->startTime)) {
3535
$this->setStartTime();
3636
}
37-
if ( ! isset($this->startMemory)) {
37+
if (!isset($this->startMemory)) {
3838
$this->setStartMemory();
3939
}
4040
return $this;
@@ -90,10 +90,10 @@ public function getActivities() : array
9090

9191
public function getContents() : string
9292
{
93-
if ( ! isset($this->endTime)) {
93+
if (!isset($this->endTime)) {
9494
$this->setEndTime(\microtime(true));
9595
}
96-
if ( ! isset($this->endMemory)) {
96+
if (!isset($this->endMemory)) {
9797
$this->setEndMemory(\memory_get_usage());
9898
}
9999
\ob_start(); ?>
@@ -161,7 +161,7 @@ protected function getServices() : array
161161
{
162162
$result = [];
163163
foreach ($this->getData() as $data) {
164-
if ( ! isset($result[$data['service']])) {
164+
if (!isset($result[$data['service']])) {
165165
$result[$data['service']] = [];
166166
}
167167
$result[$data['service']][] = [
@@ -180,7 +180,7 @@ protected function renderAvailableServices() : string
180180
$class = new ReflectionClass($this->app);
181181
$methods = $class->getMethods(ReflectionMethod::IS_STATIC);
182182
foreach ($methods as $method) {
183-
if ( ! $method->isPublic()) {
183+
if (!$method->isPublic()) {
184184
continue;
185185
}
186186
$name = $method->getName();
@@ -196,7 +196,7 @@ protected function renderAvailableServices() : string
196196
continue;
197197
}
198198
$param = $method->getParameters()[0] ?? null;
199-
if ( ! $param || $param->getName() !== 'instance') {
199+
if (!$param || $param->getName() !== 'instance') {
200200
continue;
201201
}
202202
if ($param->getType()?->getName() !== 'string') { // @phpstan-ignore-line

src/Debug/ViewCollector.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function getContents() : string
7373

7474
protected function renderRenderedViews() : string
7575
{
76-
if ( ! $this->hasData()) {
76+
if (!$this->hasData()) {
7777
return '<p>No view has been rendered.</p>';
7878
}
7979
$data = $this->getSortedData();

src/Entity.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ protected function populate(array $properties) : void
140140

141141
protected function setProperty(string $name, mixed $value) : void
142142
{
143-
if ( ! \property_exists($this, $name)) {
143+
if (!\property_exists($this, $name)) {
144144
throw $this->propertyNotDefined($name);
145145
}
146146
if ($value !== null) {
@@ -251,7 +251,7 @@ public function toModel() : array
251251

252252
public function jsonSerialize() : stdClass
253253
{
254-
if ( ! $this->getJsonVars()) {
254+
if (!$this->getJsonVars()) {
255255
return new stdClass();
256256
}
257257
$allowed = \array_flip($this->getJsonVars());
@@ -268,7 +268,7 @@ protected function getObjectVars() : array
268268
{
269269
$result = [];
270270
foreach (\get_object_vars($this) as $key => $value) {
271-
if ( ! \str_starts_with($key, '_')) {
271+
if (!\str_starts_with($key, '_')) {
272272
$result[$key] = $value;
273273
}
274274
}

src/Model.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ public function getValidationMessages() : array
825825
*/
826826
protected function getValidationRules() : array
827827
{
828-
if ( ! isset($this->validationRules)) {
828+
if (!isset($this->validationRules)) {
829829
throw new RuntimeException('Validation rules are not set');
830830
}
831831
return $this->validationRules;

src/Validator.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public static function notUnique(
3838
int | string $ignoreValue = '',
3939
string $connection = 'default'
4040
) : bool {
41-
return ! static::unique(
41+
return !static::unique(
4242
$field,
4343
$data,
4444
$tableColumn,
@@ -90,7 +90,7 @@ public static function unique(
9090
->expressions(['count' => static fn () => 'COUNT(*)'])
9191
->from($table)
9292
->whereEqual($column, $value);
93-
if ($ignoreColumn !== '' && ! \preg_match('#^{(\w+)}$#', $ignoreValue)) {
93+
if ($ignoreColumn !== '' && !\preg_match('#^{(\w+)}$#', $ignoreValue)) {
9494
$statement->whereNotEqual($ignoreColumn, $ignoreValue);
9595
}
9696
return $statement->limit(1)->run()->fetch()->count < 1; // @phpstan-ignore-line

src/View.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function __destruct()
6666
public function setBaseDir(string $baseDir) : static
6767
{
6868
$real = \realpath($baseDir);
69-
if ( ! $real || ! \is_dir($real)) {
69+
if (!$real || !\is_dir($real)) {
7070
throw new InvalidArgumentException("View base dir is not a valid directory: {$baseDir} ");
7171
}
7272
$this->baseDir = \rtrim($real, '\\/ ') . \DIRECTORY_SEPARATOR;
@@ -150,10 +150,10 @@ protected function getFilepath(string $view) : string
150150
}
151151
$view = $this->getBaseDir() . $view . $this->getExtension();
152152
$real = \realpath($view);
153-
if ( ! $real || ! \is_file($real)) {
153+
if (!$real || !\is_file($real)) {
154154
throw new InvalidArgumentException("View path does not match a file: {$view}");
155155
}
156-
if ($this->getBaseDir() && ! \str_starts_with($real, $this->getBaseDir())) {
156+
if ($this->getBaseDir() && !\str_starts_with($real, $this->getBaseDir())) {
157157
throw new InvalidArgumentException("View path out of base directory: {$real}");
158158
}
159159
return $real;
@@ -255,7 +255,7 @@ public function endBlock() : static
255255
echo \PHP_EOL . '<!-- Block end: ' . $block . ' -->' . \PHP_EOL;
256256
}
257257
$contents = \ob_get_clean();
258-
if ( ! isset($this->blocks[$name])) {
258+
if (!isset($this->blocks[$name])) {
259259
$this->blocks[$name] = $contents; // @phpstan-ignore-line
260260
}
261261
return $this;
@@ -367,7 +367,7 @@ protected function getContents(string $view, array $data) : string
367367
$data['view'] = $this;
368368
\ob_start();
369369
Isolation::require($this->getFilepath($view), $data);
370-
if (isset($this->openBlock) && ! $this->inInclude) {
370+
if (isset($this->openBlock) && !$this->inInclude) {
371371
$this->openBlock = null;
372372
$this->endBlock();
373373
}

0 commit comments

Comments
 (0)