Skip to content

Conversation

@paulbalandan
Copy link
Member

Description
php-cs-fixer recently adjusted the return types of its Preg methods. Yes, that class is internal but cs-config depended on that. With the return type change, it used the native preg_* functions instead. Since cs-config needs ^8.0.1 the fix won't work with 7.4.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@kenjis
Copy link
Member

kenjis commented Jul 18, 2023

What happened when we (or contributors) use PHP 7.4?

@paulbalandan
Copy link
Member Author

If you are using FixerGenerator to register custom fixers, it will always error that the vendor namespace is not valid.

@kenjis
Copy link
Member

kenjis commented Jul 18, 2023

Until we stop supporting PHP 7.4, I guess the only way is to fix the version of php-cs-fixer so that PHP 7.4 does not cause the error?

$ php -v
PHP 7.4.33 (cli) (built: Jun 17 2023 06:48:34) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Xdebug v3.1.5, Copyright (c) 2002-2022, by Derick Rethans
    with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies
$ composer cs-fix
> Composer\Config::disableProcessTimeout
> php-cs-fixer fix --ansi --verbose --diff --config=.php-cs-fixer.user-guide.php

In FixerGenerator.php line 55:
                                                         
  [RuntimeException]                                     
  Vendor namespace "Nexus\CsConfig\Fixer" is not valid.  
                                                         

Exception trace:
  at /Users/kenji/work/codeigniter/official/CodeIgniter4/vendor/nexusphp/cs-config/src/FixerGenerator.php:55
 Nexus\CsConfig\FixerGenerator::create() at /Users/kenji/work/codeigniter/official/CodeIgniter4/.php-cs-fixer.user-guide.php:41
 include() at /Users/kenji/work/codeigniter/official/CodeIgniter4/vendor/friendsofphp/php-cs-fixer/src/Console/ConfigurationResolver.php:954
 PhpCsFixer\Console\ConfigurationResolver::separatedContextLessInclude() at /Users/kenji/work/codeigniter/official/CodeIgniter4/vendor/friendsofphp/php-cs-fixer/src/Console/ConfigurationResolver.php:264
 PhpCsFixer\Console\ConfigurationResolver->getConfig() at /Users/kenji/work/codeigniter/official/CodeIgniter4/vendor/friendsofphp/php-cs-fixer/src/Console/ConfigurationResolver.php:602
 PhpCsFixer\Console\ConfigurationResolver->getFormat() at /Users/kenji/work/codeigniter/official/CodeIgniter4/vendor/friendsofphp/php-cs-fixer/src/Console/ConfigurationResolver.php:443
 PhpCsFixer\Console\ConfigurationResolver->getReporter() at /Users/kenji/work/codeigniter/official/CodeIgniter4/vendor/friendsofphp/php-cs-fixer/src/Console/Command/FixCommand.php:246
 PhpCsFixer\Console\Command\FixCommand->execute() at /Users/kenji/work/codeigniter/official/CodeIgniter4/vendor/symfony/console/Command/Command.php:298
 Symfony\Component\Console\Command\Command->run() at /Users/kenji/work/codeigniter/official/CodeIgniter4/vendor/symfony/console/Application.php:1040
 Symfony\Component\Console\Application->doRunCommand() at /Users/kenji/work/codeigniter/official/CodeIgniter4/vendor/symfony/console/Application.php:301
 Symfony\Component\Console\Application->doRun() at /Users/kenji/work/codeigniter/official/CodeIgniter4/vendor/friendsofphp/php-cs-fixer/src/Console/Application.php:90
 PhpCsFixer\Console\Application->doRun() at /Users/kenji/work/codeigniter/official/CodeIgniter4/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at /Users/kenji/work/codeigniter/official/CodeIgniter4/vendor/friendsofphp/php-cs-fixer/php-cs-fixer:101
 include() at /Users/kenji/work/codeigniter/official/CodeIgniter4/vendor/bin/php-cs-fixer:115

fix [--path-mode PATH-MODE] [--allow-risky ALLOW-RISKY] [--config CONFIG] [--dry-run] [--rules RULES] [--using-cache USING-CACHE] [--cache-file CACHE-FILE] [--diff] [--format FORMAT] [--stop-on-violation] [--show-progress SHOW-PROGRESS] [--] [<path>...]

Script php-cs-fixer fix --ansi --verbose --diff --config=.php-cs-fixer.user-guide.php handling the cs-fix event returned with error code 1

@paulbalandan
Copy link
Member Author

I pushed a different approach. I disabled registering custom fixers for PHP 7.4. Only for PHP 8.0 and above

@paulbalandan paulbalandan changed the title Adjust php matrix of coding-standards workflow Adjust registering of custom fixers for PHP 8.0+ only Jul 18, 2023
Copy link
Member

@kenjis kenjis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worked on PHP 7.4. Thank you!

@paulbalandan paulbalandan merged commit 8024ff9 into codeigniter4:develop Jul 18, 2023
@paulbalandan paulbalandan deleted the cs-workflow branch July 18, 2023 09:44
@kenjis kenjis mentioned this pull request Jul 21, 2023
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants