-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Support for non-FQN classes on web-API interfaces. #17424
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 non-FQN classes on web-API interfaces. #17424
Conversation
This commit provides a support for "use" statement in web-API interfaces and the usage of non-FQN class names in doctypes. It also provides a fix for MSI-1524 and MSI-1537.
Hi @phoenix128. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
@phoenix128 looks like the Integration build is broken on your latest PR |
@maghamed , trying to understand why it breaks the integration tests. |
@maghamed , it should be fixed now. |
@ishakhsuvarov , I have some failing tests in the code quality of test classes I use as fixture, should I ignore it? |
@ishakhsuvarov , any news here? Thanks. |
@phoenix128 Sorry for the delay. I don't have any major comments, hopefully it's getting merge soon enough. |
* @param ClassReflection $sourceClass | ||
* @return array | ||
*/ | ||
public function getAliasMapping(ClassReflection $sourceClass): array |
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.
Please, consider making methods private, looks like they used only in the private implementation
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.
Hi @sidolov ,
it is used in \Magento\Framework\Reflection\Test\Unit\TypeProcessorTest
. We have two options: remove tests or eject this method to a dedicated service.
*/ | ||
public function isSimpleType(string $typeName): bool | ||
{ | ||
return strtolower($typeName) === $typeName; |
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.
I can't help but feel like this should be a check against a dictionary of reserved words...
Wouldn't something like use \Magento\Framework\App\ObjectManager as om;
cause weird problems and error messages that wouldn't make sense?
While it's not the way one should be writing code (subjective), I think we can still prevent the issue if its tackled here?
Hi @sidolov, thank you for the review. |
Hi @phoenix128, thank you for your contribution! |
This commit provides a support for "use" statement in web-API interfaces and the usage of non-FQN class names in doctypes. It also provides a fix for MSI-1524 and MSI-1537.
Description
Before this commit you were not able to import class names in interfaces used for web-API.
For example, the following interface was not working with the non-FQN name
MyClass
imported through theuse
alias definition.Now, through a new method
\Magento\Framework\Reflection\TypeProcessor::resolveFullyQualifiedClassName
, the FQN is automatically resolved if an alias or a short name is provided.Fixed Issues (if relevant)
Contribution checklist