-
-
Notifications
You must be signed in to change notification settings - Fork 436
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
Refactoring: Replace dirname(__FILE__) With Corresponding Constant #2582
Merged
fballiano
merged 7 commits into
OpenMage:1.9.4.x
from
Sdfendor:replace_dirname_file_with_constant
Sep 9, 2022
Merged
Refactoring: Replace dirname(__FILE__) With Corresponding Constant #2582
fballiano
merged 7 commits into
OpenMage:1.9.4.x
from
Sdfendor:replace_dirname_file_with_constant
Sep 9, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
github-actions
bot
added
Component: Bundle
Relates to Mage_Bundle
Component: Catalog
Relates to Mage_Catalog
Component: Downloadable
Relates to Mage_Downloadable
Component: lib/Varien
Relates to lib/Varien
Component: lib/*
Relates to lib/*
Component: Reports
Relates to Mage_Reports
JavaScript
Relates to js/*
Mage.php
Relates to app/Mage.php
shell
Relates to shell scripts
labels
Sep 9, 2022
fballiano
approved these changes
Sep 9, 2022
addison74
approved these changes
Sep 9, 2022
I like dirname(DIR) because:
|
The php documentation states only since 7.0 so it at least wasn't always there 😅. |
Agree with both, but for me this is more clear ... b/c i see we look one level above ...
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Component: Bundle
Relates to Mage_Bundle
Component: Catalog
Relates to Mage_Catalog
Component: Downloadable
Relates to Mage_Downloadable
Component: lib/Varien
Relates to lib/Varien
Component: lib/*
Relates to lib/*
Component: Reports
Relates to Mage_Reports
JavaScript
Relates to js/*
Mage.php
Relates to app/Mage.php
shell
Relates to shell scripts
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description (*)
dirname(__FILE__)
returns the directory of the current file. Since PHP 5.3.0 the constant__DIR__
exists and is equivalent to the function call (see Magic constants). At the same time it's easier to grasp at first glance. Our current minimum supported PHP version is 7.3.0.The PR replaces all
dirname(__FILE__)
calls with DIR except those in lib/Zend and lib/phpseclib which are in the process of being removed from the codebase to become externally maintained dependencies.Questions or comments
In two instances
dirname(dirname(__FILE__))
is replaced withdirname(__DIR__)
. Another variant here would bedirname(__FILE__),2)
(directory name above the current one). I've chosen the first option but have no disposition which one better to use. Maybe some of you have an opinion regarding e.g. ease of understanding?Contribution checklist (*)