-
Notifications
You must be signed in to change notification settings - Fork 17
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
fix: deprecation notice for ReflectionType::__toString() in php 7.4 #33
fix: deprecation notice for ReflectionType::__toString() in php 7.4 #33
Conversation
b2d773b
to
802d75a
Compare
Codecov Report
@@ Coverage Diff @@
## master #33 +/- ##
============================================
+ Coverage 89.65% 89.91% +0.26%
- Complexity 57 58 +1
============================================
Files 8 8
Lines 116 119 +3
============================================
+ Hits 104 107 +3
Misses 12 12
|
According to the release notes, it was deprecated in favor of https://github.com/php/php-src/blob/6f57802c59f0a82bed6a61e4ae956acea7d96dd1/UPGRADING#L389-L392 |
1732d5e
to
be6cbd6
Compare
Good point, this was copied from a helper method for a more generic use case - I wasn't really looking at how it was used here. The null checks aren't needed and adding a leading |
The review comments have been addressed. Also, what are your thoughts on increasing the minimum version of netresearch/jsonmapper to The deprecation notice might be printed to stdout, which might affect language servers. The notices can be worked around with a custom error handler. |
Can you merge and release this fix please? Along with bumping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay!
lib/Dispatcher.php
Outdated
@@ -124,7 +125,15 @@ public function dispatch($msg) | |||
// Does the parameter have a type hint? | |||
$param = $parameters[$position]; | |||
if ($param->hasType()) { | |||
$class = (string)$param->getType(); | |||
$param_type = $param->getType(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$param_type = $param->getType(); | |
$paramType = $param->getType(); |
lib/Dispatcher.php
Outdated
@@ -124,7 +125,15 @@ public function dispatch($msg) | |||
// Does the parameter have a type hint? | |||
$param = $parameters[$position]; | |||
if ($param->hasType()) { | |||
$class = (string)$param->getType(); | |||
$param_type = $param->getType(); | |||
if ($param_type instanceof ReflectionNamedType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ($param_type instanceof ReflectionNamedType) { | |
if ($paramType instanceof ReflectionNamedType) { |
lib/Dispatcher.php
Outdated
if ($param_type instanceof ReflectionNamedType) { | ||
// We have object data to map and want the class name. | ||
// This should not include the `?` if the type was nullable. | ||
$class = $param_type->getName(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$class = $param_type->getName(); | |
$class = $paramType->getName(); |
lib/Dispatcher.php
Outdated
$class = $param_type->getName(); | ||
} else { | ||
// Fallback for php 7.0, which is still supported (and doesn't have nullable). | ||
$class = (string)$param_type; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$class = (string)$param_type; | |
$class = (string)$paramType; |
be6cbd6
to
b69b94c
Compare
Review comments have been addressed. The decreased code coverage is expected - one of the branches is only reachable in php 7.1+, the other in php 7.0 |
Could you merge in master? I added 7.2 to the build matrix |
Use ReflectionNamedType->getName() for php 7.1+, instead. Continue supporting php 7.0 Fixes felixfbecker#23
b69b94c
to
d6473a9
Compare
Done |
Awesome, coverage changes went away! |
🎉 This PR is included in version 3.0.4 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Use getName instead, in php 7.1+
See https://github.com/php/php-src/blob/PHP-7.4/UPGRADING
Fixes #32