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

Reflection Adapter vs. non-empty-string #1278

Closed
ondrejmirtes opened this issue Oct 11, 2022 · 1 comment · Fixed by #1286
Closed

Reflection Adapter vs. non-empty-string #1278

ondrejmirtes opened this issue Oct 11, 2022 · 1 comment · Fixed by #1286

Comments

@ondrejmirtes
Copy link
Contributor

This PR #1234 made Adapter reflection incompatible with the native PHP reflection. The native reflection returns false in has* methods if it's asked about nonexistent elements, and throws ReflectionException in get* methods: https://3v4l.org/YebV9

But the assert($name !== ''); calls are unforgiving even for has* methods. The current situation isn't great, because these methods have string in parameter types but reject '' at runtime. So currently these problems cannot be detected and avoided with static analysis.

I'd prefer if the Adapter namespace matched the behaviour of native reflection:

For has* methods, instead of the assert, do this:

if ($s === '') {
    return false;
}

For get* methods, throw ReflectionException for empty strings.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants