Run PHP-CS-Fixer

This commit is contained in:
Sebastian Meyer 2023-11-19 15:56:42 +01:00
parent 044603465e
commit 6730748032
4 changed files with 42 additions and 6 deletions

38
.php-cs-fixer.dist.php Normal file
View File

@ -0,0 +1,38 @@
<?php
/**
* Useful PHP Basics
* Copyright (C) 2023 Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
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__)
);

View File

@ -108,7 +108,7 @@ class StrictList extends SplDoublyLinkedList
get_debug_type($item) get_debug_type($item)
) )
); );
} }
} }
foreach ($items as $item) { foreach ($items as $item) {
parent::push($item); parent::push($item);
@ -134,7 +134,7 @@ class StrictList extends SplDoublyLinkedList
*/ */
public function isAllowedType(mixed $item): bool public function isAllowedType(mixed $item): bool
{ {
if (empty($this->allowedTypes)) { if (count($this->allowedTypes) === 0) {
return true; return true;
} }
foreach ($this->allowedTypes as $type) { foreach ($this->allowedTypes as $type) {

View File

@ -74,7 +74,7 @@ trait Getter
} catch (InvalidArgumentException) { } catch (InvalidArgumentException) {
$value = null; $value = null;
} finally { } finally {
return !empty($value); return (bool) $value !== false;
} }
} }
} }

View File

@ -54,10 +54,8 @@ trait Singleton
* This is a singleton class, thus the constructor is private. * This is a singleton class, thus the constructor is private.
* *
* Usage: Get an instance of this class by calling self::getInstance() * 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. * This is a singleton class, thus cloning is prohibited.