Skip to content

Commit

Permalink
Merge pull request #799 from Automattic/feature/declarationcompatibil…
Browse files Browse the repository at this point in the history
…ity-sync-with-wp
  • Loading branch information
GaryJones authored Sep 19, 2023
2 parents 9749b01 + ff14488 commit fbcc951
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class DeclarationCompatibilitySniff extends AbstractScopeSniff {
'widget_options' => [
'default' => 'array()',
],
'constol_options' => [
'control_options' => [
'default' => 'array()',
],
],
Expand Down Expand Up @@ -103,7 +103,7 @@ class DeclarationCompatibilitySniff extends AbstractScopeSniff {
'output' => [
'pass_by_reference' => true,
],
'object',
'data_object',
'depth' => [
'default' => '0',
],
Expand All @@ -118,7 +118,7 @@ class DeclarationCompatibilitySniff extends AbstractScopeSniff {
'output' => [
'pass_by_reference' => true,
],
'object',
'data_object',
'depth' => [
'default' => '0',
],
Expand Down Expand Up @@ -158,7 +158,7 @@ class DeclarationCompatibilitySniff extends AbstractScopeSniff {
'elements',
],
'unset_children' => [
'el',
'element',
'children_elements' => [
'pass_by_reference' => true,
],
Expand Down Expand Up @@ -215,7 +215,7 @@ protected function processTokenWithinScope( File $phpcsFile, $stackPtr, $currSco
return;
}

// Meed to define the originalParentClassName since we might override the parentClassName due to signature notations grouping.
// Need to define the originalParentClassName since we might override the parentClassName due to signature notations grouping.
$originalParentClassName = $parentClassName;

if ( array_key_exists( $parentClassName, $this->checkClasses ) === false ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,21 @@ class MyWalker extends Walker {
function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
} // Ok.

function unset_children( $el, $children_elements ) {
function unset_children( $element, $children_elements ) {
} // Bad. $children_elements should be passed by reference

function walk( $elements, $max_depth, ...$args ) {
} // Ok.

function paged_walk( $elements, $max_depth, $page_num, $per_page ) {
} // Bad. Missing $args.

function paged_walk( $elements, $max_depth, $page_num, $per_page, $args ) {
} // Bad. $args is not variadic.

function start_el( $output, $data_object, $depth, $args = array(), $current_object_id = 0 ) {
} // Bad. $output should be passed by reference, $depth should have a default value.

function end_el( &$output, $data_object, $depth = 0, $args = array() ) {
} // Ok.
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function getErrorList() {
128 => 1,
134 => 1,
137 => 1,
140 => 1,
];
}

Expand Down

0 comments on commit fbcc951

Please sign in to comment.