Skip to content
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

[Maintenance] Allow flex plugin during plugin installation #460

Merged
merged 4 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CONFLICTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# CONFLICTS

This document explains why certain conflicts were added to `composer.json` and
references related issues.

- `"phpstan/phpdoc-parser": "^1.6.0"`:

Usage of ^1.6 versions leads to following error: https://issuehint.com/issue/slevomat/coding-standard/1379. To remove it, Sylius-Labs/ECS
requires bump of Slevomat lib - "slevomat/coding-standard"
18 changes: 14 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
"replace": {
"sylius/resource": "self.version"
},
"conflict": {
"phpstan/phpdoc-parser": "^1.6.0"
},
"require-dev": {
"doctrine/orm": "^2.5",
"lchrusciel/api-test-case": "^5.0",
Expand All @@ -62,9 +65,10 @@
"pamil/phpspec-skip-example-extension": "^4.2",
"phpspec/phpspec": "^7.2",
"phpspec/prophecy-phpunit": "^2.0",
"phpstan/phpstan": "0.12.99",
"phpstan/phpstan-phpunit": "0.12.22",
"phpstan/phpstan-webmozart-assert": "0.12.16",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-doctrine": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-webmozart-assert": "^1.0",
"phpunit/phpunit": "^9.5",
"sylius-labs/coding-standard": "^4.0",
"sylius/grid-bundle": "^1.7",
Expand All @@ -74,12 +78,18 @@
"symplify/easy-coding-standard": "^9.4",
"twig/twig": "^2.12 || ^3.0",
"vimeo/psalm": "4.7.0",
"rector/rector": "^0.11.47"
"rector/rector": "^0.12.20"
},
"suggest": {
"doctrine/orm": "^2.5",
"sylius/locale": "^1.0"
},
"config": {
"allow-plugins": {
"symfony/flex": true,
"dealerdirect/phpcodesniffer-composer-installer": false
}
},
"extra": {
"branch-alias": {
"dev-master": "1.9-dev"
Expand Down
10 changes: 10 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,13 @@ parameters:
- '/Return typehint of method Sylius\\Bundle\\ResourceBundle\\Routing\\RoutesAttributesLoader::getClassAttributes\(\) has invalid type ReflectionAttribute./'
- '/Unable to resolve the template type ExpectedType in call to method static method Webmozart\\Assert\\Assert::isInstanceOf\(\)/'
- '/is deprecated since Sylius 1\.8/'
- '/Method Sylius\\Bundle\\ResourceBundle\\Event\\ResourceControllerEvent::stop\(\) has no return type specified./'
- '/Method Sylius\\Bundle\\ResourceBundle\\Form\\Extension\\HttpFoundation\\HttpFoundationRequestHandler::handleRequest\(\) has no return type specified./'
- '/Method Sylius\\Bundle\\ResourceBundle\\Grid\\Controller\\ResourcesResolver::getResources\(\) has no return type specified./'
- '/Method Sylius\\Component\\Resource\\Model\\ResourceInterface::getId\(\) has no return type specified./'
- '/Method Sylius\\Component\\Resource\\Model\\TimestampableInterface::set(Created|Updated)At\(\) has no return type specified./'
- '/Parameter #1 \$objectOrArray of method Symfony\\Component\\PropertyAccess\\PropertyAccessor::getValue\(\) expects array\|object, mixed given\./'
- '/Parameter #1 \$objectOrArray of method Symfony\\Component\\PropertyAccess\\PropertyAccessorInterface::getValue\(\) expects array\|object, mixed given\./'
- '/Parameter #4 \.\.\.\$values of function sprintf expects bool\|float\|int\|string\|null, mixed given\./'
- '/Parameter #1 \$submittedData of method Symfony\\Component\\Form\\FormInterface::submit\(\) expects array\|string\|null, mixed given\./'
- '/Parameter #2 \$callback of function preg_replace_callback expects callable\(array<int\|string, string>\): string, Closure\(array\): mixed given\./'
12 changes: 6 additions & 6 deletions src/Bundle/AbstractResourceBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function build(ContainerBuilder $container): void
if (class_exists($compilerPassClassName)) {
if (!method_exists($compilerPassClassName, $compilerPassMethod)) {
throw new InvalidConfigurationException(
"The 'mappingFormat' value is invalid, must be 'xml', 'yaml' or 'annotation'."
"The 'mappingFormat' value is invalid, must be 'xml', 'yaml' or 'annotation'.",
);
}

Expand All @@ -48,7 +48,7 @@ public function build(ContainerBuilder $container): void
$container->addCompilerPass($compilerPassClassName::$compilerPassMethod(
[$this->getConfigFilesPath() => $this->getModelNamespace()],
[$this->getObjectManagerParameter()],
sprintf('%s.driver.%s', $this->getBundlePrefix(), $driver)
sprintf('%s.driver.%s', $this->getBundlePrefix(), $driver),
));

break;
Expand All @@ -57,7 +57,7 @@ public function build(ContainerBuilder $container): void
[$this->getModelNamespace()],
[$this->getConfigFilesPath()],
[sprintf('%s.object_manager', $this->getBundlePrefix())],
sprintf('%s.driver.%s', $this->getBundlePrefix(), $driver)
sprintf('%s.driver.%s', $this->getBundlePrefix(), $driver),
));

break;
Expand Down Expand Up @@ -106,7 +106,7 @@ protected function getMappingCompilerPassInfo(string $driverType): array
case SyliusResourceBundle::DRIVER_DOCTRINE_MONGODB_ODM:
@trigger_error(sprintf(
'The "%s" driver is deprecated in Sylius 1.3. Doctrine MongoDB and PHPCR will no longer be supported in Sylius 2.0.',
$driverType
$driverType,
), \E_USER_DEPRECATED);

$mappingsPassClassname = DoctrineMongoDBMappingsPass::class;
Expand All @@ -119,7 +119,7 @@ protected function getMappingCompilerPassInfo(string $driverType): array
case SyliusResourceBundle::DRIVER_DOCTRINE_PHPCR_ODM:
@trigger_error(sprintf(
'The "%s" driver is deprecated in Sylius 1.3. Doctrine MongoDB and PHPCR will no longer be supported in Sylius 2.0.',
$driverType
$driverType,
), \E_USER_DEPRECATED);

$mappingsPassClassname = DoctrinePhpcrMappingsPass::class;
Expand All @@ -142,7 +142,7 @@ protected function getConfigFilesPath(): string
return sprintf(
'%s/Resources/config/doctrine/%s',
$this->getPath(),
strtolower($this->getDoctrineMappingDirectory())
strtolower($this->getDoctrineMappingDirectory()),
);
}

