Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add additional return types to the
NewReturnTypeDeclarationsSniff
As return type hints didn't exist at all for PHP < 7.0, this sniff should also alert on return type hints for `array`, `callable`, `self` or arbitrary (namespaced) class names. Includes additional unit tests.
- Loading branch information
Showing
3 changed files
with
48 additions
and
8 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
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 |
---|---|---|
@@ -1,11 +1,17 @@ | ||
<?php | ||
|
||
// PHP 7.0+ | ||
function foo($a): bool {} | ||
|
||
function foo($a): int {} | ||
|
||
function foo($a): float {} | ||
|
||
function foo($a): string {} | ||
function foo($a): array {} | ||
function foo($a): callable {} | ||
function foo($a): self {} | ||
function foo($a): Baz {} | ||
function foo($a): \Baz {} | ||
function foo($a): myNamespace\Baz {} | ||
function foo($a): \myNamespace\Baz {} | ||
|
||
// PHP 7.1+ | ||
function foo($a): void {} |