diff --git a/docs/configuration.md b/docs/configuration.md index eb91f2d1..ffe3a191 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -60,11 +60,19 @@ then a random prefix will be automatically generated. ### PHP Version -The PHP version provided is used to configure the underlying [PHP-Parser] Parser and Printer. This will not affect -the PHP internal symbols used by PHP-Scoper but may affect what code can be parsed and how the code will be printed. +The PHP version provided is used to configure the underlying [PHP-Parser] Parser and Printer. -If `null` or `''` (empty string) is given, then the host version will be used, i.e. executing it with PHP 8.4 will -result in PHP 8.4 being used as the PHP version. +The version used by the Parser will affect what code it can understand, e.g. if it is configured in PHP 8.2 it will not +understand a PHP 8.3 construct (e.g. typed class constants). However, what symbols are interpreted as internal will +remain unchanged. The function `json_validate()` will be considered as internal even if the parser is configured with +PHP 8.2. + +The printer version affects the code style. For example nowdocs and heredocs will be indented if the printer's PHP +version is higher than 7.4 but will be formated without indent otherwise. + +If `null` or `''` (empty string) is given, then the host version will be used for the parser and 7.2 will be used for +the printer. This allows PHP-Scoper to a PHP 7.2 compatible codebase without breaking its compatibility although the +host version is a newer version. ### Output directory diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 7e50016c..a85a8720 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -61,5 +61,3 @@ parameters: # Fixed in https://github.com/nikic/PHP-Parser/pull/1003 - message: '#Standard constructor expects array#' path: 'src/Container.php' - - message: '#Standard constructor expects array#' - path: 'src/PhpParser/Printer/StandardPrinterFactory.php' diff --git a/src/PhpParser/Printer/StandardPrinterFactory.php b/src/PhpParser/Printer/StandardPrinterFactory.php index 78a612e1..5217b75c 100644 --- a/src/PhpParser/Printer/StandardPrinterFactory.php +++ b/src/PhpParser/Printer/StandardPrinterFactory.php @@ -23,7 +23,7 @@ public function createPrinter(?PhpVersion $phpVersion = null): Printer { return new StandardPrinter( new Standard([ - 'phpVersion' => $phpVersion, + 'phpVersion' => $phpVersion ?? PhpVersion::fromComponents(7, 2), ]), ); }