Skip to content

Commit

Permalink
Merge b6adfc2 into 96dd2af
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfnl committed Oct 15, 2022
2 parents 96dd2af + b6adfc2 commit d24c30e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Tests/BackCompat/BCFile/GetMethodPropertiesTest.inc
Expand Up @@ -151,6 +151,9 @@ fn&(?string $a) : ?string => $b;
/* testFunctionCallFnPHPCS353-354 */
$value = $obj->fn(true);

/* testFunctionDeclarationNestedInTernaryPHPCS2975 */
return (!$a ? [ new class { public function b(): c {} } ] : []);

/* testArrowFunctionLiveCoding */
// Intentional parse error. This has to be the last test in the file.
$fn = fn
24 changes: 24 additions & 0 deletions Tests/BackCompat/BCFile/GetMethodPropertiesTest.php
Expand Up @@ -923,6 +923,30 @@ public function testArrowFunctionReturnByRef()
$this->getMethodPropertiesTestHelper('/* ' . __FUNCTION__ . ' */', $expected);
}

/**
* Test handling of function declaration nested in a ternary, where the colon for the
* return type was incorrectly tokenized as T_INLINE_ELSE prior to PHPCS 3.5.7.
*
* @return void
*/
public function testFunctionDeclarationNestedInTernaryPHPCS2975()
{
$expected = [
'scope' => 'public',
'scope_specified' => true,
'return_type' => 'c',
'return_type_token' => 7, // Offset from the T_FN token.
'return_type_end_token' => 7, // Offset from the T_FN token.
'nullable_return_type' => false,
'is_abstract' => false,
'is_final' => false,
'is_static' => false,
'has_body' => true,
];

$this->getMethodPropertiesTestHelper('/* ' . __FUNCTION__ . ' */', $expected);
}

/**
* Test helper.
*
Expand Down

0 comments on commit d24c30e

Please sign in to comment.