-
Notifications
You must be signed in to change notification settings - Fork 9.4k
improve and make more strict autoload.php #28923
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
improve and make more strict autoload.php #28923
Conversation
Hi @rvitaliy. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review. For more details, please, review the Magento Contributor Guide documentation. |
@magento run all tests |
@magento run Functional Tests B2B |
1 similar comment
@magento run Functional Tests B2B |
$vendorAutoload = ( | ||
static function (): ?string { | ||
$vendorDir = require VENDOR_PATH; | ||
|
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 @rvitaliy. Thank you for your collaboration. Could I kindly ask you to provide a comment for these two declarations of $vendorAutoload
with highlighting what is a particular block for? At first glance, these blocks of code look very similar (almost the same) and it's hard to guess why we need such an approach. I see that in first case we have the trailing slash, but let's make developers life a little bit easier and highlight this case in the comments. Thank you!
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.
@rogyar
sorry, but i can't do it.
personally i don't undestand why we need the second check without BP prefix.
i'm refactor the old code without change to the logics, make it more strict and readable.
IMHO: we can remove the second block of check, app/{$vendor}
is not a valid path for vendor.
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.
Good point. I see that this functionality has been recently added. So I assume it was done for a purpose.
Unfortunately, there's no additional information about this change. Well then, let's leave it as it is. Maybe it's required for some particular circumstances (like CI system or so).
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.
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.
so the second check is need to autoload vendors from the global path
Hi @rogyar, thank you for the review. |
QA Not applicable |
@magento create issue |
Hi @rvitaliy, thank you for your contribution! |
Description (*)
two improvements:
is_readable
instead offile_exists
. if we userequire
orinclude
on a existing file that is not readable php generate errors. So we need to chech if file_exists and is_readable (is_readable
do both things)$vendorAutoload
, it's allow us to have a more readable code with early return.Related Pull Requests
none
Fixed Issues (if relevant)
none
Manual testing scenarios (*)
not necessary, if CI passes this code is good, it's only technical improvement.
Contribution checklist (*)
Resolved issues: