-
Notifications
You must be signed in to change notification settings - Fork 113
[Server] Add autoload check for enum types in ReferenceHandler #225
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
base: main
Are you sure you want to change the base?
[Server] Add autoload check for enum types in ReferenceHandler #225
Conversation
Some old framework is using autoload to include with the typeName directly, e.g. `include(ini.php)` when the typeName is `ini`. If the typeName is the arbitrary type, set autoload in `enum_exists` to `false`
|
Hey @joshuatam, thanks for reaching out and bringing the patch. Can you help me understand the issue here? What's happening without this patch? |
I am integrating the sdk with Yii1, in which it will throw an error when reading Elements classes, e.g. And the error is |
|
I'm really not sure that this is an error on library side, but rather something your autoloader should catch? are you using composer or sth custom? |
| $shouldAutoload = !in_array($typeName, ['int', 'float', 'string', 'bool', 'array', 'object', 'callable', 'iterable', 'mixed', 'void', 'null', 'false', 'true', 'never']); | ||
|
|
||
| if (enum_exists($typeName, $shouldAutoload)) { |
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.
Can we do something like this?
Ie, if it is an int, we would never call enum_exists().
| $shouldAutoload = !in_array($typeName, ['int', 'float', 'string', 'bool', 'array', 'object', 'callable', 'iterable', 'mixed', 'void', 'null', 'false', 'true', 'never']); | |
| if (enum_exists($typeName, $shouldAutoload)) { | |
| if ($type->isBuiltin() === false && enum_exists($typeName)) { |
https://www.php.net/manual/en/language.types.type-system.php
Motivation and Context
Some old framework is using autoload to include with the typeName directly, e.g.
include(ini.php)when the typeName isini.If the typeName is the arbitrary type, set autoload in
enum_existstofalseHow Has This Been Tested?
Yes
Breaking Changes
No
Types of changes
Checklist
Additional context
None