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

Raise PHPStan level for the AmpProject\AmpWP package to 4 #4733

Closed
schlessera opened this issue May 15, 2020 · 2 comments · Fixed by #7096
Closed

Raise PHPStan level for the AmpProject\AmpWP package to 4 #4733

schlessera opened this issue May 15, 2020 · 2 comments · Fixed by #7096
Labels
Changelogged Whether the issue/PR has been added to release notes. Groomed P1 Medium priority Tech Debt Deprecations, inefficiencies, code health WS:Perf Work stream for Metrics, Performance and Optimizer
Projects
Milestone

Comments

@schlessera
Copy link
Collaborator

Feature description

The plugin package (AmpProject\AmpWP) is currently sitting at and enforcing level 3 of PHPStan static analysis.

There are 27 errors that need to be fixed so that we can raise the level to 4 and enforce this new quality level in Travis CI.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • PHPStan does not show any detected errors when run on level 4.

Implementation brief

  • Change the level to 4 in the file phpstan.neon.dist.
  • Run composer analyze.
  • Fix detected errors until no more are found.

QA testing instructions

Demo

Changelog entry

@schlessera schlessera added the Tech Debt Deprecations, inefficiencies, code health label May 15, 2020
@schlessera
Copy link
Collaborator Author

includes/admin/class-amp-post-meta-box.php

Line Error
136 Property WP_Screen::$is_block_editor (bool) in isset() is not nullable.
268 Property WP_Post::$ID (int) in isset() is not nullable.

includes/amp-helper-functions.php

Line Error
1703 Strict comparison using === between false and string will always evaluate to false.

includes/class-amp-theme-support.php

Line Error
423 Call to function method_exists() with (int

includes/cli/class-amp-cli-validation-command.php

Line Error
698 If condition is always true.

includes/embeds/class-amp-facebook-embed-handler.php

Line Error
109 Strict comparison using === between null and string will always evaluate to false.

includes/embeds/class-amp-playlist-embed-handler.php

Line Error
98 Property AMP_Playlist_Embed_Handler::$removed_shortcode_callback (callable) in isset() is not nullable.

includes/embeds/class-amp-tiktok-embed-handler.php

Line Error
53 Left side of && is always true.

includes/options/class-amp-options-manager.php

Line Error
322 Property WP_Post_Type::$label (string) in isset() is not nullable.
554 Call to function is_array() with bool will always evaluate to false.

includes/sanitizers/class-amp-base-sanitizer.php

Line Error
228 Strict comparison using === between null and string will always evaluate to false.

includes/sanitizers/class-amp-core-theme-sanitizer.php

Line Error
1012 Negated boolean expression is always false.
1706 Instanceof between DOMElement and DOMComment will always evaluate to false.

includes/sanitizers/class-amp-iframe-sanitizer.php

Line Error
384 Result of && is always false.

includes/sanitizers/class-amp-img-sanitizer.php

Line Error
401 Strict comparison using === between 'figure' and 'a' will always evaluate to false.

includes/sanitizers/class-amp-meta-sanitizer.php

Line Error
318 If condition is always true.

includes/sanitizers/class-amp-style-sanitizer.php

Line Error
476 Property AMP_Style_Sanitizer::$used_class_names (array) in isset() is not nullable.
697 Property AMP_Style_Sanitizer::$used_tag_names (array) in isset() is not nullable.
2658 Negated boolean expression is always false.

includes/sanitizers/class-amp-tag-and-attribute-sanitizer.php

Line Error
2646 Left side of && is always true.
2646 Right side of && is always true.

includes/templates/class-amp-post-template.php

Line Error
190 Property AMP_Post_Template::$data (array) in isset() is not nullable.

includes/utils/class-amp-image-dimension-extractor.php

Line Error
146 If condition is always false.

includes/validation/class-amp-validation-error-taxonomy.php

Line Error
464 Call to function in_array() with arguments string, array(0, 1, 3, 2) and true will always evaluate to false.
464 Result of && is always false.

includes/validation/class-amp-validation-manager.php

Line Error
1830 If condition is always true.

src/Admin/SiteHealth.php

Line Error
325 Right side of && is always true.

@kmyram kmyram added this to Backlog in Ongoing Jun 11, 2020
@kmyram kmyram added the WS:Perf Work stream for Metrics, Performance and Optimizer label Aug 5, 2020
@kmyram kmyram added P1 Medium priority Groomed labels Nov 24, 2020
@westonruter westonruter added this to the v2.3 milestone Apr 14, 2022
@westonruter westonruter moved this from Backlog to To Do in Ongoing Apr 14, 2022
@dhaval-parekh dhaval-parekh self-assigned this May 10, 2022
@dhaval-parekh dhaval-parekh moved this from To Do to In Progress in Ongoing May 10, 2022
@dhaval-parekh dhaval-parekh moved this from In Progress to Ready for Review in Ongoing May 11, 2022
@dhaval-parekh dhaval-parekh moved this from Ready for Review to In Progress in Ongoing May 13, 2022
@westonruter westonruter moved this from In Progress to Ready for Review in Ongoing May 18, 2022
@westonruter westonruter moved this from Ready for Review to Ready for QA in Ongoing May 18, 2022
@pooja-muchandikar
Copy link

Performed smoke testing on the plugin and the features are working as expected ✅
No blockers found so far.

@westonruter westonruter moved this from Ready for QA to QA Passed in Ongoing Jun 13, 2022
@westonruter westonruter added the Changelogged Whether the issue/PR has been added to release notes. label Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelogged Whether the issue/PR has been added to release notes. Groomed P1 Medium priority Tech Debt Deprecations, inefficiencies, code health WS:Perf Work stream for Metrics, Performance and Optimizer
Projects
Ongoing
  
QA Passed
Development

Successfully merging a pull request may close this issue.

5 participants