From 6730748032c98060e18808b938315bd2bb97c87c Mon Sep 17 00:00:00 2001 From: Sebastian Meyer Date: Sun, 19 Nov 2023 15:56:42 +0100 Subject: [PATCH] Run PHP-CS-Fixer --- .php-cs-fixer.dist.php | 38 +++++++++++++++++++++++++++++++ src/DataStructures/StrictList.php | 4 ++-- src/Traits/Getter.php | 2 +- src/Traits/Singleton.php | 4 +--- 4 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 .php-cs-fixer.dist.php diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..8286899 --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,38 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +declare(strict_types=1); + +namespace PhpCsFixer; + +/** + * Configuration for PHP-CS-Fixer. + * @see https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/doc/config.rst + * + * @return ConfigInterface + */ +return (new Config()) + ->setRiskyAllowed(true) + ->setRules([ + '@PSR12' => true, + ]) + ->setFinder( + (new Finder())->in(__DIR__) + ); diff --git a/src/DataStructures/StrictList.php b/src/DataStructures/StrictList.php index 2c981a5..e1f1090 100644 --- a/src/DataStructures/StrictList.php +++ b/src/DataStructures/StrictList.php @@ -108,7 +108,7 @@ class StrictList extends SplDoublyLinkedList get_debug_type($item) ) ); - } + } } foreach ($items as $item) { parent::push($item); @@ -134,7 +134,7 @@ class StrictList extends SplDoublyLinkedList */ public function isAllowedType(mixed $item): bool { - if (empty($this->allowedTypes)) { + if (count($this->allowedTypes) === 0) { return true; } foreach ($this->allowedTypes as $type) { diff --git a/src/Traits/Getter.php b/src/Traits/Getter.php index b4adba5..e4df8a1 100644 --- a/src/Traits/Getter.php +++ b/src/Traits/Getter.php @@ -74,7 +74,7 @@ trait Getter } catch (InvalidArgumentException) { $value = null; } finally { - return !empty($value); + return (bool) $value !== false; } } } diff --git a/src/Traits/Singleton.php b/src/Traits/Singleton.php index e1cdbb6..c12ac03 100644 --- a/src/Traits/Singleton.php +++ b/src/Traits/Singleton.php @@ -54,10 +54,8 @@ trait Singleton * This is a singleton class, thus the constructor is private. * * Usage: Get an instance of this class by calling self::getInstance() - * - * @param mixed ...$args Constructor parameters */ - abstract private function __construct(mixed ...$args); + abstract private function __construct(); /** * This is a singleton class, thus cloning is prohibited.