Skip to content

Conversation

@siwinski
Copy link
Member

No description provided.

requireFile($firstExistsDependency);
$loadedDependency = $firstExistsDependency;
break;
} catch (\RuntimeException $e) {
Copy link
Member Author

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?

Copy link
Collaborator

@remicollet remicollet left a 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

foreach ($dependencies as $dependency) {
if (is_array($dependency)) {
$dependencyToLoad = null;
$loadedDependency = null;
Copy link
Collaborator

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 ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! Updated.

requireFile($dependencyToLoad);
if ($required && empty($loadedDependency)) {
throw new \RuntimeException(sprintf(
'Files not found: "%s"',
Copy link
Collaborator

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.

Copy link
Member Author

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
@siwinski siwinski merged commit 5bf508f into master Oct 26, 2016
@siwinski
Copy link
Member Author

Updated

On Wed, Oct 26, 2016 at 1:51 AM, Remi Collet notifications@github.com
wrote:

@remicollet approved this pull request.

no problem for me, feel free to merge for 0.2.0 is you want

In src/Dependencies.php
#9 (review)
:

  */
 protected static function process(array $dependencies, $required)
 {
     foreach ($dependencies as $dependency) {
         if (is_array($dependency)) {
  •            $dependencyToLoad = null;
    
  •            $loadedDependency = null;
    

A boolean can be enough ?

In src/Dependencies.php
#9 (review)
:

                 }
             }
  •            if ($required || isset($dependencyToLoad)) {
    
  •                if (!isset($dependencyToLoad)) {
    
  •                    $dependencyToLoad = end($dependency);
    

- }

  •                requireFile($dependencyToLoad);
    
  •            if ($required && empty($loadedDependency)) {
    
  •                throw new \RuntimeException(sprintf(
    
  •                  'Files not found: "%s"',
    

for consistency with other exception use single quote around each name.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#9 (review),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA_HKNcLny1ROFKeCOUtLT0Nt7x8HsSQks5q3up1gaJpZM4Kgtjd
.

@siwinski siwinski deleted the refactor-dependencies-process-with-exceptions branch October 27, 2016 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants