diff --git a/Makefile b/Makefile index e49fc24b..65c567cc 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ COMPOSER=symfony composer CONSOLE=${SYMFONY} console export COMPOSE_PROJECT_NAME=rich-editor PLUGIN_NAME=sylius-${COMPOSE_PROJECT_NAME}-plugin -COMPOSE=docker-compose +COMPOSE=docker compose YARN=yarn ### diff --git a/phpstan.neon b/phpstan.neon index 3db8ce03..fd292f38 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,5 @@ parameters: - level: max + level: 8 paths: - %rootDir%/src/ diff --git a/src/Controller/FormController.php b/src/Controller/FormController.php index 4b7e8e48..54f91fbc 100644 --- a/src/Controller/FormController.php +++ b/src/Controller/FormController.php @@ -257,12 +257,12 @@ private function convertFormDataForRequest(array $formData, string $prefix = '') foreach ($formData as $key => $value) { if (\is_array($value)) { if (empty($prefix)) { - $items = array_merge($items, $this->convertFormDataForRequest($value, sprintf('%s', $key))); + $items = array_merge($items, $this->convertFormDataForRequest($value, \sprintf('%s', $key))); } else { - $items = array_merge($items, $this->convertFormDataForRequest($value, sprintf('%s[%s]', $prefix, $key))); + $items = array_merge($items, $this->convertFormDataForRequest($value, \sprintf('%s[%s]', $prefix, $key))); } } else { - $items[sprintf('%s[%s]', $prefix, $key)] = $value; + $items[\sprintf('%s[%s]', $prefix, $key)] = $value; } } diff --git a/src/DependencyInjection/UiElementRegistryPass.php b/src/DependencyInjection/UiElementRegistryPass.php index 90b628bf..4d3495ac 100644 --- a/src/DependencyInjection/UiElementRegistryPass.php +++ b/src/DependencyInjection/UiElementRegistryPass.php @@ -124,7 +124,7 @@ private function validateUiElementResource(string $class): void $interfaces = (array) class_implements($class); if (!\in_array(UiElementInterface::class, $interfaces, true)) { - throw new InvalidArgumentException(sprintf('Class "%s" must implement "%s" to be registered as a UiElement resource.', $class, UiElementInterface::class)); + throw new InvalidArgumentException(\sprintf('Class "%s" must implement "%s" to be registered as a UiElement resource.', $class, UiElementInterface::class)); } } diff --git a/src/Exception/UiElementNotFoundException.php b/src/Exception/UiElementNotFoundException.php index 485421ae..fb360421 100644 --- a/src/Exception/UiElementNotFoundException.php +++ b/src/Exception/UiElementNotFoundException.php @@ -22,6 +22,6 @@ final class UiElementNotFoundException extends Exception */ public function __construct(string $code, ?Exception $previous = null) { - parent::__construct(sprintf('UiElement with code "%s" could not be found!', $code), 0, $previous); + parent::__construct(\sprintf('UiElement with code "%s" could not be found!', $code), 0, $previous); } } diff --git a/src/Form/Type/UiElement/HtmlType.php b/src/Form/Type/UiElement/HtmlType.php index 43dec080..55bd005e 100644 --- a/src/Form/Type/UiElement/HtmlType.php +++ b/src/Form/Type/UiElement/HtmlType.php @@ -13,9 +13,8 @@ namespace MonsieurBiz\SyliusRichEditorPlugin\Form\Type\UiElement; -use MonsieurBiz\SyliusRichEditorPlugin\Form\Type\WysiwygType; -use MonsieurBiz\SyliusRichEditorPlugin\WysiwygEditor\EditorInterface; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\FormBuilderInterface; class HtmlType extends AbstractType @@ -26,9 +25,8 @@ class HtmlType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options): void { $builder - ->add('content', WysiwygType::class, [ + ->add('content', TextareaType::class, [ 'label' => 'monsieurbiz_richeditor_plugin.ui_element.monsieurbiz.html.field.content', - 'editor_toolbar_type' => EditorInterface::TOOLBAR_TYPE_FULL, ]) ; } diff --git a/src/Maker/UiElementMaker.php b/src/Maker/UiElementMaker.php index aa234665..30c4cffd 100644 --- a/src/Maker/UiElementMaker.php +++ b/src/Maker/UiElementMaker.php @@ -60,7 +60,7 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen $uiElementFormClassNameDetails->getFullName(), __DIR__ . '/../Resources/skeleton/UiElementFormType.tpl.php', [ - 'code' => sprintf('%s.%s', $codePrefix, $code), + 'code' => \sprintf('%s.%s', $codePrefix, $code), 'icon' => 'map pin', 'tags' => json_encode([]), ] @@ -68,14 +68,14 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen // Generate templates $generator->generateTemplate( - sprintf('Admin/UiElement/%s.html.twig', $code), + \sprintf('Admin/UiElement/%s.html.twig', $code), __DIR__ . '/../Resources/skeleton/UiElementTemplate.tpl.php', [ 'code' => $code, ] ); $generator->generateTemplate( - sprintf('Shop/UiElement/%s.html.twig', $code), + \sprintf('Shop/UiElement/%s.html.twig', $code), __DIR__ . '/../Resources/skeleton/UiElementTemplate.tpl.php', [ 'code' => $code, diff --git a/src/Twig/RichEditorExtension.php b/src/Twig/RichEditorExtension.php index 8b0dadb1..d8f45753 100644 --- a/src/Twig/RichEditorExtension.php +++ b/src/Twig/RichEditorExtension.php @@ -206,7 +206,7 @@ public function convertYoutubeEmbeddedLink(string $url): ?string return null; } - return sprintf('https://www.youtube.com/embed/%s', $id); + return \sprintf('https://www.youtube.com/embed/%s', $id); } /** diff --git a/src/UiElement/Metadata.php b/src/UiElement/Metadata.php index 79d0a7ed..0dfd0779 100644 --- a/src/UiElement/Metadata.php +++ b/src/UiElement/Metadata.php @@ -84,7 +84,7 @@ public function isEnabled(): bool public function getParameter(string $name) { if (!$this->hasParameter($name)) { - throw new InvalidArgumentException(sprintf('Parameter "%s" is not configured for resource "%s".', $name, $this->getCode())); + throw new InvalidArgumentException(\sprintf('Parameter "%s" is not configured for resource "%s".', $name, $this->getCode())); } return $this->parameters[$name]; @@ -112,7 +112,7 @@ public function getParameters(): array public function getClass(string $name): string { if (!$this->hasClass($name)) { - throw new InvalidArgumentException(sprintf('Class "%s" is not configured for resource "%s".', $name, $this->getCode())); + throw new InvalidArgumentException(\sprintf('Class "%s" is not configured for resource "%s".', $name, $this->getCode())); } return $this->parameters['classes'][$name]; @@ -132,7 +132,7 @@ public function hasClass(string $name): bool public function getTemplate(string $name): string { if (!$this->hasTemplate($name)) { - throw new InvalidArgumentException(sprintf('Template "%s" is not configured for resource "%s".', $name, $this->getCode())); + throw new InvalidArgumentException(\sprintf('Template "%s" is not configured for resource "%s".', $name, $this->getCode())); } return $this->parameters['templates'][$name]; @@ -153,7 +153,7 @@ public function getServiceId(string $serviceName): string { $code = explode('.', $this->code); - return sprintf('%s.%s.%s', $code[0], $serviceName, $code[1]); + return \sprintf('%s.%s.%s', $code[0], $serviceName, $code[1]); } /** diff --git a/src/UiElement/Metadata/Registry.php b/src/UiElement/Metadata/Registry.php index b4eaca57..4b19d6c1 100644 --- a/src/UiElement/Metadata/Registry.php +++ b/src/UiElement/Metadata/Registry.php @@ -30,7 +30,7 @@ final class Registry implements RegistryInterface public function get(string $code): MetadataInterface { if (!\array_key_exists($code, $this->metadata)) { - throw new InvalidArgumentException(sprintf('Resource "%s" does not exist.', $code)); + throw new InvalidArgumentException(\sprintf('Resource "%s" does not exist.', $code)); } return $this->metadata[$code]; diff --git a/src/Validator/Constraints/YoutubeUrlValidator.php b/src/Validator/Constraints/YoutubeUrlValidator.php index b14f4243..abeb99f5 100644 --- a/src/Validator/Constraints/YoutubeUrlValidator.php +++ b/src/Validator/Constraints/YoutubeUrlValidator.php @@ -27,7 +27,6 @@ public function validate(mixed $value, Constraint $constraint): void throw new UnexpectedTypeException($constraint, YoutubeUrl::class); } - /** @phpstan-ignore-next-line */ $value = (string) $value; if (!preg_match(self::YOUTUBE_REGEX_VALIDATOR, $value)) { diff --git a/src/WysiwygEditor/EditorCollection.php b/src/WysiwygEditor/EditorCollection.php index 5e12bbca..42dfe33f 100644 --- a/src/WysiwygEditor/EditorCollection.php +++ b/src/WysiwygEditor/EditorCollection.php @@ -44,6 +44,6 @@ public function getEditor(string $type): EditorInterface return $this->editors[$type]; } - throw new DomainException(sprintf('There is no editor with %s type', $type)); + throw new DomainException(\sprintf('There is no editor with %s type', $type)); } }