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

Test enhancement for fix PSR-4 autoloading #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ php:
- '7.1'
- '7.2'
- '7.3'
- '7.4'
Copy link
Author

Choose a reason for hiding this comment

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

Add php-7.4 version test during Travis CI build.


before_script:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
Expand All @@ -16,7 +17,7 @@ script:
# Fail the Travis CI build on the first error.
- set -e
- mkdir -p build/logs
- php vendor/bin/phpcs --standard=PSR12 src
- php vendor/bin/phpcs --standard=PSR2 src
Copy link
Author

Choose a reason for hiding this comment

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

Revert the PSR-2 coding style and it can avoid PSR-12 coding style checking to cause the Travis CI build failed.

Copy link
Member

Choose a reason for hiding this comment

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

There are many things about PSR-12 that I like, in fact most things. In fact, the only thing I disagree with is that they no longer allow <?php declare(strict_types=1);, which I strongly feel is the bestest way to declare this.

Here is the corporate workaround:
PHPExpertsInc/SimpleDTO@1faa8a4

I'm pretty sure all of our projects modded after April 8th 2020 are failing this test.

Copy link
Author

Choose a reason for hiding this comment

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

Is it possible to consider using phpcs.xml file to ignore declare(strict_types=1); checking?

Copy link
Author

Choose a reason for hiding this comment

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

@hopeseekr, after searching some solutions about ignoring declare strict type checking, here is the proper solution:

The phpcs.xml file is as follows:

<?xml version="1.0"?>
<ruleset name="Custom Standard" namespace="MyProject\CS\Standard">
  <rule ref="PSR12">
    <exclude name="PSR12.Files.FileHeader" />
    <exclude name="PSR12.Files.OpenTag" />
  </rule>
</ruleset>

- php vendor/bin/phpcs --standard=PSR1 tests
- php vendor/bin/phpstan analyze --level max src
- vendor/bin/phpunit --coverage-text --coverage-clover build/logs/clover.xml
Expand Down
3 changes: 0 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
"autoload-dev": {
"psr-4": { "PHPExperts\\Combinatorics\\Tests\\" : "tests/" }
},
"config": {
"classmap-authoritative": true
},
"scripts": {
"post-create-project-cmd": [
"php install.php"
Expand Down
5 changes: 5 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
parameters:
checkMissingIterableValueType: false
paths:
- src/
- tests/
Copy link
Author

Choose a reason for hiding this comment

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

To fix following error during PHPStan static code analyzing, using this phpstan.neon file to ignore checkMissingIterableValueType setting.

Copy link
Member

Choose a reason for hiding this comment

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

File renamed without changes.