Expand Down
12 changes: 6 additions & 6 deletions src/Bundle/Controller/EventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(SymfonyEventDispatcherInterface $eventDispatcher)
public function dispatch(
string $eventName,
RequestConfiguration $requestConfiguration,
ResourceInterface $resource
ResourceInterface $resource,
): ResourceControllerEvent {
$eventName = $requestConfiguration->getEvent() ?: $eventName;
$metadata = $requestConfiguration->getMetadata();
Expand All @@ -43,7 +43,7 @@ public function dispatch(
public function dispatchMultiple(
string $eventName,
RequestConfiguration $requestConfiguration,
$resources
$resources,
): ResourceControllerEvent {
$eventName = $requestConfiguration->getEvent() ?: $eventName;
$metadata = $requestConfiguration->getMetadata();
Expand All @@ -57,7 +57,7 @@ public function dispatchMultiple(
public function dispatchPreEvent(
string $eventName,
RequestConfiguration $requestConfiguration,
ResourceInterface $resource
ResourceInterface $resource,
): ResourceControllerEvent {
$eventName = $requestConfiguration->getEvent() ?: $eventName;
$metadata = $requestConfiguration->getMetadata();
Expand All @@ -71,7 +71,7 @@ public function dispatchPreEvent(
public function dispatchPostEvent(
string $eventName,
RequestConfiguration $requestConfiguration,
ResourceInterface $resource
ResourceInterface $resource,
): ResourceControllerEvent {
$eventName = $requestConfiguration->getEvent() ?: $eventName;
$metadata = $requestConfiguration->getMetadata();
Expand All @@ -85,15 +85,15 @@ public function dispatchPostEvent(
public function dispatchInitializeEvent(
string $eventName,
RequestConfiguration $requestConfiguration,
ResourceInterface $resource
ResourceInterface $resource,
): ResourceControllerEvent {
$eventName = $requestConfiguration->getEvent() ?: $eventName;
$metadata = $requestConfiguration->getMetadata();
$event = new ResourceControllerEvent($resource);

$this->eventDispatcher->dispatch(
$event,
sprintf('%s.%s.initialize_%s', $metadata->getApplicationName(), $metadata->getName(), $eventName)
sprintf('%s.%s.initialize_%s', $metadata->getApplicationName(), $metadata->getName(), $eventName),
);

return $event;
Expand Down
10 changes: 5 additions & 5 deletions src/Bundle/Controller/EventDispatcherInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,31 @@ interface EventDispatcherInterface
public function dispatch(
string $eventName,
RequestConfiguration $requestConfiguration,
ResourceInterface $resource
ResourceInterface $resource,
): ResourceControllerEvent;

/** @param mixed $resources */
public function dispatchMultiple(
string $eventName,
RequestConfiguration $requestConfiguration,
$resources
$resources,
): ResourceControllerEvent;

public function dispatchPreEvent(
string $eventName,
RequestConfiguration $requestConfiguration,
ResourceInterface $resource
ResourceInterface $resource,
): ResourceControllerEvent;

public function dispatchPostEvent(
string $eventName,
RequestConfiguration $requestConfiguration,
ResourceInterface $resource
ResourceInterface $resource,
): ResourceControllerEvent;

public function dispatchInitializeEvent(
string $eventName,
RequestConfiguration $requestConfiguration,
ResourceInterface $resource
ResourceInterface $resource,
): ResourceControllerEvent;
}
4 changes: 2 additions & 2 deletions src/Bundle/Controller/FlashHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(SessionInterface $session, TranslatorInterface $tran
public function addSuccessFlash(
RequestConfiguration $requestConfiguration,
string $actionName,
?ResourceInterface $resource = null
?ResourceInterface $resource = null,
): void {
$this->addFlashWithType($requestConfiguration, $actionName, 'success');
}
Expand Down Expand Up @@ -79,7 +79,7 @@ private function addFlashWithType(RequestConfiguration $requestConfiguration, st
$this->addFlash(
$type,
$this->getResourceMessage($actionName),
$parameters
$parameters,
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Bundle/Controller/FlashHelperInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface FlashHelperInterface
public function addSuccessFlash(
RequestConfiguration $requestConfiguration,
string $actionName,
?ResourceInterface $resource = null
?ResourceInterface $resource = null,
): void;

public function addErrorFlash(RequestConfiguration $requestConfiguration, string $actionName): void;
Expand Down
6 changes: 3 additions & 3 deletions src/Bundle/Controller/ParametersParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function ($parameter) use ($request) {

return $this->parseRequestValue($parameter, $request);
},
$parameters
$parameters,
);
}

Expand Down Expand Up @@ -90,13 +90,13 @@ function (array $matches) use ($request) {
throw new \InvalidArgumentException(sprintf(
'Cannot use %s ($%s) as parameter in expression.',
gettype($variable),
$matches[1]
$matches[1],
));
}

return is_string($variable) ? sprintf('"%s"', addslashes($variable)) : $variable;
},
$expression
$expression,
);

return $this->expression->evaluate($expression, ['container' => $this->container]);
Expand Down
6 changes: 3 additions & 3 deletions src/Bundle/Controller/RedirectHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ public function redirectToResource(RequestConfiguration $configuration, Resource
return $this->redirectToRoute(
$configuration,
(string) $configuration->getRedirectRoute(ResourceActions::SHOW),
$configuration->getRedirectParameters($resource)
$configuration->getRedirectParameters($resource),
);
} catch (RouteNotFoundException $exception) {
return $this->redirectToRoute(
$configuration,
(string) $configuration->getRedirectRoute(ResourceActions::INDEX),
$configuration->getRedirectParameters($resource)
$configuration->getRedirectParameters($resource),
);
}
}
Expand All @@ -51,7 +51,7 @@ public function redirectToIndex(RequestConfiguration $configuration, ?ResourceIn
return $this->redirectToRoute(
$configuration,
(string) $configuration->getRedirectRoute('index'),
$configuration->getRedirectParameters($resource)
$configuration->getRedirectParameters($resource),
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Bundle/Controller/RequestConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ public function getRequestParameter($parameter, $defaults = [])
{
return array_replace_recursive(
$defaults,
$this->request->get($parameter, [])
$this->request->get($parameter, []),
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Bundle/Controller/RequestConfigurationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private function parseApiParameters(Request $request): array

$allowedSerializationGroups = array_merge(
$parameters['allowed_serialization_groups'] ?? [],
$parameters['serialization_groups'] ?? []
$parameters['serialization_groups'] ?? [],
);

/** @var string[] $apiGroupsHeaders */
Expand Down
10 changes: 5 additions & 5 deletions src/Bundle/Controller/ResourceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function __construct(
EventDispatcherInterface $eventDispatcher,
?StateMachineInterface $stateMachine,
ResourceUpdateHandlerInterface $resourceUpdateHandler,
ResourceDeleteHandlerInterface $resourceDeleteHandler
ResourceDeleteHandlerInterface $resourceDeleteHandler,
) {
$this->metadata = $metadata;
$this->requestConfigurationFactory = $requestConfigurationFactory;
Expand Down Expand Up @@ -244,9 +244,9 @@ public function updateAction(Request $request): Response
$form->handleRequest($request);

if (
in_array($request->getMethod(), ['POST', 'PUT', 'PATCH'], true)
&& $form->isSubmitted()
&& $form->isValid()
in_array($request->getMethod(), ['POST', 'PUT', 'PATCH'], true) &&
$form->isSubmitted() &&
$form->isValid()
) {
$resource = $form->getData();

Expand Down Expand Up @@ -516,7 +516,7 @@ protected function getParameter(string $name)
throw new \RuntimeException(sprintf(
'Container passed to "%s" has to implements "%s".',
self::class,
ContainerInterface::class
ContainerInterface::class,
));
}

Expand Down
2 changes: 1 addition & 1 deletion src/Bundle/Controller/ResourceUpdateHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct(?StateMachineInterface $stateMachine)
public function handle(
ResourceInterface $resource,
RequestConfiguration $requestConfiguration,
ObjectManager $manager
ObjectManager $manager,
): void {
if (null !== $this->stateMachine && $requestConfiguration->hasStateMachine()) {
$this->stateMachine->apply($requestConfiguration, $resource);
Expand Down
2 changes: 1 addition & 1 deletion src/Bundle/Controller/ResourceUpdateHandlerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ interface ResourceUpdateHandlerInterface
public function handle(
ResourceInterface $resource,
RequestConfiguration $requestConfiguration,
ObjectManager $manager
ObjectManager $manager,
): void;
}
2 changes: 1 addition & 1 deletion src/Bundle/Controller/ResourcesCollectionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function get(RequestConfiguration $requestConfiguration, RepositoryInterf
$paginator->setMaxPerPage($this->resolveMaxPerPage(
$request->query->has('limit') ? $request->query->getInt('limit') : null,
$requestConfiguration->getPaginationMaxPerPage(),
$paginationLimits
$paginationLimits,
));
$currentPage = (int) $request->query->get('page', '1');
$paginator->setCurrentPage($currentPage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ public function resolve(array $resources): array
'Triggered by resource "%s" with model "%s" and interface "%s".',
$alias,
$model,
$interface
$interface,
),
\E_USER_DEPRECATED
\E_USER_DEPRECATED,
);

$interfaces[$interface] = $model;
Expand Down
Loading