Skip to content
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

[PHPCS] Add sniff for declaration of strict_types #5342

Closed
johnsaigle opened this issue Oct 21, 2019 · 4 comments · Fixed by #6039
Closed

[PHPCS] Add sniff for declaration of strict_types #5342

johnsaigle opened this issue Oct 21, 2019 · 4 comments · Fixed by #6039
Labels
Meta PR does something that organizes, upgrades, or manages the functionality of the codebase Proposal PR or issue suggesting an improvement that can be accepted, rejected or altered State: Stale PR that has had no recent activity, needs to be triaged for review or closure to proceed Testing PR contains test plan or automated test code (or config files for Travis)

Comments

@johnsaigle
Copy link
Contributor

johnsaigle commented Oct 21, 2019

https://github.com/slevomat/coding-standard/#slevomatcodingstandardtypehintsdeclarestricttypes-

This depends on adding the Slevomat coding standard as a developer dependency. This has been proposed already in #4064

PHPCS >= 3.0 is required so this isn't possible until #5349 is merged

@johnsaigle johnsaigle added Testing PR contains test plan or automated test code (or config files for Travis) Meta PR does something that organizes, upgrades, or manages the functionality of the codebase Proposal PR or issue suggesting an improvement that can be accepted, rejected or altered State: Blocked PR or issue awaiting an external event such as the merge or another PR to proceed labels Oct 21, 2019
@johnsaigle johnsaigle removed the State: Blocked PR or issue awaiting an external event such as the merge or another PR to proceed label Oct 29, 2019
@stale
Copy link

stale bot commented Jan 7, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the State: Stale PR that has had no recent activity, needs to be triaged for review or closure to proceed label Jan 7, 2020
@johnsaigle johnsaigle added the State: Blocked PR or issue awaiting an external event such as the merge or another PR to proceed label Jan 7, 2020
@stale
Copy link

stale bot commented Jan 7, 2020

The Stale label is being removed automatically because some activity has occurred or because the developers have decided that this pull request is important and should not continue to be overlooked.

@stale stale bot removed the State: Stale PR that has had no recent activity, needs to be triaged for review or closure to proceed label Jan 7, 2020
@johnsaigle
Copy link
Contributor Author

Blocked by #5396 which adds the Slevomat dependency and also handles many typing issue that will make the strict types sniff much more feasible to implement.

@johnsaigle johnsaigle added PR sent and removed State: Blocked PR or issue awaiting an external event such as the merge or another PR to proceed PR sent labels Feb 10, 2020
@stale
Copy link

stale bot commented Apr 18, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the State: Stale PR that has had no recent activity, needs to be triaged for review or closure to proceed label Apr 18, 2020
driusan pushed a commit that referenced this issue Jun 17, 2020
Previous attempts to force type hints or strict typing en masse have failed because it's just too darn complicated to do it all at once.

This introduces a new Strict Type coding standard that we can selectively apply to files by adding to an array in test/run-php-linter.sh. Hopefully this will provide an approach to using stricter typing that is easier to author and review.

Using vendor/bin/phpcbf --standard=test/StrictTypesCS.xml $file will now allow PHPCBF to automatically provide

    return types
    param types
    strict_types =1

based on PHPDocs.

It will also throw errors if Traversable types do not have specific type annotations.

The Database.class.inc file has been modified as an example of the changes

Resolves #5342
AlexandraLivadas pushed a commit to AlexandraLivadas/Loris that referenced this issue Jun 29, 2021
Previous attempts to force type hints or strict typing en masse have failed because it's just too darn complicated to do it all at once.

This introduces a new Strict Type coding standard that we can selectively apply to files by adding to an array in test/run-php-linter.sh. Hopefully this will provide an approach to using stricter typing that is easier to author and review.

Using vendor/bin/phpcbf --standard=test/StrictTypesCS.xml $file will now allow PHPCBF to automatically provide

    return types
    param types
    strict_types =1

based on PHPDocs.

It will also throw errors if Traversable types do not have specific type annotations.

The Database.class.inc file has been modified as an example of the changes

Resolves aces#5342
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Meta PR does something that organizes, upgrades, or manages the functionality of the codebase Proposal PR or issue suggesting an improvement that can be accepted, rejected or altered State: Stale PR that has had no recent activity, needs to be triaged for review or closure to proceed Testing PR contains test plan or automated test code (or config files for Travis)
Projects
None yet
1 participant