Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Upgrade Rector to v1 and try using DOWN_TO_PHP_74 again #2906

@leoloso

Description

@leoloso

In file src/Config/Rector/Downgrade/Configurators/AbstractDowngradeContainerConfigurationService.php it should use DOWN_TO_PHP_74 to downgrade to PHP 7.4,
but there's a bug in which this code:

\set_error_handler(static fn($type, $message, $file, $line) => throw new \ErrorException($message, 0, $type, $file, $line));

from file vendor/symfony/cache/Traits/FilesystemCommonTrait.php is not being downgraded, then the plugin explodes:

Error: There has been a critical error on this website.Learn more about troubleshooting WordPress. There has been a critical error on this website.
PHP Fatal error:  During class fetch: Uncaught ParseError: syntax error, unexpected 'throw' (T_THROW) in /app/wordpress/wp-content/plugins/gatographql/vendor/symfony/cache/Traits/FilesystemCommonTrait.php:78
Stack trace:
#0 phar:///usr/local/bin/wp/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile('/app/wordpress/...')
#1 [internal function]: Composer\Autoload\ClassLoader->loadClass('PrefixedByPoP\\S...')
#2 /app/wordpress/wp-content/plugins/gatographql/vendor/symfony/cache/Traits/FilesystemTrait.php(21): spl_autoload_call('PrefixedByPoP\\S...')
#3 phar:///usr/local/bin/wp/vendor/composer/ClassLoader.php(571): include('/app/wordpress/...')
#4 phar:///usr/local/bin/wp/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile('/app/wordpress/...')
#5 [internal function]: Composer\Autoload\ClassLoader->loadClass('PrefixedByPoP\\S...')
#6 /app/wordpress/wp-content/plugins/gatographql/vendor/symfony/cache/Adapter/FilesystemAdapter.php(18): spl_autoload_call('PrefixedByPoP\\S...')
#7 phar:///usr/local/bin in /app/wordpress/wp-content/plugins/gatographql/vendor/symfony/cache/Traits/FilesystemTrait.php on line 21

(The code should become:

\set_error_handler(static function ($type, $message, $file, $line) {
  throw new \ErrorException($message, 0, $type, $file, $line);
});

)

To avoid this problem, for the time being, the project is using set DOWN_TO_PHP_73!

Solution

There must be a bug in Rector v0.18 (the current version), in which the downgrade rules have been misplaced across sets.

Then, upgrade to the latest version of Rector, and try again.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions