Skip to content
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

Support for php 8.0 ReflectionUnionType in lib/Dispatcher.php #35

Open
TysonAndre opened this issue Nov 6, 2019 · 0 comments
Open

Support for php 8.0 ReflectionUnionType in lib/Dispatcher.php #35

TysonAndre opened this issue Nov 6, 2019 · 0 comments

Comments

@TysonAndre
Copy link
Contributor

TysonAndre commented Nov 6, 2019

https://wiki.php.net/rfc/union_types_v2 was merged.

This introduces ReflectionUnionType extends ReflectionType. https://wiki.php.net/rfc/union_types_v2#reflection - ReflectionUnionType->getTypes() should be used if it exists. (similar to how phpdoc union types are used).

The existing code wouldn't work, because $class = (string)$paramType would contain |.

Also, I think that nullable types may get converted to ?stdClass in 8.0 in nullable types of union types

                            if ($paramType instanceof ReflectionNamedType) {
                                // We have object data to map and want the class name.
                                // This should not include the `?` if the type was nullable.
                                $class = $paramType->getName();
                            } else {
                                // Fallback for php 7.0, which is still supported (and doesn't have nullable).
                                $class = (string)$paramType;
                            }
                            $value = $this->mapper->map($value, new $class());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants