-
Notifications
You must be signed in to change notification settings - Fork 569
Fix slow analysis on return with a big OR condition #5049
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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7e60d89
Fix slow analysis on return with a big OR condition
staabm 991b5e4
Added regression test
staabm 9657f0d
use the same BOOLEAN_EXPRESSION_MAX_PROCESS_DEPTH as MutatingScope
staabm 5930af2
Update NodeScopeResolver.php
staabm 74c6509
Update bug-14207.php
staabm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| <?php declare(strict_types = 1); | ||
|
|
||
| namespace Bug14207; | ||
|
|
||
| use function assert; | ||
| use function PHPStan\Testing\assertType; | ||
|
|
||
| class WP_HTML_Token { | ||
| public string $namespace; | ||
| public string $node_name; | ||
| } | ||
|
|
||
| class HelloWorld | ||
| { | ||
| /** | ||
| * Returns whether an element of a given name is in the HTML special category. | ||
| * | ||
| * @since 6.4.0 | ||
| * | ||
| * @see https://html.spec.whatwg.org/#special | ||
| * | ||
| * @param WP_HTML_Token|string $tag_name Node to check, or only its name if in the HTML namespace. | ||
| * @return bool Whether the element of the given name is in the special category. | ||
| */ | ||
| public static function is_special( $tag_name ): bool { | ||
| if ( is_string( $tag_name ) ) { | ||
| $tag_name = strtoupper( $tag_name ); | ||
| } else { | ||
| $tag_name = 'html' === $tag_name->namespace | ||
| ? strtoupper( $tag_name->node_name ) | ||
| : "{$tag_name->namespace} {$tag_name->node_name}"; | ||
| } | ||
|
|
||
| assertType('non-falsy-string|uppercase-string', $tag_name); | ||
|
|
||
| $x = ( | ||
| 'ADDRESS' === $tag_name || | ||
| 'APPLET' === $tag_name || | ||
| 'AREA' === $tag_name || | ||
| 'ARTICLE' === $tag_name || | ||
| 'ASIDE' === $tag_name || | ||
| 'BASE' === $tag_name || | ||
| 'BASEFONT' === $tag_name || | ||
| 'BGSOUND' === $tag_name || | ||
| 'BLOCKQUOTE' === $tag_name || | ||
| 'BODY' === $tag_name || | ||
| 'BR' === $tag_name || | ||
| 'BUTTON' === $tag_name || | ||
| 'CAPTION' === $tag_name || | ||
| 'CENTER' === $tag_name || | ||
| 'COL' === $tag_name || | ||
| 'COLGROUP' === $tag_name || | ||
| 'DD' === $tag_name || | ||
| 'DETAILS' === $tag_name || | ||
| 'DIR' === $tag_name || | ||
| 'DIV' === $tag_name || | ||
| 'DL' === $tag_name || | ||
| 'DT' === $tag_name || | ||
| 'EMBED' === $tag_name || | ||
| 'FIELDSET' === $tag_name || | ||
| 'FIGCAPTION' === $tag_name || | ||
| 'FIGURE' === $tag_name || | ||
| 'FOOTER' === $tag_name || | ||
| 'FORM' === $tag_name || | ||
| 'FRAME' === $tag_name || | ||
| 'FRAMESET' === $tag_name || | ||
| 'H1' === $tag_name || | ||
| 'H2' === $tag_name || | ||
| 'H3' === $tag_name || | ||
| 'H4' === $tag_name || | ||
| 'H5' === $tag_name || | ||
| 'H6' === $tag_name || | ||
| 'HEAD' === $tag_name || | ||
| 'HEADER' === $tag_name || | ||
| 'HGROUP' === $tag_name || | ||
| 'HR' === $tag_name || | ||
| 'HTML' === $tag_name || | ||
| 'IFRAME' === $tag_name || | ||
| 'IMG' === $tag_name || | ||
| 'INPUT' === $tag_name || | ||
| 'KEYGEN' === $tag_name || | ||
| 'LI' === $tag_name || | ||
| 'LINK' === $tag_name || | ||
| 'LISTING' === $tag_name || | ||
| 'MAIN' === $tag_name || | ||
| 'MARQUEE' === $tag_name || | ||
| 'MENU' === $tag_name || | ||
| 'META' === $tag_name || | ||
| 'NAV' === $tag_name || | ||
| 'NOEMBED' === $tag_name || | ||
| 'NOFRAMES' === $tag_name || | ||
| 'NOSCRIPT' === $tag_name || | ||
| 'OBJECT' === $tag_name || | ||
| 'OL' === $tag_name || | ||
| 'P' === $tag_name || | ||
| 'PARAM' === $tag_name || | ||
| 'PLAINTEXT' === $tag_name || | ||
| 'PRE' === $tag_name || | ||
| 'SCRIPT' === $tag_name || | ||
| 'SEARCH' === $tag_name || | ||
| 'SECTION' === $tag_name || | ||
| 'SELECT' === $tag_name || | ||
| 'SOURCE' === $tag_name || | ||
| 'STYLE' === $tag_name || | ||
| 'SUMMARY' === $tag_name || | ||
| 'TABLE' === $tag_name || | ||
| 'TBODY' === $tag_name || | ||
| 'TD' === $tag_name || | ||
| 'TEMPLATE' === $tag_name || | ||
| 'TEXTAREA' === $tag_name || | ||
| 'TFOOT' === $tag_name || | ||
| 'TH' === $tag_name || | ||
| 'THEAD' === $tag_name || | ||
| 'TITLE' === $tag_name || | ||
| 'TR' === $tag_name || | ||
| 'TRACK' === $tag_name || | ||
| 'UL' === $tag_name || | ||
| 'WBR' === $tag_name || | ||
| 'XMP' === $tag_name || | ||
|
|
||
| // MathML. | ||
| 'math MI' === $tag_name || | ||
| 'math MO' === $tag_name || | ||
| 'math MN' === $tag_name || | ||
| 'math MS' === $tag_name || | ||
| 'math MTEXT' === $tag_name || | ||
| 'math ANNOTATION-XML' === $tag_name || | ||
|
|
||
| // SVG. | ||
| 'svg DESC' === $tag_name || | ||
| 'svg FOREIGNOBJECT' === $tag_name || | ||
| 'svg TITLE' === $tag_name | ||
| ); | ||
|
|
||
| assertType('bool', $x); | ||
|
|
||
| return $x; | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this type is not correct, but its a pre-existing unrelated problem: created a separate issue for that