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

HTML API: phpstan check #7805

Draft
wants to merge 6 commits into
base: trunk
Choose a base branch
from
Draft
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 composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"squizlabs/php_codesniffer": "3.10.3",
"wp-coding-standards/wpcs": "~3.1.0",
"phpcompatibility/phpcompatibility-wp": "~2.1.3",
"yoast/phpunit-polyfills": "^1.1.0"
"yoast/phpunit-polyfills": "^1.1.0",
"phpstan/phpstan": "^2.0"
},
"config": {
"allow-plugins": {
Expand Down
12 changes: 12 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
parameters:
level: 2
phpVersion: 70224
paths:
- src/wp-includes/html-api
- src/wp-includes/class-wp-token-map.php
scanFiles:
- src/wp-includes/compat.php
- src/wp-includes/formatting.php
- src/wp-includes/functions.php
- src/wp-includes/kses.php
- src/wp-includes/l10n.php
2 changes: 1 addition & 1 deletion src/wp-includes/html-api/class-wp-html-processor-state.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ class WP_HTML_Processor_State {
*
* @see https://html.spec.whatwg.org/#concept-frag-parse-context
*
* @var [string, array]|null
* @var array{string, array}|null
*/
public $context_node = null;

Expand Down
6 changes: 3 additions & 3 deletions src/wp-includes/html-api/class-wp-html-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,8 @@ function ( WP_HTML_Token $token ): void {
* @since 6.7.0
*
* @param string $message Explains support is missing in order to parse the current node.
*
* @return never
*/
private function bail( string $message ) {
$here = $this->bookmarks[ $this->state->current_token->bookmark_name ];
Expand Down Expand Up @@ -3013,9 +3015,7 @@ private function step_in_body(): bool {
}

$this->generate_implied_end_tags( $token_name );
if ( $node !== $this->state->stack_of_open_elements->current_node() ) {
// @todo Record parse error: this error doesn't impact parsing.
}
// @todo record parse error if $node is not the current node.

foreach ( $this->state->stack_of_open_elements->walk_up() as $item ) {
$this->state->stack_of_open_elements->pop();
Expand Down
7 changes: 3 additions & 4 deletions src/wp-includes/html-api/class-wp-html-tag-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -1547,12 +1547,11 @@ private function skip_script_data(): bool {
continue;
}

if ( '/' === $html[ $at ] ) {
$is_closing = '/' === $html[ $at ];

if ( $is_closing ) {
$closer_potentially_starts_at = $at - 1;
$is_closing = true;
++$at;
} else {
$is_closing = false;
}

/*
Expand Down
Loading