Skip to content

Commit

Permalink
[FixturesBundle] Introduce scalar types
Browse files Browse the repository at this point in the history
  • Loading branch information
pamil committed Aug 25, 2017
1 parent a912c72 commit 9e7ef52
Show file tree
Hide file tree
Showing 60 changed files with 208 additions and 268 deletions.
12 changes: 6 additions & 6 deletions src/Sylius/Bundle/FixturesBundle/Command/FixturesListCommand.php
Expand Up @@ -27,7 +27,7 @@ final class FixturesListCommand extends ContainerAwareCommand
/**
* {@inheritdoc}
*/
protected function configure()
protected function configure(): void
{
$this
->setName('sylius:fixtures:list')
Expand All @@ -38,7 +38,7 @@ protected function configure()
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): void
{
$this->listSuites($output);
$this->listFixtures($output);
Expand All @@ -47,7 +47,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
/**
* @param OutputInterface $output
*/
private function listSuites(OutputInterface $output)
private function listSuites(OutputInterface $output): void
{
$suites = $this->getSuiteRegistry()->getSuites();

Expand All @@ -61,7 +61,7 @@ private function listSuites(OutputInterface $output)
/**
* @param OutputInterface $output
*/
private function listFixtures(OutputInterface $output)
private function listFixtures(OutputInterface $output): void
{
$fixtures = $this->getFixtureRegistry()->getFixtures();

Expand All @@ -75,15 +75,15 @@ private function listFixtures(OutputInterface $output)
/**
* @return SuiteRegistryInterface
*/
private function getSuiteRegistry()
private function getSuiteRegistry(): SuiteRegistryInterface
{
return $this->getContainer()->get('sylius_fixtures.suite_registry');
}

/**
* @return FixtureRegistryInterface
*/
private function getFixtureRegistry()
private function getFixtureRegistry(): FixtureRegistryInterface
{
return $this->getContainer()->get('sylius_fixtures.fixture_registry');
}
Expand Down
10 changes: 5 additions & 5 deletions src/Sylius/Bundle/FixturesBundle/Command/FixturesLoadCommand.php
Expand Up @@ -32,7 +32,7 @@ final class FixturesLoadCommand extends ContainerAwareCommand
/**
* {@inheritdoc}
*/
protected function configure()
protected function configure(): void
{
$this
->setName('sylius:fixtures:load')
Expand All @@ -44,7 +44,7 @@ protected function configure()
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): void
{
if ($input->isInteractive()) {
/** @var QuestionHelper $questionHelper */
Expand All @@ -66,7 +66,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
/**
* @param InputInterface $input
*/
private function loadSuites(InputInterface $input)
private function loadSuites(InputInterface $input): void
{
$suiteName = $input->getArgument('suite');
$suite = $this->getSuiteRegistry()->getSuite($suiteName);
Expand All @@ -77,15 +77,15 @@ private function loadSuites(InputInterface $input)
/**
* @return SuiteRegistryInterface
*/
private function getSuiteRegistry()
private function getSuiteRegistry(): SuiteRegistryInterface
{
return $this->getContainer()->get('sylius_fixtures.suite_registry');
}

/**
* @return SuiteLoaderInterface
*/
private function getSuiteLoader()
private function getSuiteLoader(): SuiteLoaderInterface
{
return $this->getContainer()->get('sylius_fixtures.suite_loader');
}
Expand Down
Expand Up @@ -26,7 +26,7 @@ final class FixtureRegistryPass implements CompilerPassInterface
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if (!$container->has('sylius_fixtures.fixture_registry')) {
return;
Expand Down
Expand Up @@ -26,7 +26,7 @@ final class ListenerRegistryPass implements CompilerPassInterface
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if (!$container->has('sylius_fixtures.listener_registry')) {
return;
Expand Down
Expand Up @@ -25,7 +25,7 @@ final class Configuration implements ConfigurationInterface
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('sylius_fixtures');
Expand All @@ -38,7 +38,7 @@ public function getConfigTreeBuilder()
/**
* @param ArrayNodeDefinition $rootNode
*/
private function buildSuitesNode(ArrayNodeDefinition $rootNode)
private function buildSuitesNode(ArrayNodeDefinition $rootNode): void
{
/** @var ArrayNodeDefinition $suitesNode */
$suitesNode = $rootNode
Expand Down Expand Up @@ -73,7 +73,7 @@ private function buildSuitesNode(ArrayNodeDefinition $rootNode)
/**
* @param ArrayNodeDefinition $suitesNode
*/
private function buildFixturesNode(ArrayNodeDefinition $suitesNode)
private function buildFixturesNode(ArrayNodeDefinition $suitesNode): void
{
/** @var ArrayNodeDefinition $fixturesNode */
$fixturesNode = $suitesNode
Expand All @@ -91,7 +91,7 @@ private function buildFixturesNode(ArrayNodeDefinition $suitesNode)
/**
* @param ArrayNodeDefinition $suitesNode
*/
private function buildListenersNode(ArrayNodeDefinition $suitesNode)
private function buildListenersNode(ArrayNodeDefinition $suitesNode): void
{
/** @var ArrayNodeDefinition $listenersNode */
$listenersNode = $suitesNode
Expand All @@ -107,7 +107,7 @@ private function buildListenersNode(ArrayNodeDefinition $suitesNode)
/**
* @param ArrayNodeDefinition $node
*/
private function buildAttributesNode(ArrayNodeDefinition $node)
private function buildAttributesNode(ArrayNodeDefinition $node): void
{
$attributesNodeBuilder = $node->canBeUnset()->children();
$attributesNodeBuilder->integerNode('priority')->defaultValue(0);
Expand Down
Expand Up @@ -27,7 +27,7 @@ final class SyliusFixturesExtension extends Extension implements PrependExtensio
/**
* {@inheritdoc}
*/
public function load(array $config, ContainerBuilder $container)
public function load(array $config, ContainerBuilder $container): void
{
$config = $this->processConfiguration($this->getConfiguration([], $container), $config);
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
Expand All @@ -40,7 +40,7 @@ public function load(array $config, ContainerBuilder $container)
/**
* {@inheritdoc}
*/
public function prepend(ContainerBuilder $container)
public function prepend(ContainerBuilder $container): void
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));

Expand All @@ -63,7 +63,7 @@ public function prepend(ContainerBuilder $container)
* @param array $config
* @param ContainerBuilder $container
*/
private function registerSuites(array $config, ContainerBuilder $container)
private function registerSuites(array $config, ContainerBuilder $container): void
{
$suiteRegistry = $container->findDefinition('sylius_fixtures.suite_registry');
foreach ($config['suites'] as $suiteName => $suiteConfiguration) {
Expand Down
4 changes: 2 additions & 2 deletions src/Sylius/Bundle/FixturesBundle/Fixture/AbstractFixture.php
Expand Up @@ -24,7 +24,7 @@ abstract class AbstractFixture implements FixtureInterface
/**
* {@inheritdoc}
*/
final public function getConfigTreeBuilder()
final public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder();
$optionsNode = $treeBuilder->root($this->getName());
Expand All @@ -37,7 +37,7 @@ final public function getConfigTreeBuilder()
/**
* @param ArrayNodeDefinition $optionsNode
*/
protected function configureOptionsNode(ArrayNodeDefinition $optionsNode)
protected function configureOptionsNode(ArrayNodeDefinition $optionsNode): void
{
// empty
}
Expand Down
4 changes: 2 additions & 2 deletions src/Sylius/Bundle/FixturesBundle/Fixture/FixtureInterface.php
Expand Up @@ -23,10 +23,10 @@ interface FixtureInterface extends ConfigurationInterface
/**
* @param array $options
*/
public function load(array $options);
public function load(array $options): void;

/**
* @return string
*/
public function getName();
public function getName(): string;
}
Expand Up @@ -22,7 +22,7 @@ final class FixtureNotFoundException extends \InvalidArgumentException
* @param string $name
* @param \Exception|null $previous
*/
public function __construct($name, \Exception $previous = null)
public function __construct(string $name, ?\Exception $previous = null)
{
parent::__construct(sprintf('Fixture with name "%s" could not be found!', $name), 0, $previous);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Sylius/Bundle/FixturesBundle/Fixture/FixtureRegistry.php
Expand Up @@ -28,7 +28,7 @@ final class FixtureRegistry implements FixtureRegistryInterface
/**
* @param FixtureInterface $fixture
*/
public function addFixture(FixtureInterface $fixture)
public function addFixture(FixtureInterface $fixture): void
{
Assert::keyNotExists($this->fixtures, $fixture->getName(), 'Fixture with name "%s" is already registered.');

Expand All @@ -38,7 +38,7 @@ public function addFixture(FixtureInterface $fixture)
/**
* {@inheritdoc}
*/
public function getFixture($name)
public function getFixture(string $name): FixtureInterface
{
if (!isset($this->fixtures[$name])) {
throw new FixtureNotFoundException($name);
Expand All @@ -50,7 +50,7 @@ public function getFixture($name)
/**
* {@inheritdoc}
*/
public function getFixtures()
public function getFixtures(): array
{
return $this->fixtures;
}
Expand Down
Expand Up @@ -25,10 +25,10 @@ interface FixtureRegistryInterface
*
* @throws FixtureNotFoundException
*/
public function getFixture($name);
public function getFixture(string $name): FixtureInterface;

/**
* @return FixtureInterface[] Name indexed
* @return array|FixtureInterface[] Name indexed
*/
public function getFixtures();
public function getFixtures(): array;
}
Expand Up @@ -24,7 +24,7 @@ abstract class AbstractListener implements ListenerInterface
/**
* {@inheritdoc}
*/
final public function getConfigTreeBuilder()
final public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder();
$optionsNode = $treeBuilder->root($this->getName());
Expand All @@ -37,7 +37,7 @@ final public function getConfigTreeBuilder()
/**
* @param ArrayNodeDefinition $optionsNode
*/
protected function configureOptionsNode(ArrayNodeDefinition $optionsNode)
protected function configureOptionsNode(ArrayNodeDefinition $optionsNode): void
{
// empty
}
Expand Down
Expand Up @@ -22,5 +22,5 @@ interface AfterFixtureListenerInterface extends ListenerInterface
* @param FixtureEvent $fixtureEvent
* @param array $options
*/
public function afterFixture(FixtureEvent $fixtureEvent, array $options);
public function afterFixture(FixtureEvent $fixtureEvent, array $options): void;
}
Expand Up @@ -22,5 +22,5 @@ interface AfterSuiteListenerInterface extends ListenerInterface
* @param SuiteEvent $suiteEvent
* @param array $options
*/
public function afterSuite(SuiteEvent $suiteEvent, array $options);
public function afterSuite(SuiteEvent $suiteEvent, array $options): void;
}
Expand Up @@ -22,5 +22,5 @@ interface BeforeFixtureListenerInterface extends ListenerInterface
* @param FixtureEvent $fixtureEvent
* @param array $options
*/
public function beforeFixture(FixtureEvent $fixtureEvent, array $options);
public function beforeFixture(FixtureEvent $fixtureEvent, array $options): void;
}
Expand Up @@ -22,5 +22,5 @@ interface BeforeSuiteListenerInterface extends ListenerInterface
* @param SuiteEvent $suiteEvent
* @param array $options
*/
public function beforeSuite(SuiteEvent $suiteEvent, array $options);
public function beforeSuite(SuiteEvent $suiteEvent, array $options): void;
}
6 changes: 3 additions & 3 deletions src/Sylius/Bundle/FixturesBundle/Listener/FixtureEvent.php
Expand Up @@ -51,23 +51,23 @@ public function __construct(SuiteInterface $suite, FixtureInterface $fixture, ar
/**
* @return SuiteInterface
*/
public function suite()
public function suite(): SuiteInterface
{
return $this->suite;
}

/**
* @return FixtureInterface
*/
public function fixture()
public function fixture(): FixtureInterface
{
return $this->fixture;
}

/**
* @return array
*/
public function fixtureOptions()
public function fixtureOptions(): array
{
return $this->fixtureOptions;
}
Expand Down
Expand Up @@ -23,5 +23,5 @@ interface ListenerInterface extends ConfigurationInterface
/**
* @return string
*/
public function getName();
public function getName(): string;
}
Expand Up @@ -22,7 +22,7 @@ final class ListenerNotFoundException extends \InvalidArgumentException
* @param string $name
* @param \Exception|null $previous
*/
public function __construct($name, \Exception $previous = null)
public function __construct(string $name, ?\Exception $previous = null)
{
parent::__construct(sprintf('Listener with name "%s" could not be found!', $name), 0, $previous);
}
Expand Down
Expand Up @@ -28,7 +28,7 @@ final class ListenerRegistry implements ListenerRegistryInterface
/**
* @param ListenerInterface $listener
*/
public function addListener(ListenerInterface $listener)
public function addListener(ListenerInterface $listener): void
{
Assert::keyNotExists($this->listeners, $listener->getName(), 'Listener with name "%s" is already registered.');

Expand All @@ -38,7 +38,7 @@ public function addListener(ListenerInterface $listener)
/**
* {@inheritdoc}
*/
public function getListener($name)
public function getListener(string $name): ListenerInterface
{
if (!isset($this->listeners[$name])) {
throw new ListenerNotFoundException($name);
Expand All @@ -50,7 +50,7 @@ public function getListener($name)
/**
* {@inheritdoc}
*/
public function getListeners()
public function getListeners(): array
{
return $this->listeners;
}
Expand Down
Expand Up @@ -25,10 +25,10 @@ interface ListenerRegistryInterface
*
* @throws ListenerNotFoundException
*/
public function getListener($name);
public function getListener(string $name): ListenerInterface;

/**
* @return ListenerInterface[] Name indexed
* @return array|ListenerInterface[] Name indexed
*/
public function getListeners();
public function getListeners(): array;
}

0 comments on commit 9e7ef52

Please sign in to comment.