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

PHPStan Level 2 fixes #785

Merged
merged 2 commits into from
Apr 6, 2020
Merged

Conversation

szepeviktor
Copy link
Contributor

@szepeviktor szepeviktor commented Apr 5, 2020

By submitting a PR to this repository, I agree to the terms within the Auth0 Code of Conduct.

Description

@joshcanhelp Started static analysis by @phpstan

References

https://packagist.org/packages/szepeviktor/phpstan-wordpress

Testing

Please consider using PHPStan on at least Level 4.

phpstan.neon.dist

#$ composer require --dev szepeviktor/phpstan-wordpress
#$ vendor/bin/phpstan analyze -l 3

includes:
    - vendor/szepeviktor/phpstan-wordpress/extension.neon
parameters:
    level: max
    inferPrivatePropertyTypeFromConstructor: true
    autoload_files:
        - functions.php
        # FIXME Must comment out require_once twice!!!
        - WP_Auth0.php
    paths:
        - functions.php
        - lib/
    ignoreErrors:
        # Uses func_get_args()
        - '#^Function apply_filters(_ref_array)? invoked with [34567] parameters, 2 required\.$#'

Checklist

  • I have added documentation for new/changed functionality in this PR or in auth0.com/docs
  • All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used, if not master

@szepeviktor szepeviktor requested a review from a team April 5, 2020 22:52
@szepeviktor szepeviktor mentioned this pull request Apr 5, 2020
Copy link
Contributor

@joshcanhelp joshcanhelp left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution here! I have one specific comment in here but, generally ... is this something we can add to CI? And what does it provide beyond the PHPCS scan we have there now?

lib/WP_Auth0_Embed_Widget.php Show resolved Hide resolved
lib/WP_Auth0_LoginManager.php Outdated Show resolved Hide resolved
@szepeviktor
Copy link
Contributor Author

is this something we can add to CI?

Yes! See #786

And what does it provide beyond the PHPCS scan we have there now?

On Level 0-4 PHPStan corrects critical errors (non-existent things, invalid function calls) and invalid PHPDoc blocks,
although on Level 5-8 more benefits come!

PHPCS can only deliver a very tiny piece of PHPStan.

@joshcanhelp joshcanhelp added this to the 4.1.0 milestone Apr 6, 2020
@joshcanhelp
Copy link
Contributor

joshcanhelp commented Apr 6, 2020

❯ composer pre-commit
> "vendor/bin/phpcs"
............................................................ 60 / 66 (91%)
......                                                       66 / 66 (100%)


Time: 15.21 secs; Memory: 22MB

> "vendor/bin/phpunit"
Installing...
Running as single site... To run multisite, use -c tests/phpunit/multisite.xml
Not running ajax tests. To execute these, use --group ajax.
Not running ms-files tests. To execute these, use --group ms-files.
Not running external-http tests. To execute these, use --group external-http.
PHPUnit 6.5.14 by Sebastian Bergmann and contributors.

Runtime:       PHP 7.1.33 with Xdebug 2.6.1
Configuration: ~/Sites/wp-auth0/wp-content/plugins/auth0/phpunit.xml.dist

...............................................................  63 / 409 ( 15%)
............................................................... 126 / 409 ( 30%)
............................................................... 189 / 409 ( 46%)
............................................................... 252 / 409 ( 61%)
............................................................... 315 / 409 ( 77%)
............................................................... 378 / 409 ( 92%)
...............................                                 409 / 409 (100%)

Time: 17.29 seconds, Memory: 48.00MB

OK (409 tests, 1561 assertions)

@joshcanhelp joshcanhelp merged commit 071f927 into auth0:master Apr 6, 2020
@szepeviktor szepeviktor deleted the phpstan-Level-2 branch April 6, 2020 16:35
@szepeviktor szepeviktor mentioned this pull request Jan 9, 2021
3 tasks
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants