New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backport recognition of return type hints #323
Merged
wimg
merged 8 commits into
PHPCompatibility:master
from
jrfnl:feature/return-types-back-compat
Feb 16, 2017
Merged
Backport recognition of return type hints #323
wimg
merged 8 commits into
PHPCompatibility:master
from
jrfnl:feature/return-types-back-compat
Feb 16, 2017
Conversation
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
jrfnl
force-pushed
the
feature/return-types-back-compat
branch
from
January 16, 2017 02:18
3c99656
to
d7fabf8
Compare
Rebased for merge conflicts |
Never mind, apparently it was just slow to trigger. |
jrfnl
force-pushed
the
feature/return-types-back-compat
branch
from
January 18, 2017 10:52
806cd41
to
fcbda25
Compare
2 similar comments
jrfnl
force-pushed
the
feature/return-types-back-compat
branch
from
January 18, 2017 11:51
fcbda25
to
a7ecf91
Compare
5 similar comments
jrfnl
force-pushed
the
feature/return-types-back-compat
branch
3 times, most recently
from
January 20, 2017 04:11
642716b
to
13963f6
Compare
1 similar comment
This was referenced Jan 20, 2017
This function itself is not unit tested as the sniffs in which it will be used effectively unit test it already.
…rationsSniff It wasn't just scalar return types which were introduced in PHP 7, return types didn't exist at all before that.
…eTypesSniff`. Includes extra unit test cases for namespaced classes.
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.
jrfnl
force-pushed
the
feature/return-types-back-compat
branch
from
February 6, 2017 21:51
13963f6
to
c21e981
Compare
Rebased |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When reviewing test skip conditions I came across the
NewNullableTypes
andNewScalarReturnTypeDeclarations
which both skipped for PHPCS < 2.4.0 for tests involving return type hints. Turned out this was not that difficult to backport.getReturnTypeHintToken()
utility function which will be used by both sniffs.self
andcallable
not being recognized as T_RETURN_TYPE in PHPCS < 2.6.0getReturnTypeHintToken()
utility function in both theNewNullableTypes
andNewReturnTypeDeclarations
sniffs.Additionally, this PR:
NewScalarReturnTypeDeclarations
sniff toNewReturnTypeDeclarations
.Return types didn't exist at all before PHP 7.0, so it wasn't just scalar return types which were introduced in PHP 7.0.
NewReturnTypeDeclarations
sniff.Fixes: theFixed in Sync the?
of a nullable type hint not being added correctly to the typehint content forarray
,callable
andself
in theNewNullableTypes
sniff.getMethodParameters()
method with the version now merged in PHPCS #326NewNullableTypes
sniff.Includes additional unit test cases for namespaced class name return hints (both) and for
array
,callable
andself
return type hints for theNewReturnTypeDeclarations
sniff.[Edit] I've added one more commit to this PR to allow for an upstream change in the upcoming PHPCS 2.7.2 which introduces a new
T_NULLABLE
token which was breaking theNewNullableTypes
sniff.Ref: squizlabs/PHP_CodeSniffer#1263
Ref: squizlabs/PHP_CodeSniffer@b2b4b28
[Edit] And another commit... now allowing for type hints in anonymous functions. Including unit tests for the same.