Skip to content

Commit

Permalink
Merge pull request #1881 from dpfaffenbauer/issues/psalm
Browse files Browse the repository at this point in the history
[Psalm] fix tests
  • Loading branch information
dpfaffenbauer authored Mar 2, 2022
2 parents 088dd8f + 7392105 commit feeb80b
Show file tree
Hide file tree
Showing 25 changed files with 123 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public function process(ContainerBuilder $container): void
if ($container->hasParameter($stackId)) {
$registry = $container->getDefinition('coreshop.registry.index.extensions');

/**
* @var array $stack
*/
$stack = $container->getParameter($stackId);

foreach ($stack as $class) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class RegisterFrontendControllerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
/**
* @var array $controllers
*/
$controllers = $container->getParameter('coreshop.frontend.controllers');

foreach ($controllers as $key => $value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ public function getConfigAction(): Response
];
}

/**
* @var array $fieldTypes
*/
$fieldTypes = $this->container->getParameter('coreshop.index.mapping_types');
$fieldTypesResult = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ public function getConfigAction(Request $request): Response
$actions = [];
$types = [];

/**
* @var array $actionTypes
*/
$actionTypes = $this->container->getParameter('coreshop.notification_rule.actions.types');

/**
* @var array $conditionTypes
*/
$conditionTypes = $this->container->getParameter('coreshop.notification_rule.conditions.types');

foreach ($actionTypes as $type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ class OrderController extends PimcoreController

public function getStatesAction(Request $request): Response
{
/**
* @var array $identifiers
*/
$identifiers = $this->container->getParameter('coreshop.state_machines');
$states = [];
$transitions = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,21 @@ public function getDataForEditmode($data, $object = null, $params = [])
$calculationBehaviourTypes = [];
$pricingBehaviourTypes = [];

foreach ($this->getContainer()->getParameter('coreshop.product_quantity_price_rules.calculators') as $type) {
/**
* @var array $calculators
*/
$calculators = $this->getContainer()->getParameter('coreshop.product_quantity_price_rules.calculators');

/**
* @var array $actions
*/
$actions = $this->getContainer()->getParameter('coreshop.product_quantity_price_rules.actions');

foreach ($calculators as $type) {
$calculationBehaviourTypes[] = [$type, 'coreshop_product_quantity_price_rules_calculator_' . strtolower($type)];
}
foreach ($this->getContainer()->getParameter('coreshop.product_quantity_price_rules.actions') as $type) {

foreach ($actions as $type) {
$pricingBehaviourTypes[] = [$type, 'coreshop_product_quantity_price_rules_behaviour_' . strtolower($type)];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public function getConfigAction(): Response
];

if ($this->container->hasParameter('coreshop.all.pimcore_classes')) {
/**
* @var array $classes
*/
$classes = $this->container->getParameter('coreshop.all.pimcore_classes');

foreach ($classes as $key => $definition) {
Expand All @@ -58,6 +61,9 @@ public function getConfigAction(): Response
$config['classMap'][$application][$alias] = $class;
}

/**
* @var array $stack
*/
$stack = $this->container->getParameter('coreshop.all.stack.pimcore_class_names');

foreach ($stack as $key => $impl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ protected function getCoreShopPimcoreClasses()

public function getParameterTypeDeclaration(): ?string
{
return '?\\' . \Pimcore::getContainer()->getParameter('coreshop.all.stack')[$this->stack];
/**
* @var array $stack
*/
$stack = \Pimcore::getContainer()->getParameter('coreshop.all.stack');

return '?\\' . $stack[$this->stack];
}

public function getReturnTypeDeclaration(): ?string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,22 @@ public function getReturnTypeDeclaration(): ?string

public function getPhpdocInputType(): ?string
{
return '?\\' . \Pimcore::getContainer()->getParameter('coreshop.all.stack')[$this->stack] . '[]';
/**
* @var array $stack
*/
$stack = \Pimcore::getContainer()->getParameter('coreshop.all.stack');

return '?\\' . $stack[$this->stack] . '[]';
}

public function getPhpdocReturnType(): ?string
{
return '?\\' . \Pimcore::getContainer()->getParameter('coreshop.all.stack')[$this->stack] . '[]';
/**
* @var array $stack
*/
$stack = \Pimcore::getContainer()->getParameter('coreshop.all.stack');

return '?\\' . $stack[$this->stack] . '[]';
}

public function getClasses()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ final class RegisterPimcoreResourcesPass implements CompilerPassInterface
public function process(ContainerBuilder $container): void
{
try {
/**
* @var array $resources
*/
$resources = $container->getParameter('coreshop.all.pimcore_classes');
$registry = $container->findDefinition(RegistryInterface::class);
} catch (InvalidArgumentException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ final class RegisterResourcesPass implements CompilerPassInterface
public function process(ContainerBuilder $container): void
{
try {
/**
* @var array $resources
*/
$resources = $container->getParameter('coreshop.resources');
$registry = $container->findDefinition(RegistryInterface::class);
} catch (InvalidArgumentException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ public function process(ContainerBuilder $container): void
return;
}

/**
* @var array $classes
*/
$classes = $container->getParameter('coreshop.all.pimcore_classes');

/**
* @var array $stack
*/
$stack = $container->getParameter('coreshop.all.stack');

$classStack = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,17 @@ public function process(ContainerBuilder $container): void
return;
}

/**
* @var array $stackConfig
*/
$stackConfig = $container->getParameter('coreshop.all.stack');

foreach ($container->getParameter('coreshop.all.stack.fqcns') as $alias => $classes) {
/**
* @var array $fqcns
*/
$fqcns = $container->getParameter('coreshop.all.stack.fqcns');

foreach ($fqcns as $alias => $classes) {
[$applicationName, $name] = explode('.', $alias);

$definition = new Definition(Metadata::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ private function loadPersistence(array $drivers, array $resources, LoaderInterfa

private function loadResources(array $loadedResources, ContainerBuilder $container): void
{
/**
* @var array $resources
*/
$resources = $container->hasParameter('coreshop.resources') ? $container->getParameter('coreshop.resources') : [];

foreach ($loadedResources as $alias => $resourceConfig) {
Expand Down Expand Up @@ -149,6 +152,9 @@ protected function loadPimcoreModels(array $models, ContainerBuilder $container)
$metadata = Metadata::fromAliasAndConfiguration($alias, $resourceConfig);

foreach (['coreshop.all.pimcore_classes', sprintf('%s.pimcore_classes', $metadata->getApplicationName())] as $parameter) {
/**
* @var array $resources
*/
$resources = $container->hasParameter($parameter) ? $container->getParameter($parameter) : [];
$resources[$alias] = $resourceConfig;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ protected function addPimcoreClass(ContainerBuilder $container, MetadataInterfac
$allPaths = [];

if ($container->hasParameter($parameterName)) {
/**
* @var array $allPaths
*/
$allPaths = $container->getParameter($parameterName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ public function registerStack(string $applicationName, array $stack, ContainerBu
$globalParameterName = 'coreshop.all.stack';

foreach ([$appParameterName, $globalParameterName] as $parameterName) {
/**
* @var array $stackConfig
*/
$stackConfig = $container->hasParameter($parameterName) ? $container->getParameter($parameterName) : [];

foreach ($stack as $key => $interface) {
Expand Down Expand Up @@ -156,6 +159,9 @@ protected function registerPimcoreResources($applicationName, $bundleResources,
}

if ($container->hasParameter($globalParameter)) {
/**
* @var array $globalPermissions
*/
$globalPermissions = $container->getParameter($globalParameter);
}

Expand Down Expand Up @@ -187,6 +193,9 @@ public function registerDependantBundles($applicationName, $bundles, ContainerBu
$globalParameterName = 'coreshop.all.dependant.bundles';

foreach ([$appParameterName, $globalParameterName] as $parameterName) {
/**
* @var array $bundleConfig
*/
$bundleConfig = $container->hasParameter($parameterName) ? $container->getParameter($parameterName) : [];

foreach ($bundles as $bundleName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public function installResources(OutputInterface $output, string $applicationNam
$parameter = $applicationName ? sprintf('%s.pimcore_classes', $applicationName) : 'coreshop.all.pimcore_classes';

if ($this->kernel->getContainer()->hasParameter($parameter)) {
/**
* @var array $pimcoreClasses
*/
$pimcoreClasses = $this->kernel->getContainer()->getParameter($parameter);
$fieldCollections = [];
$bricks = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public function installResources(OutputInterface $output, string $applicationNam
;

if ($this->kernel->getContainer()->hasParameter($parameter)) {
/**
* @var array $bundlesToInstall
*/
$bundlesToInstall = $this->kernel->getContainer()->getParameter($parameter);

$progress = new ProgressBar($output);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public function installResources(OutputInterface $output, string $applicationNam
) : 'coreshop.all.pimcore.admin.install.documents';

if ($this->kernel->getContainer()->hasParameter($parameter)) {
/**
* @var array $documentFilesToInstall
*/
$documentFilesToInstall = $this->kernel->getContainer()->getParameter($parameter);
$docsToInstall = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public function installResources(OutputInterface $output, string $applicationNam
$parameter = $applicationName ? sprintf('%s.pimcore.admin.install.grid_config', $applicationName) : 'coreshop.all.pimcore.admin.install.grid_config';

if ($this->kernel->getContainer()->hasParameter($parameter)) {
/**
* @var array $routeFilesToInstall
*/
$routeFilesToInstall = $this->kernel->getContainer()->getParameter($parameter);
$gridConfigsToInstall = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public function installResources(OutputInterface $output, string $applicationNam
$parameter = $applicationName ? sprintf('%s.pimcore.admin.install.image_thumbnails', $applicationName) : 'coreshop.all.pimcore.admin.install.image_thumbnails';

if ($this->kernel->getContainer()->hasParameter($parameter)) {
/**
* @var array $thumbnailFilesToInstall
*/
$thumbnailFilesToInstall = $this->kernel->getContainer()->getParameter($parameter);
$thumbnailsToInstall = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public function installResources(OutputInterface $output, string $applicationNam
$parameter = $applicationName ? sprintf('%s.permissions', $applicationName) : 'coreshop.all.permissions';

if ($this->kernel->getContainer()->hasParameter($parameter)) {
/**
* @var array $permissionGroups
*/
$permissionGroups = $this->kernel->getContainer()->getParameter($parameter);

if ($parameter !== 'coreshop.all.permissions') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public function installResources(OutputInterface $output, string $applicationNam
$parameter = $applicationName ? sprintf('%s.pimcore.admin.install.routes', $applicationName) : 'coreshop.all.pimcore.admin.install.routes';

if ($this->kernel->getContainer()->hasParameter($parameter)) {
/**
* @var array $routeFilesToInstall
*/
$routeFilesToInstall = $this->kernel->getContainer()->getParameter($parameter);
$routesToInstall = [];

Expand Down
3 changes: 3 additions & 0 deletions src/CoreShop/Bundle/ResourceBundle/Installer/SqlInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public function installResources(OutputInterface $output, string $applicationNam
$parameter = $applicationName ? sprintf('%s.pimcore.admin.install.sql', $applicationName) : 'coreshop.all.pimcore.admin.install.sql';

if ($this->kernel->getContainer()->hasParameter($parameter)) {
/**
* @var array $sqlFilesToExecute
*/
$sqlFilesToExecute = $this->kernel->getContainer()->getParameter($parameter);

$progress = new ProgressBar($output);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class CarrierController extends ResourceController
{
public function getConfigAction(): JsonResponse
{
/**
* @var array $strategies
*/
$strategies = $this->container->getParameter('coreshop.shipping.tax_calculation_strategies');

$convertedStrategies = [];
Expand Down

0 comments on commit feeb80b

Please sign in to comment.