Skip to content

Commit

Permalink
Add strict type coding standard (#6039)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
johnsaigle authored Jun 17, 2020
1 parent fb359f8 commit 4860cf1
Show file tree
Hide file tree
Showing 5 changed files with 246 additions and 125 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"php-webdriver/webdriver" : "^1.8.2",
"phan/phan": ">=2.3.0",
"phpmd/phpmd": "~2.8",
"phpstan/phpstan": "0.12.17"
"phpstan/phpstan": "0.12.17",
"slevomat/coding-standard": "^6.0"
},
"scripts": {
"pre-install-cmd": "mkdir -p project/libraries"
Expand Down
41 changes: 41 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4860cf1

Please sign in to comment.