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

Conversation

peter279k
Copy link

@peter279k peter279k commented Jul 28, 2020

Changed log

  • Remove classmap-authoritative to avoid deprecated PSR-4 autoloading warning message.
  • Modify the PHP file name and let this file name be same as class name. It can be loading class correctly during composer autoloading generating.

This change is Reviewable

@@ -16,7 +16,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>

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.

@@ -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.

@hopeseekr
Copy link
Member

Thank you very much for this PR.

I am merging it next time I see it if I don't fix the issues myself.

Thank you for encouraging me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants