Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Conversation

SlayerBirden
Copy link
Contributor

Method getConfigFile is not defined in the InjectorInterface hence it's missing from some injectors.
Adjusted logic to apply different "get" logic based on different injector types with default fallback.

This fixes #39

Copy link
Member

@weierophinney weierophinney left a comment

Choose a reason for hiding this comment

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

A few comments:

  • Please add a @todo annotation to the InjectorInterface to add a getConfigFile() method in the next major version.
  • Add a @todo annotation to getInjectorConfigFileName() to remove it for the next major version in favor of the defined getConfigFile() method on the interface.
  • Please add unit tests so we can validate the fix.

Thanks!

} elseif ($injector instanceof AbstractInjector) {
// default flow
$fileName = $injector->getConfigFile();
}
Copy link
Member

Choose a reason for hiding this comment

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

Please split each of these cases into its own method, and return the results of calling that method.

As an example:

private function getInjectorConfigFileName(InjectorInterface $injector)
{
    if ($injector instanceof ConfigInjectorChain) {
        return $this->getConfigFileNameFromInjectorChain($injector);
    }
    // etc.
    return '';
}

private function getConfigFileNameFromInjectorChain(ConfigInjectorChain $injector)
{
    $names = [];
    foreach ($injector->getCollection() as $item) {
        $names[] = $this->getInjectorConfigFileName($item);
    }
    return implode(', ', $names);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@weierophinney done; removed the noop case as it's not actually possible to reach it with current ConfigDiscovery logic

refactor getConfigName calls - divide into smaller methods;
add testing for different injector types;
@SlayerBirden
Copy link
Contributor Author

okulik@okulik:~/Sites/projects/zend-component-installer$ ./vendor/bin/phpunit --filter testUninstallMessageWithDifferentInjectors
PHPUnit 6.4.3 by Sebastian Bergmann and contributors.

..                                                                  2 / 2 (100%)

Time: 203 ms, Memory: 8.00MB

OK (2 tests, 4 assertions)

@weierophinney ^ test results

@weierophinney weierophinney merged commit ad560c0 into zendframework:master Jan 11, 2018
weierophinney added a commit that referenced this pull request Jan 11, 2018
weierophinney added a commit that referenced this pull request Jan 11, 2018
weierophinney added a commit that referenced this pull request Jan 11, 2018
Forward port #47

Conflicts:
	CHANGELOG.md
@weierophinney
Copy link
Member

Thanks, @SlayerBirden

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fatal error while component removal
2 participants