-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #573 from PHPCSStandards/feature/getmethodproperti…
…es-bugfix-closure-use-vs-return-type BCFile/FunctionDeclarations::get[Method]Properties(): skip over closure use statements
- Loading branch information
Showing
7 changed files
with
405 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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
5 changes: 5 additions & 0 deletions
5
Tests/BackCompat/BCFile/GetMethodPropertiesParseError1Test.inc
This file contains 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,5 @@ | ||
<?php | ||
|
||
/* testParseError */ | ||
// Intentional parse error. | ||
$incompleteUse = function(int $a, string $b = '') use(&$import, |
54 changes: 54 additions & 0 deletions
54
Tests/BackCompat/BCFile/GetMethodPropertiesParseError1Test.php
This file contains 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,54 @@ | ||
<?php | ||
/** | ||
* PHPCSUtils, utility functions and classes for PHP_CodeSniffer sniff developers. | ||
* | ||
* @package PHPCSUtils | ||
* @copyright 2019-2020 PHPCSUtils Contributors | ||
* @license https://opensource.org/licenses/LGPL-3.0 LGPL3 | ||
* @link https://github.com/PHPCSStandards/PHPCSUtils | ||
*/ | ||
|
||
namespace PHPCSUtils\Tests\BackCompat\BCFile; | ||
|
||
use PHPCSUtils\BackCompat\BCFile; | ||
use PHPCSUtils\TestUtils\UtilityMethodTestCase; | ||
use PHPCSUtils\Tokens\Collections; | ||
|
||
/** | ||
* Tests for the \PHPCSUtils\BackCompat\BCFile::getMethodProperties method. | ||
* | ||
* @covers \PHPCSUtils\BackCompat\BCFile::getMethodProperties | ||
* | ||
* @group functiondeclarations | ||
* | ||
* @since 1.0.11 | ||
*/ | ||
final class GetMethodPropertiesParseError1Test extends UtilityMethodTestCase | ||
{ | ||
|
||
/** | ||
* Test handling of closure declarations with an incomplete use clause. | ||
* | ||
* @return void | ||
*/ | ||
public function testParseError() | ||
{ | ||
$target = $this->getTargetToken('/* testParseError */', Collections::functionDeclarationTokens()); | ||
$result = BCFile::getMethodProperties(self::$phpcsFile, $target); | ||
|
||
$expected = [ | ||
'scope' => 'public', | ||
'scope_specified' => false, | ||
'return_type' => '', | ||
'return_type_token' => false, | ||
'return_type_end_token' => false, | ||
'nullable_return_type' => false, | ||
'is_abstract' => false, | ||
'is_final' => false, | ||
'is_static' => false, | ||
'has_body' => false, | ||
]; | ||
|
||
$this->assertSame($expected, $result); | ||
} | ||
} |
This file contains 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 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
Oops, something went wrong.