-
Couldn't load subscription status.
- Fork 3
Refactor Dependencies::process() with exceptions #9
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
Refactor Dependencies::process() with exceptions #9
Conversation
| requireFile($firstExistsDependency); | ||
| $loadedDependency = $firstExistsDependency; | ||
| break; | ||
| } catch (\RuntimeException $e) { |
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.
For the change here, I was trying to make this block of code use the same conditionals logic as Fedora\Autoloader::requireFile() without copying-and-pasting the conditionals. This does have the overhead of an Exception object creation (from Fedora\Autoloader::requireFile()) and the catch though. Perhaps a copy-and-paste of the conditionals here would be better or a common function (something like Fedora\Autoloader::fileLoadable()?) that this code block and Fedora\Autoloader::requireFile() could both use?
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.
no problem for me, feel free to merge for 0.2.0 is you want
src/Dependencies.php
Outdated
| foreach ($dependencies as $dependency) { | ||
| if (is_array($dependency)) { | ||
| $dependencyToLoad = null; | ||
| $loadedDependency = null; |
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.
A boolean can be enough ?
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.
Yes! Updated.
src/Dependencies.php
Outdated
| requireFile($dependencyToLoad); | ||
| if ($required && empty($loadedDependency)) { | ||
| throw new \RuntimeException(sprintf( | ||
| 'Files not found: "%s"', |
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.
for consistency with other exception use single quote around each name.
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.
Updated.
- Boolean to test if "first found" dependency loaded instead of full dependency string - Replace double-quotes with single-quotes in "First found" dependency thrown exception - Throw exception when single (not "first found") dependency is required and not loaded
|
Updated On Wed, Oct 26, 2016 at 1:51 AM, Remi Collet notifications@github.com
|
No description provided.