Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support PHPStan 2.0 #267

Merged
merged 5 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ jobs:
strategy:
matrix:
php-version:
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"
Expand All @@ -27,10 +25,6 @@ jobs:
- composer phpcs
- composer phpstan
exclude:
- php-version: "7.2"
run: composer lint
- php-version: "7.3"
run: composer lint
- php-version: "7.4"
run: composer lint
- php-version: "8.0"
Expand All @@ -40,10 +34,6 @@ jobs:
- php-version: "8.2"
run: composer lint
include:
- php-version: "7.2"
run: composer lint-7.x
- php-version: "7.3"
run: composer lint-7.x
- php-version: "7.4"
run: composer lint-7.x
- php-version: "8.0"
Expand Down Expand Up @@ -115,8 +105,6 @@ jobs:
strategy:
matrix:
php-version:
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
}
},
"require": {
"php": "^7.2 || ^8.0",
"phpstan/phpstan": "^1.12.6"
"php": "^7.4 || ^8.0",
"phpstan/phpstan": "^2.0"
},
"require-dev": {
"nette/neon": "^3.2",
"nikic/php-parser": "^4.13 || ^5.0",
"phpunit/phpunit": "^8.5 || ^10.1 || ^11.0",
"php-parallel-lint/php-parallel-lint": "^1.2",
"php-parallel-lint/php-console-highlighter": "^1.0",
"phpstan/phpstan-deprecation-rules": "^1.2",
"phpstan/phpstan-deprecation-rules": "^2.0",
"spaze/coding-standard": "^1.7"
},
"autoload": {
Expand Down
20 changes: 8 additions & 12 deletions src/Allowed/Allowed.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,13 @@
class Allowed
{

/** @var Formatter */
private $formatter;
private Formatter $formatter;

/** @var Normalizer */
private $normalizer;
private Normalizer $normalizer;

/** @var AllowedPath */
private $allowedPath;
private AllowedPath $allowedPath;

/** @var TypeStringResolver */
private $typeStringResolver;
private TypeStringResolver $typeStringResolver;


public function __construct(
Expand All @@ -62,7 +58,7 @@ public function __construct(

/**
* @param Scope $scope
* @param array<int, Arg>|null $args
* @param array<Arg>|null $args
* @param DisallowedWithParams $disallowed
* @return bool
*/
Expand Down Expand Up @@ -116,7 +112,7 @@ private function callMatches(Scope $scope, string $call): bool

/**
* @param Scope $scope
* @param array<int, Arg>|null $args
* @param array<Arg>|null $args
* @param array<int|string, Param> $allowConfig
* @param bool $paramsRequired
* @return bool
Expand Down Expand Up @@ -152,7 +148,7 @@ private function hasAllowedParams(Scope $scope, ?array $args, array $allowConfig

/**
* @param Scope $scope
* @param array<int, Arg>|null $args
* @param array<Arg>|null $args
* @param DisallowedWithParams $disallowed
* @return bool
*/
Expand All @@ -169,7 +165,7 @@ private function hasAllowedParamsInAllowed(Scope $scope, ?array $args, Disallowe


/**
* @param array<int, Arg> $args
* @param array<Arg> $args
* @param Scope $scope
* @param Param $param
* @return Type|null
Expand Down
16 changes: 8 additions & 8 deletions src/Allowed/AllowedConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@ class AllowedConfig
{

/** @var list<string> */
private $allowIn;
private array $allowIn;

/** @var list<string> */
private $allowExceptIn;
private array $allowExceptIn;

/** @var list<string> */
private $allowInCalls;
private array $allowInCalls;

/** @var list<string> */
private $allowExceptInCalls;
private array $allowExceptInCalls;

/** @var array<int|string, Param> */
private $allowParamsInAllowed;
private array $allowParamsInAllowed;

/** @var array<int|string, Param> */
private $allowParamsAnywhere;
private array $allowParamsAnywhere;

/** @var array<int|string, Param> */
private $allowExceptParamsInAllowed;
private array $allowExceptParamsInAllowed;

/** @var array<int|string, Param> */
private $allowExceptParams;
private array $allowExceptParams;


/**
Expand Down
3 changes: 1 addition & 2 deletions src/Allowed/AllowedPath.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
class AllowedPath
{

/** @var FilePath */
private $filePath;
private FilePath $filePath;


public function __construct(FilePath $filePath)
Expand Down
5 changes: 2 additions & 3 deletions src/Calls/EchoCalls.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
class EchoCalls implements Rule
{

/** @var DisallowedCallsRuleErrors */
private $disallowedCallsRuleErrors;
private DisallowedCallsRuleErrors $disallowedCallsRuleErrors;

/** @var list<DisallowedCall> */
private $disallowedCalls;
private array $disallowedCalls;


/**
Expand Down
5 changes: 2 additions & 3 deletions src/Calls/EmptyCalls.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
class EmptyCalls implements Rule
{

/** @var DisallowedCallsRuleErrors */
private $disallowedCallsRuleErrors;
private DisallowedCallsRuleErrors $disallowedCallsRuleErrors;

/** @var list<DisallowedCall> */
private $disallowedCalls;
private array $disallowedCalls;


/**
Expand Down
5 changes: 2 additions & 3 deletions src/Calls/EvalCalls.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
class EvalCalls implements Rule
{

/** @var DisallowedCallsRuleErrors */
private $disallowedCallsRuleErrors;
private DisallowedCallsRuleErrors $disallowedCallsRuleErrors;

/** @var list<DisallowedCall> */
private $disallowedCalls;
private array $disallowedCalls;


/**
Expand Down
5 changes: 2 additions & 3 deletions src/Calls/ExitDieCalls.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
class ExitDieCalls implements Rule
{

/** @var DisallowedCallsRuleErrors */
private $disallowedCallsRuleErrors;
private DisallowedCallsRuleErrors $disallowedCallsRuleErrors;

/** @var list<DisallowedCall> */
private $disallowedCalls;
private array $disallowedCalls;


/**
Expand Down
8 changes: 3 additions & 5 deletions src/Calls/FunctionCalls.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@
class FunctionCalls implements Rule
{

/** @var DisallowedCallsRuleErrors */
private $disallowedCallsRuleErrors;
private DisallowedCallsRuleErrors $disallowedCallsRuleErrors;

/** @var list<DisallowedCall> */
private $disallowedCalls;
private array $disallowedCalls;

/** @var ReflectionProvider */
private $reflectionProvider;
private ReflectionProvider $reflectionProvider;


/**
Expand Down
5 changes: 2 additions & 3 deletions src/Calls/MethodCalls.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@
class MethodCalls implements Rule
{

/** @var DisallowedMethodRuleErrors */
private $disallowedMethodRuleErrors;
private DisallowedMethodRuleErrors $disallowedMethodRuleErrors;

/** @var list<DisallowedCall> */
private $disallowedCalls;
private array $disallowedCalls;


/**
Expand Down
5 changes: 2 additions & 3 deletions src/Calls/NewCalls.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ class NewCalls implements Rule
{
private const CONSTRUCT = '::__construct';

/** @var DisallowedCallsRuleErrors */
private $disallowedCallsRuleErrors;
private DisallowedCallsRuleErrors $disallowedCallsRuleErrors;

/** @var list<DisallowedCall> */
private $disallowedCalls;
private array $disallowedCalls;


/**
Expand Down
5 changes: 2 additions & 3 deletions src/Calls/PrintCalls.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
class PrintCalls implements Rule
{

/** @var DisallowedCallsRuleErrors */
private $disallowedCallsRuleErrors;
private DisallowedCallsRuleErrors $disallowedCallsRuleErrors;

/** @var list<DisallowedCall> */
private $disallowedCalls;
private array $disallowedCalls;


/**
Expand Down
5 changes: 2 additions & 3 deletions src/Calls/ShellExecCalls.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@
class ShellExecCalls implements Rule
{

/** @var DisallowedCallsRuleErrors */
private $disallowedCallsRuleErrors;
private DisallowedCallsRuleErrors $disallowedCallsRuleErrors;

/** @var list<DisallowedCall> */
private $disallowedCalls;
private array $disallowedCalls;


/**
Expand Down
5 changes: 2 additions & 3 deletions src/Calls/StaticCalls.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@
class StaticCalls implements Rule
{

/** @var DisallowedMethodRuleErrors */
private $disallowedMethodRuleErrors;
private DisallowedMethodRuleErrors $disallowedMethodRuleErrors;

/** @var list<DisallowedCall> */
private $disallowedCalls;
private array $disallowedCalls;


/**
Expand Down
5 changes: 2 additions & 3 deletions src/ControlStructures/BreakControlStructure.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
class BreakControlStructure implements Rule
{

/** @var DisallowedControlStructureRuleErrors */
private $disallowedControlStructureRuleErrors;
private DisallowedControlStructureRuleErrors $disallowedControlStructureRuleErrors;

/** @var list<DisallowedControlStructure> */
private $disallowedControlStructures;
private array $disallowedControlStructures;


/**
Expand Down
5 changes: 2 additions & 3 deletions src/ControlStructures/ContinueControlStructure.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
class ContinueControlStructure implements Rule
{

/** @var DisallowedControlStructureRuleErrors */
private $disallowedControlStructureRuleErrors;
private DisallowedControlStructureRuleErrors $disallowedControlStructureRuleErrors;

/** @var list<DisallowedControlStructure> */
private $disallowedControlStructures;
private array $disallowedControlStructures;


/**
Expand Down
5 changes: 2 additions & 3 deletions src/ControlStructures/DeclareControlStructure.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
class DeclareControlStructure implements Rule
{

/** @var DisallowedControlStructureRuleErrors */
private $disallowedControlStructureRuleErrors;
private DisallowedControlStructureRuleErrors $disallowedControlStructureRuleErrors;

/** @var list<DisallowedControlStructure> */
private $disallowedControlStructures;
private array $disallowedControlStructures;


/**
Expand Down
5 changes: 2 additions & 3 deletions src/ControlStructures/DoWhileControlStructure.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
class DoWhileControlStructure implements Rule
{

/** @var DisallowedControlStructureRuleErrors */
private $disallowedControlStructureRuleErrors;
private DisallowedControlStructureRuleErrors $disallowedControlStructureRuleErrors;

/** @var list<DisallowedControlStructure> */
private $disallowedControlStructures;
private array $disallowedControlStructures;


/**
Expand Down
5 changes: 2 additions & 3 deletions src/ControlStructures/ElseControlStructure.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
class ElseControlStructure implements Rule
{

/** @var DisallowedControlStructureRuleErrors */
private $disallowedControlStructureRuleErrors;
private DisallowedControlStructureRuleErrors $disallowedControlStructureRuleErrors;

/** @var list<DisallowedControlStructure> */
private $disallowedControlStructures;
private array $disallowedControlStructures;


/**
Expand Down
5 changes: 2 additions & 3 deletions src/ControlStructures/ElseIfControlStructure.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@
class ElseIfControlStructure implements Rule
{

/** @var DisallowedControlStructureRuleErrors */
private $disallowedControlStructureRuleErrors;
private DisallowedControlStructureRuleErrors $disallowedControlStructureRuleErrors;

/** @var list<DisallowedControlStructure> */
private $disallowedControlStructures;
private array $disallowedControlStructures;


/**
Expand Down
Loading