Skip to content

Configure PHP version for PHP_CodeSniffer #4697

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

Merged
merged 1 commit into from
Jul 1, 2021

Conversation

morozov
Copy link
Member

@morozov morozov commented Jul 1, 2021

Q A
Type improvement
BC Break no

Currently, phpcs fails with a bunch of false-positive errors if run on PHP 8:

$ php -v
PHP 8.0.8 (cli) (built: Jun 29 2021 22:25:18) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.8, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.8, Copyright (c), by Zend Technologies
    with Xdebug v3.0.4, Copyright (c) 2002-2021, by Derick Rethans

$ phpcs
.......................EE.E......E..........E.........EEE..E 60 / 76 (79%)
E.EEEE...EEEE...                                             76 / 76 (100%)



FILE: tests/Doctrine/Tests/DBAL/Functional/Driver/PDO/ConnectionTest.php
--------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------------
 86 | ERROR | [x] Class name referenced via call of function get_class().
    |       |     (SlevomatCodingStandard.Classes.ModernClassNameReference.ClassNameReferencedViaFunctionCall)
--------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------------------------
...
And a lot more.

Note that $object::class is only available as of PHP 8.0. All of the errors are trigger with the assumption that the runtime PHP version (8.0) is the minimum supported version (7.3).

We already have some rules specific to PHP 7.4 suppressed:

dbal/phpcs.xml.dist

Lines 40 to 45 in ce7db44

<!-- Disable the rules that will require PHP 7.4 -->
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
<properties>
<property name="enableNativeTypeHint" value="false"/>
</properties>
</rule>

But there's a better way to configure the minimum supported PHP version.

Verified

This commit was signed with the committer’s verified signature. The key has expired.
marandaneto Manoel Aranda Neto
@morozov morozov marked this pull request as ready for review July 1, 2021 01:00
@morozov morozov requested a review from greg0ire July 1, 2021 01:00
@morozov morozov added this to the 2.13.3 milestone Jul 1, 2021
@morozov
Copy link
Member Author

morozov commented Jul 1, 2021

The "Coding Standards (7.4)" build is irrelevant in the context of this PR. I'll disable it before the merge.

@morozov morozov merged commit 378324a into doctrine:2.13.x Jul 1, 2021
@morozov morozov deleted the phpcs-php-version branch July 1, 2021 13:50
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants