Add PHPStan with strict rules

This commit is contained in:
Sebastian Meyer 2023-11-19 16:01:58 +01:00
parent 6730748032
commit a53e3303a0
10 changed files with 17 additions and 24 deletions

View File

@ -35,6 +35,8 @@
"php": "^8.0" "php": "^8.0"
}, },
"require-dev": { "require-dev": {
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-strict-rules": "^1.5",
"friendsofphp/php-cs-fixer": "^3.0" "friendsofphp/php-cs-fixer": "^3.0"
}, },
"autoload": { "autoload": {

14
phpstan.dist.neon Normal file
View File

@ -0,0 +1,14 @@
#
# Configuration for PHPStan.
# @see https://phpstan.org/config-reference
#
includes:
- vendor/phpstan/phpstan-strict-rules/rules.neon
parameters:
level: 2
strictRules:
noVariableVariables: false
paths:
- src

View File

@ -31,11 +31,6 @@ use OCC\Basics\Traits\Getter;
* *
* @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com> * @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
* @package opencultureconsulting/basics * @package opencultureconsulting/basics
*
* @implements \ArrayAccess
* @implements \Countable
* @implements \Iterator
* @implements \Serializable
*/ */
class StrictList extends SplDoublyLinkedList class StrictList extends SplDoublyLinkedList
{ {

View File

@ -29,11 +29,6 @@ use RuntimeException;
* *
* @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com> * @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
* @package opencultureconsulting/basics * @package opencultureconsulting/basics
*
* @implements \ArrayAccess
* @implements \Countable
* @implements \Iterator
* @implements \Serializable
*/ */
class StrictQueue extends StrictList class StrictQueue extends StrictList
{ {

View File

@ -29,11 +29,6 @@ use RuntimeException;
* *
* @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com> * @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
* @package opencultureconsulting/basics * @package opencultureconsulting/basics
*
* @implements \ArrayAccess
* @implements \Countable
* @implements \Iterator
* @implements \Serializable
*/ */
class StrictStack extends StrictList class StrictStack extends StrictList
{ {

View File

@ -43,7 +43,7 @@ use ErrorException;
*/ */
function throwErrorException(int $severity = E_USER_ERROR, string $message = '', ?string $file = null, ?int $line = null): bool function throwErrorException(int $severity = E_USER_ERROR, string $message = '', ?string $file = null, ?int $line = null): bool
{ {
if (error_reporting() & $severity) { if ((error_reporting() & $severity) > 0) {
throw new ErrorException($message, 0, $severity, $file, $line); throw new ErrorException($message, 0, $severity, $file, $line);
} }
return false; return false;

View File

@ -27,8 +27,6 @@ namespace OCC\Basics\InterfaceTraits;
* *
* @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com> * @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
* @package opencultureconsulting/basics * @package opencultureconsulting/basics
*
* @implements \ArrayAccess
*/ */
trait ArrayAccess /* implements \ArrayAccess */ trait ArrayAccess /* implements \ArrayAccess */
{ {

View File

@ -27,8 +27,6 @@ namespace OCC\Basics\InterfaceTraits;
* *
* @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com> * @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
* @package opencultureconsulting/basics * @package opencultureconsulting/basics
*
* @implements \Countable
*/ */
trait Countable /* implements \Countable */ trait Countable /* implements \Countable */
{ {

View File

@ -27,8 +27,6 @@ namespace OCC\Basics\InterfaceTraits;
* *
* @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com> * @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
* @package opencultureconsulting/basics * @package opencultureconsulting/basics
*
* @implements \Iterator
*/ */
trait Iterator /* implements \Iterator */ trait Iterator /* implements \Iterator */
{ {

View File

@ -29,8 +29,6 @@ use ArrayIterator;
* *
* @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com> * @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
* @package opencultureconsulting/basics * @package opencultureconsulting/basics
*
* @implements \IteratorAggregate
*/ */
trait IteratorAggregate /* implements \IteratorAggregate */ trait IteratorAggregate /* implements \IteratorAggregate */
{ {