Skip to content

Commit 386c849

Browse files
committed
Make return type check PHPCS v3 compat
Fixes #16
1 parent ae34a97 commit 386c849

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## NOT RELEASED
44
- Fixed false positive "missing argument type declaration" when param are passed by-reference.
5+
- Make `ReturnTypeDeclarationSniff` compatible with PHPCS 3.3
56

67
## 0.13.2
78
- Changed "squizlabs/php_codesniffer" in composer.json to "~3.2.3"

Inpsyde/Sniffs/CodeQuality/ReturnTypeDeclarationSniff.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,11 @@ private function maybeGeneratorErrors(
234234
*/
235235
private function returnTypeContent(File $file, int $functionPosition): string
236236
{
237+
$info = $file->getMethodProperties($functionPosition);
238+
if (array_key_exists('return_type', $info) && is_string($info['return_type'])) {
239+
return ltrim($info['return_type'], '\\');
240+
}
241+
237242
$tokens = $file->getTokens();
238243
$returnTypeToken = $file->findNext(
239244
[T_RETURN_TYPE],

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"minimum-stability": "stable",
2929
"require": {
3030
"php": ">=7.0",
31-
"squizlabs/php_codesniffer": "~3.2.3",
31+
"squizlabs/php_codesniffer": "^3",
3232
"dealerdirect/phpcodesniffer-composer-installer": "^0.4",
3333
"wp-coding-standards/wpcs": "^0.14",
3434
"automattic/phpcs-neutron-standard": "^1",

0 commit comments

Comments
 (0)