diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bab4133cff..9e1062a125 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,9 +5,9 @@ on: pull_request: jobs: - tests_70: + tests_71: runs-on: "ubuntu-latest" - name: "PHP 7.0 Unit Tests" + name: "PHP 7.1 Unit Tests" steps: - name: "Checkout" uses: "actions/checkout@v3" @@ -15,7 +15,7 @@ jobs: uses: "shivammathur/setup-php@v2" with: coverage: "xdebug" - php-version: "7.0" + php-version: "7.1" tools: composer:v2 - name: "Install dependencies" run: | @@ -34,7 +34,6 @@ jobs: strategy: matrix: php-version: - - "7.1" - "7.2" - "7.3" - "7.4" @@ -71,9 +70,9 @@ jobs: run: "composer update --no-progress --prefer-dist" - name: "Tests" run: "test_old/run-php-src.sh 7.3.21" - test_old_80_70: + test_old_80_71: runs-on: "ubuntu-latest" - name: "PHP 8.1 Code on PHP 7.0 Integration Tests" + name: "PHP 8.1 Code on PHP 7.1 Integration Tests" steps: - name: "Checkout" uses: "actions/checkout@v3" @@ -81,7 +80,7 @@ jobs: uses: "shivammathur/setup-php@v2" with: coverage: "none" - php-version: "7.0" + php-version: "7.1" tools: composer:v2 - name: "Install PHP 8 dependencies" run: "composer update --no-progress --prefer-dist" diff --git a/CHANGELOG.md b/CHANGELOG.md index 5aa1986696..b0e2bd3fee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +Version 4.19.0 (2024-MM-DD) +--------------------------- + +### Changed + +* Do not use implicitly nullable parameters +* PHP 7.0 is no longer supported + Version 4.18.0 (2023-12-10) --------------------------- diff --git a/composer.json b/composer.json index 2fd064a212..9a3e1a9761 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ } ], "require": { - "php": ">=7.0", + "php": ">=7.1", "ext-tokenizer": "*" }, "require-dev": { diff --git a/lib/PhpParser/ConstExprEvaluator.php b/lib/PhpParser/ConstExprEvaluator.php index 7131c3d255..ceb3f11f3d 100644 --- a/lib/PhpParser/ConstExprEvaluator.php +++ b/lib/PhpParser/ConstExprEvaluator.php @@ -37,7 +37,7 @@ class ConstExprEvaluator * * @param callable|null $fallbackEvaluator To call if subexpression cannot be evaluated */ - public function __construct(callable $fallbackEvaluator = null) { + public function __construct(?callable $fallbackEvaluator = null) { $this->fallbackEvaluator = $fallbackEvaluator ?? function(Expr $expr) { throw new ConstExprEvaluationException( "Expression of type {$expr->getType()} cannot be evaluated" diff --git a/lib/PhpParser/Internal/PrintableNewAnonClassNode.php b/lib/PhpParser/Internal/PrintableNewAnonClassNode.php index 6763227014..917ed1e854 100644 --- a/lib/PhpParser/Internal/PrintableNewAnonClassNode.php +++ b/lib/PhpParser/Internal/PrintableNewAnonClassNode.php @@ -31,7 +31,7 @@ class PrintableNewAnonClassNode extends Expr public $stmts; public function __construct( - array $attrGroups, int $flags, array $args, Node\Name $extends = null, array $implements, + array $attrGroups, int $flags, array $args, ?Node\Name $extends = null, array $implements, array $stmts, array $attributes ) { parent::__construct($attributes); diff --git a/lib/PhpParser/Lexer.php b/lib/PhpParser/Lexer.php index e15dd0a5d2..60b809b8b1 100644 --- a/lib/PhpParser/Lexer.php +++ b/lib/PhpParser/Lexer.php @@ -69,7 +69,7 @@ public function __construct(array $options = []) { * @param ErrorHandler|null $errorHandler Error handler to use for lexing errors. Defaults to * ErrorHandler\Throwing */ - public function startLexing(string $code, ErrorHandler $errorHandler = null) { + public function startLexing(string $code, ?ErrorHandler $errorHandler = null) { if (null === $errorHandler) { $errorHandler = new ErrorHandler\Throwing(); } diff --git a/lib/PhpParser/Lexer/Emulative.php b/lib/PhpParser/Lexer/Emulative.php index b0929f3ccb..a0e781d04d 100644 --- a/lib/PhpParser/Lexer/Emulative.php +++ b/lib/PhpParser/Lexer/Emulative.php @@ -74,7 +74,7 @@ public function __construct(array $options = []) } } - public function startLexing(string $code, ErrorHandler $errorHandler = null) { + public function startLexing(string $code, ?ErrorHandler $errorHandler = null) { $emulators = array_filter($this->emulators, function($emulator) use($code) { return $emulator->isEmulationNeeded($code); }); diff --git a/lib/PhpParser/NameContext.php b/lib/PhpParser/NameContext.php index 777a4afdee..82c5acc2c7 100644 --- a/lib/PhpParser/NameContext.php +++ b/lib/PhpParser/NameContext.php @@ -36,7 +36,7 @@ public function __construct(ErrorHandler $errorHandler) { * * @param Name|null $namespace Null is the global namespace */ - public function startNamespace(Name $namespace = null) { + public function startNamespace(?Name $namespace = null) { $this->namespace = $namespace; $this->origAliases = $this->aliases = [ Stmt\Use_::TYPE_NORMAL => [], diff --git a/lib/PhpParser/Node/Arg.php b/lib/PhpParser/Node/Arg.php index bcf130e68c..17e6802607 100644 --- a/lib/PhpParser/Node/Arg.php +++ b/lib/PhpParser/Node/Arg.php @@ -27,7 +27,7 @@ class Arg extends NodeAbstract */ public function __construct( Expr $value, bool $byRef = false, bool $unpack = false, array $attributes = [], - Identifier $name = null + ?Identifier $name = null ) { $this->attributes = $attributes; $this->name = $name; diff --git a/lib/PhpParser/Node/Expr/ArrayDimFetch.php b/lib/PhpParser/Node/Expr/ArrayDimFetch.php index 71694478e9..46db975c4c 100644 --- a/lib/PhpParser/Node/Expr/ArrayDimFetch.php +++ b/lib/PhpParser/Node/Expr/ArrayDimFetch.php @@ -18,7 +18,7 @@ class ArrayDimFetch extends Expr * @param null|Expr $dim Array index / dim * @param array $attributes Additional attributes */ - public function __construct(Expr $var, Expr $dim = null, array $attributes = []) { + public function __construct(Expr $var, ?Expr $dim = null, array $attributes = []) { $this->attributes = $attributes; $this->var = $var; $this->dim = $dim; diff --git a/lib/PhpParser/Node/Expr/ArrayItem.php b/lib/PhpParser/Node/Expr/ArrayItem.php index 1b078f8218..5aaa9867ee 100644 --- a/lib/PhpParser/Node/Expr/ArrayItem.php +++ b/lib/PhpParser/Node/Expr/ArrayItem.php @@ -23,7 +23,7 @@ class ArrayItem extends Expr * @param bool $byRef Whether to assign by reference * @param array $attributes Additional attributes */ - public function __construct(Expr $value, Expr $key = null, bool $byRef = false, array $attributes = [], bool $unpack = false) { + public function __construct(Expr $value, ?Expr $key = null, bool $byRef = false, array $attributes = [], bool $unpack = false) { $this->attributes = $attributes; $this->key = $key; $this->value = $value; diff --git a/lib/PhpParser/Node/Expr/Exit_.php b/lib/PhpParser/Node/Expr/Exit_.php index b88a8f7e6f..5469b8e4ca 100644 --- a/lib/PhpParser/Node/Expr/Exit_.php +++ b/lib/PhpParser/Node/Expr/Exit_.php @@ -19,7 +19,7 @@ class Exit_ extends Expr * @param null|Expr $expr Expression * @param array $attributes Additional attributes */ - public function __construct(Expr $expr = null, array $attributes = []) { + public function __construct(?Expr $expr = null, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; } diff --git a/lib/PhpParser/Node/Expr/Yield_.php b/lib/PhpParser/Node/Expr/Yield_.php index aef8fc333d..f15336edeb 100644 --- a/lib/PhpParser/Node/Expr/Yield_.php +++ b/lib/PhpParser/Node/Expr/Yield_.php @@ -18,7 +18,7 @@ class Yield_ extends Expr * @param null|Expr $key Key expression * @param array $attributes Additional attributes */ - public function __construct(Expr $value = null, Expr $key = null, array $attributes = []) { + public function __construct(?Expr $value = null, ?Expr $key = null, array $attributes = []) { $this->attributes = $attributes; $this->key = $key; $this->value = $value; diff --git a/lib/PhpParser/Node/Name.php b/lib/PhpParser/Node/Name.php index f0a564ff0b..0d6e4b1ff5 100644 --- a/lib/PhpParser/Node/Name.php +++ b/lib/PhpParser/Node/Name.php @@ -162,7 +162,7 @@ public function __toString() : string { * * @return static|null Sliced name */ - public function slice(int $offset, int $length = null) { + public function slice(int $offset, ?int $length = null) { $numParts = count($this->parts); $realOffset = $offset < 0 ? $offset + $numParts : $offset; diff --git a/lib/PhpParser/Node/Param.php b/lib/PhpParser/Node/Param.php index 1e90b79441..dfb77f6290 100644 --- a/lib/PhpParser/Node/Param.php +++ b/lib/PhpParser/Node/Param.php @@ -34,7 +34,7 @@ class Param extends NodeAbstract * @param AttributeGroup[] $attrGroups PHP attribute groups */ public function __construct( - $var, Expr $default = null, $type = null, + $var, ?Expr $default = null, $type = null, bool $byRef = false, bool $variadic = false, array $attributes = [], int $flags = 0, diff --git a/lib/PhpParser/Node/Stmt/Break_.php b/lib/PhpParser/Node/Stmt/Break_.php index 6adc5a6c6f..d9464a1ae8 100644 --- a/lib/PhpParser/Node/Stmt/Break_.php +++ b/lib/PhpParser/Node/Stmt/Break_.php @@ -15,7 +15,7 @@ class Break_ extends Node\Stmt * @param null|Node\Expr $num Number of loops to break * @param array $attributes Additional attributes */ - public function __construct(Node\Expr $num = null, array $attributes = []) { + public function __construct(?Node\Expr $num = null, array $attributes = []) { $this->attributes = $attributes; $this->num = $num; } diff --git a/lib/PhpParser/Node/Stmt/Catch_.php b/lib/PhpParser/Node/Stmt/Catch_.php index 9b9c094782..5d7b5c0168 100644 --- a/lib/PhpParser/Node/Stmt/Catch_.php +++ b/lib/PhpParser/Node/Stmt/Catch_.php @@ -23,7 +23,7 @@ class Catch_ extends Node\Stmt * @param array $attributes Additional attributes */ public function __construct( - array $types, Expr\Variable $var = null, array $stmts = [], array $attributes = [] + array $types, ?Expr\Variable $var = null, array $stmts = [], array $attributes = [] ) { $this->attributes = $attributes; $this->types = $types; diff --git a/lib/PhpParser/Node/Stmt/Continue_.php b/lib/PhpParser/Node/Stmt/Continue_.php index 24882683b3..f2b30d79f5 100644 --- a/lib/PhpParser/Node/Stmt/Continue_.php +++ b/lib/PhpParser/Node/Stmt/Continue_.php @@ -15,7 +15,7 @@ class Continue_ extends Node\Stmt * @param null|Node\Expr $num Number of loops to continue * @param array $attributes Additional attributes */ - public function __construct(Node\Expr $num = null, array $attributes = []) { + public function __construct(?Node\Expr $num = null, array $attributes = []) { $this->attributes = $attributes; $this->num = $num; } diff --git a/lib/PhpParser/Node/Stmt/Declare_.php b/lib/PhpParser/Node/Stmt/Declare_.php index f46ff0bafd..a3a5bfaa59 100644 --- a/lib/PhpParser/Node/Stmt/Declare_.php +++ b/lib/PhpParser/Node/Stmt/Declare_.php @@ -18,7 +18,7 @@ class Declare_ extends Node\Stmt * @param Node\Stmt[]|null $stmts Statements * @param array $attributes Additional attributes */ - public function __construct(array $declares, array $stmts = null, array $attributes = []) { + public function __construct(array $declares, ?array $stmts = null, array $attributes = []) { $this->attributes = $attributes; $this->declares = $declares; $this->stmts = $stmts; diff --git a/lib/PhpParser/Node/Stmt/EnumCase.php b/lib/PhpParser/Node/Stmt/EnumCase.php index 5beff8b39f..4b1079bcd7 100644 --- a/lib/PhpParser/Node/Stmt/EnumCase.php +++ b/lib/PhpParser/Node/Stmt/EnumCase.php @@ -20,7 +20,7 @@ class EnumCase extends Node\Stmt * @param AttributeGroup[] $attrGroups PHP attribute groups * @param array $attributes Additional attributes */ - public function __construct($name, Node\Expr $expr = null, array $attrGroups = [], array $attributes = []) { + public function __construct($name, ?Node\Expr $expr = null, array $attrGroups = [], array $attributes = []) { parent::__construct($attributes); $this->name = \is_string($name) ? new Node\Identifier($name) : $name; $this->expr = $expr; diff --git a/lib/PhpParser/Node/Stmt/Namespace_.php b/lib/PhpParser/Node/Stmt/Namespace_.php index c63204577c..fc249161a9 100644 --- a/lib/PhpParser/Node/Stmt/Namespace_.php +++ b/lib/PhpParser/Node/Stmt/Namespace_.php @@ -22,7 +22,7 @@ class Namespace_ extends Node\Stmt * @param null|Node\Stmt[] $stmts Statements * @param array $attributes Additional attributes */ - public function __construct(Node\Name $name = null, $stmts = [], array $attributes = []) { + public function __construct(?Node\Name $name = null, $stmts = [], array $attributes = []) { $this->attributes = $attributes; $this->name = $name; $this->stmts = $stmts; diff --git a/lib/PhpParser/Node/Stmt/PropertyProperty.php b/lib/PhpParser/Node/Stmt/PropertyProperty.php index 205731e20e..286b42961c 100644 --- a/lib/PhpParser/Node/Stmt/PropertyProperty.php +++ b/lib/PhpParser/Node/Stmt/PropertyProperty.php @@ -18,7 +18,7 @@ class PropertyProperty extends Node\Stmt * @param null|Node\Expr $default Default value * @param array $attributes Additional attributes */ - public function __construct($name, Node\Expr $default = null, array $attributes = []) { + public function __construct($name, ?Node\Expr $default = null, array $attributes = []) { $this->attributes = $attributes; $this->name = \is_string($name) ? new Node\VarLikeIdentifier($name) : $name; $this->default = $default; diff --git a/lib/PhpParser/Node/Stmt/Return_.php b/lib/PhpParser/Node/Stmt/Return_.php index efc578c58f..53731254c0 100644 --- a/lib/PhpParser/Node/Stmt/Return_.php +++ b/lib/PhpParser/Node/Stmt/Return_.php @@ -15,7 +15,7 @@ class Return_ extends Node\Stmt * @param null|Node\Expr $expr Expression * @param array $attributes Additional attributes */ - public function __construct(Node\Expr $expr = null, array $attributes = []) { + public function __construct(?Node\Expr $expr = null, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; } diff --git a/lib/PhpParser/Node/Stmt/StaticVar.php b/lib/PhpParser/Node/Stmt/StaticVar.php index 29584560d3..0cc47b4122 100644 --- a/lib/PhpParser/Node/Stmt/StaticVar.php +++ b/lib/PhpParser/Node/Stmt/StaticVar.php @@ -20,7 +20,7 @@ class StaticVar extends Node\Stmt * @param array $attributes Additional attributes */ public function __construct( - Expr\Variable $var, Node\Expr $default = null, array $attributes = [] + Expr\Variable $var, ?Node\Expr $default = null, array $attributes = [] ) { $this->attributes = $attributes; $this->var = $var; diff --git a/lib/PhpParser/Node/Stmt/TryCatch.php b/lib/PhpParser/Node/Stmt/TryCatch.php index 7fc158c570..74e004380b 100644 --- a/lib/PhpParser/Node/Stmt/TryCatch.php +++ b/lib/PhpParser/Node/Stmt/TryCatch.php @@ -21,7 +21,7 @@ class TryCatch extends Node\Stmt * @param null|Finally_ $finally Optional finally node * @param array $attributes Additional attributes */ - public function __construct(array $stmts, array $catches, Finally_ $finally = null, array $attributes = []) { + public function __construct(array $stmts, array $catches, ?Finally_ $finally = null, array $attributes = []) { $this->attributes = $attributes; $this->stmts = $stmts; $this->catches = $catches; diff --git a/lib/PhpParser/NodeDumper.php b/lib/PhpParser/NodeDumper.php index ba622efd12..e0c7f783ad 100644 --- a/lib/PhpParser/NodeDumper.php +++ b/lib/PhpParser/NodeDumper.php @@ -39,7 +39,7 @@ public function __construct(array $options = []) { * * @return string Dumped value */ - public function dump($node, string $code = null) : string { + public function dump($node, ?string $code = null) : string { $this->code = $code; return $this->dumpRecursive($node); } diff --git a/lib/PhpParser/NodeVisitor/NameResolver.php b/lib/PhpParser/NodeVisitor/NameResolver.php index 83f3ea831c..dd2e9ca766 100644 --- a/lib/PhpParser/NodeVisitor/NameResolver.php +++ b/lib/PhpParser/NodeVisitor/NameResolver.php @@ -35,7 +35,7 @@ class NameResolver extends NodeVisitorAbstract * @param ErrorHandler|null $errorHandler Error handler * @param array $options Options */ - public function __construct(ErrorHandler $errorHandler = null, array $options = []) { + public function __construct(?ErrorHandler $errorHandler = null, array $options = []) { $this->nameContext = new NameContext($errorHandler ?? new ErrorHandler\Throwing); $this->preserveOriginalNames = $options['preserveOriginalNames'] ?? false; $this->replaceNodes = $options['replaceNodes'] ?? true; @@ -164,7 +164,7 @@ public function enterNode(Node $node) { return null; } - private function addAlias(Stmt\UseUse $use, int $type, Name $prefix = null) { + private function addAlias(Stmt\UseUse $use, int $type, ?Name $prefix = null) { // Add prefix for group uses $name = $prefix ? Name::concat($prefix, $use->name) : $use->name; // Type is determined either by individual element or whole use declaration diff --git a/lib/PhpParser/Parser.php b/lib/PhpParser/Parser.php index 8956c76718..7236c68e2a 100644 --- a/lib/PhpParser/Parser.php +++ b/lib/PhpParser/Parser.php @@ -14,5 +14,5 @@ interface Parser * @return Node\Stmt[]|null Array of statements (or null non-throwing error handler is used and * the parser was unable to recover from an error). */ - public function parse(string $code, ErrorHandler $errorHandler = null); + public function parse(string $code, ?ErrorHandler $errorHandler = null); } diff --git a/lib/PhpParser/Parser/Multiple.php b/lib/PhpParser/Parser/Multiple.php index 77fd1f3fbb..083ff465d3 100644 --- a/lib/PhpParser/Parser/Multiple.php +++ b/lib/PhpParser/Parser/Multiple.php @@ -24,7 +24,7 @@ public function __construct(array $parsers) { $this->parsers = $parsers; } - public function parse(string $code, ErrorHandler $errorHandler = null) { + public function parse(string $code, ?ErrorHandler $errorHandler = null) { if (null === $errorHandler) { $errorHandler = new ErrorHandler\Throwing; } diff --git a/lib/PhpParser/ParserAbstract.php b/lib/PhpParser/ParserAbstract.php index 9f9d00c763..567e09a975 100644 --- a/lib/PhpParser/ParserAbstract.php +++ b/lib/PhpParser/ParserAbstract.php @@ -155,7 +155,7 @@ public function __construct(Lexer $lexer, array $options = []) { * @return Node\Stmt[]|null Array of statements (or null non-throwing error handler is used and * the parser was unable to recover from an error). */ - public function parse(string $code, ErrorHandler $errorHandler = null) { + public function parse(string $code, ?ErrorHandler $errorHandler = null) { $this->errorHandler = $errorHandler ?: new ErrorHandler\Throwing; $this->lexer->startLexing($code, $this->errorHandler); diff --git a/lib/PhpParser/ParserFactory.php b/lib/PhpParser/ParserFactory.php index baba23bdb4..98b0aee343 100644 --- a/lib/PhpParser/ParserFactory.php +++ b/lib/PhpParser/ParserFactory.php @@ -21,7 +21,7 @@ class ParserFactory * * @return Parser The parser instance */ - public function create(int $kind, Lexer $lexer = null, array $parserOptions = []) : Parser { + public function create(int $kind, ?Lexer $lexer = null, array $parserOptions = []) : Parser { if (null === $lexer) { $lexer = new Lexer\Emulative(); }