diff --git a/composer.json b/composer.json index a2ba12c75..92eb886be 100755 --- a/composer.json +++ b/composer.json @@ -40,27 +40,27 @@ "sonata-project/doctrine-orm-admin-bundle": "^4.9", "spatie/image-optimizer": "^1.3", "spatie/yaml-front-matter": "^2.0", - "symfony/asset": "6.2.*", - "symfony/cache": "6.2.*", - "symfony/console": "6.2.*", - "symfony/expression-language": "6.2.*", - "symfony/finder": "6.2.*", - "symfony/form": "6.2.*", - "symfony/framework-bundle": "6.2.*", - "symfony/lock": "6.2.*", - "symfony/mailer": "6.2.*", + "symfony/asset": "6.3.*", + "symfony/cache": "6.3.*", + "symfony/console": "6.3.*", + "symfony/expression-language": "6.3.*", + "symfony/finder": "6.3.*", + "symfony/form": "6.3.*", + "symfony/framework-bundle": "6.3.*", + "symfony/lock": "6.3.*", + "symfony/mailer": "6.3.*", "symfony/monolog-bundle": "^3.7", - "symfony/process": "6.2.*", - "symfony/security-bundle": "6.2.*", - "symfony/security-csrf": "6.2.*", + "symfony/process": "6.3.*", + "symfony/security-bundle": "6.3.*", + "symfony/security-csrf": "6.3.*", "symfony/security-guard": "*", - "symfony/serializer": "6.2.*", - "symfony/translation": "6.2.*", - "symfony/twig-bundle": "6.2.*", - "symfony/validator": "6.2.*", - "symfony/web-link": "6.2.*", - "symfony/webpack-encore-bundle": "^1.8", - "symfony/yaml": "6.2.*", + "symfony/serializer": "6.3.*", + "symfony/translation": "6.3.*", + "symfony/twig-bundle": "6.3.*", + "symfony/validator": "6.3.*", + "symfony/web-link": "6.3.*", + "symfony/webpack-encore-bundle": "^2.0", + "symfony/yaml": "6.3.*", "thecodingmachine/safe": "^2.2", "twig/intl-extra": "^3.2", "vich/uploader-bundle": "^2.0", @@ -75,9 +75,10 @@ "phpstan/phpstan-symfony": "^1.0", "phpunit/phpunit": "^9.5", "psalm/plugin-symfony": "^5.0", - "rector/rector": "^0.16", + "rector/rector": "^0.17", "squizlabs/php_codesniffer": "^3.5", - "symfony/dotenv": "6.2.*", + "symfony/debug-bundle": "^6.3", + "symfony/dotenv": "6.3.*", "symfony/maker-bundle": "^1.35", "symfony/panther": "^1 || ^2.0", "symfony/phpunit-bridge": "^6.1", diff --git a/packages/admin-block-editor/src/Block/AbstractBlock.php b/packages/admin-block-editor/src/Block/AbstractBlock.php index 39759edd1..ca5ab926f 100755 --- a/packages/admin-block-editor/src/Block/AbstractBlock.php +++ b/packages/admin-block-editor/src/Block/AbstractBlock.php @@ -26,10 +26,7 @@ public function __construct(string $name) } } - /** - * @param mixed $block - */ - public function render($block): string + public function render(object $block): string { $view = $this->getApp()->getView('/block/'.$this->name.'.html.twig', '@PushwordAdminBlockEditor'); diff --git a/packages/admin-block-editor/src/Block/BlockInterface.php b/packages/admin-block-editor/src/Block/BlockInterface.php index 938f3dc87..010f49059 100755 --- a/packages/admin-block-editor/src/Block/BlockInterface.php +++ b/packages/admin-block-editor/src/Block/BlockInterface.php @@ -7,8 +7,7 @@ interface BlockInterface { - /** @param mixed $block */ - public function render($block): string; + public function render(object $block): string; public function setApp(AppConfig $appConfig): self; diff --git a/packages/admin-block-editor/src/Form/EditorjsType.php b/packages/admin-block-editor/src/Form/EditorjsType.php index ff6b4062a..44ee3ebcb 100755 --- a/packages/admin-block-editor/src/Form/EditorjsType.php +++ b/packages/admin-block-editor/src/Form/EditorjsType.php @@ -6,9 +6,6 @@ class EditorjsType extends TextType { - /** - * {@inheritdoc} - */ public function getBlockPrefix(): string { return 'editorjs'; diff --git a/packages/admin/src/Menu/PageMenuProvider.php b/packages/admin/src/Menu/PageMenuProvider.php index 00c9b8e07..07de18361 100755 --- a/packages/admin/src/Menu/PageMenuProvider.php +++ b/packages/admin/src/Menu/PageMenuProvider.php @@ -100,9 +100,9 @@ private function isRequestingPageEdit(string $host = ''): bool private function extractHostFilter(array $query): ?string { if ( - isset($query['filter']) && \is_array($query['filter']) && - isset($query['filter']['host']) && \is_array($query['filter']['host']) && - isset($query['filter']['host']['value'])) { + isset($query['filter']) && \is_array($query['filter']) + && isset($query['filter']['host']) && \is_array($query['filter']['host']) + && isset($query['filter']['host']['value'])) { if (\is_array($query['filter']['host']['value']) && isset($query['filter']['host']['value'][0]) && \is_string($query['filter']['host']['value'][0])) { return $query['filter']['host']['value'][0]; } diff --git a/packages/admin/src/UserAdmin.php b/packages/admin/src/UserAdmin.php index 9c882ec5c..0bea50863 100755 --- a/packages/admin/src/UserAdmin.php +++ b/packages/admin/src/UserAdmin.php @@ -52,7 +52,7 @@ protected function configureFormFields(FormMapper $form): void $form->end(); - foreach ($fields[1] as $k => $block) { + foreach ($fields[1] as $k => $block) { $form->with($k, ['class' => 'col-md-3 columnFields']); foreach ($block as $singleBlock) { $this->addFormField($singleBlock, $form); diff --git a/packages/advanced-main-image/src/PageAdvancedMainImageFormField.php b/packages/advanced-main-image/src/PageAdvancedMainImageFormField.php index d924c0ec1..89980d7d5 100755 --- a/packages/advanced-main-image/src/PageAdvancedMainImageFormField.php +++ b/packages/advanced-main-image/src/PageAdvancedMainImageFormField.php @@ -25,7 +25,7 @@ public function formField(FormMapper $form): FormMapper 'admin.page.mainImageFormat.34fullscreen' => 3, // 'admin.page.mainImageFormat.fullscreen' => 4, ], - 'data' => \intval($subject->getCustomProperty('mainImageFormat')), + 'data' => \intval($subject->getCustomPropertyScalar('mainImageFormat')), ]); return $form; diff --git a/packages/conversation/src/Controller/ConversationFormController.php b/packages/conversation/src/Controller/ConversationFormController.php index 267ffc485..fded6a4fe 100755 --- a/packages/conversation/src/Controller/ConversationFormController.php +++ b/packages/conversation/src/Controller/ConversationFormController.php @@ -50,7 +50,7 @@ private function getFormManagerClass(string $type) throw new \Exception('`'.$type."` does'nt exist (not configured)."); } - $class = \strval($this->apps->get()->get($param)); + $class = \strval($this->apps->get()->getStr($param)); if (! class_exists($class) || ! (new \ReflectionClass($class))->implementsInterface(ConversationFormInterface::class)) { throw new \Exception('`'.$type."` does'nt exist."); @@ -130,7 +130,7 @@ private function initResponse(Request $request): Response return $response; } - public function show(Request $request, string $type, ?string $host = null): Response + public function show(Request $request, string $type, string $host = null): Response { // $host = $host ?? $request->getHost(); if (null !== $host) { diff --git a/packages/conversation/src/Form/FormTrait.php b/packages/conversation/src/Form/FormTrait.php index 5f864b1e5..dfbcb26a9 100755 --- a/packages/conversation/src/Form/FormTrait.php +++ b/packages/conversation/src/Form/FormTrait.php @@ -11,12 +11,10 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormFactory; use Symfony\Component\Form\FormInterface; -use Symfony\Component\HttpFoundation\IpUtils; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; -use Symfony\Component\Security\Core\Security; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints\Email; use Symfony\Component\Validator\Constraints\Length; diff --git a/packages/conversation/src/Service/NewMessageMailNotifier.php b/packages/conversation/src/Service/NewMessageMailNotifier.php index ed519b9f4..3a4fed786 100755 --- a/packages/conversation/src/Service/NewMessageMailNotifier.php +++ b/packages/conversation/src/Service/NewMessageMailNotifier.php @@ -24,8 +24,6 @@ class NewMessageMailNotifier private readonly string $host; /** - . - * * @param class-string $message Entity */ public function __construct( @@ -37,10 +35,10 @@ public function __construct( private readonly TranslatorInterface $translator, private readonly LoggerInterface $logger ) { - $this->emailTo = \strval($this->apps->get()->get('conversation_notification_email_to')); - $this->emailFrom = \strval($this->apps->get()->get('conversation_notification_email_from')); - $this->interval = \strval($this->apps->get()->get('conversation_notification_interval')); - $this->appName = \strval($this->apps->get()->get('name')); + $this->emailTo = \strval($this->apps->get()->getStr('conversation_notification_email_to')); + $this->emailFrom = \strval($this->apps->get()->getStr('conversation_notification_email_from')); + $this->interval = \strval($this->apps->get()->getStr('conversation_notification_interval')); + $this->appName = \strval($this->apps->get()->getStr('name')); $this->host = $this->apps->get()->getMainHost(); } diff --git a/packages/core/composer.json b/packages/core/composer.json index 6b611c29f..4560e020c 100755 --- a/packages/core/composer.json +++ b/packages/core/composer.json @@ -24,27 +24,27 @@ "pushword/skeleton": "*", "thecodingmachine/safe": "^2.1", "spatie/image-optimizer": "^1.3", - "symfony/asset": "6.2.*", - "symfony/cache": "6.2.*", - "symfony/console": "6.2.*", - "symfony/expression-language": "6.2.*", - "symfony/finder": "6.2.*", - "symfony/form": "6.2.*", - "symfony/framework-bundle": "6.2.*", - "symfony/lock": "6.2.*", - "symfony/mailer": "6.2.*", - "symfony/process": "6.2.*", - "symfony/security-bundle": "6.2.*", - "symfony/security-csrf": "6.2.*", + "symfony/asset": "6.3.*", + "symfony/cache": "6.3.*", + "symfony/console": "6.3.*", + "symfony/expression-language": "6.3.*", + "symfony/finder": "6.3.*", + "symfony/form": "6.3.*", + "symfony/framework-bundle": "6.3.*", + "symfony/lock": "6.3.*", + "symfony/mailer": "6.3.*", + "symfony/process": "6.3.*", + "symfony/security-bundle": "6.3.*", + "symfony/security-csrf": "6.3.*", "symfony/security-guard": "*", - "symfony/translation": "6.2.*", - "symfony/twig-bundle": "6.2.*", - "symfony/validator": "6.2.*", - "symfony/web-link": "6.2.*", - "symfony/webpack-encore-bundle": "^1.8", - "symfony/yaml": "6.2.*", - "symfony/dotenv": "6.2.*", - "symfony/runtime": "6.2.*", + "symfony/translation": "6.3.*", + "symfony/twig-bundle": "6.3.*", + "symfony/validator": "6.3.*", + "symfony/web-link": "6.3.*", + "symfony/webpack-encore-bundle": "^2.0", + "symfony/yaml": "6.3.*", + "symfony/dotenv": "6.3.*", + "symfony/runtime": "6.3.*", "twig/intl-extra": "^3.2", "vich/uploader-bundle": "^2.0", "villfa/invert-color": "^0.5", @@ -54,8 +54,8 @@ "friendsofphp/php-cs-fixer": "^2.17", "phpunit/phpunit": "^9.5", "squizlabs/php_codesniffer": "^3.5", - "symfony/phpunit-bridge": "6.2.*", - "symfony/dotenv": "6.2.*", + "symfony/phpunit-bridge": "6.3.*", + "symfony/dotenv": "6.3.*", "symfony/maker-bundle": "^1.35", "symfony/profiler-pack": "^1.0", "symplify/monorepo-builder": "^9.0" diff --git a/packages/core/src/Command/NewCommand.php b/packages/core/src/Command/NewCommand.php index 3ac79f37e..18505f317 100755 --- a/packages/core/src/Command/NewCommand.php +++ b/packages/core/src/Command/NewCommand.php @@ -37,6 +37,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $mainDomain = $helper->ask($input, $output, $question); $question = new Question('Locale (default: en|fr):', 'en|fr'); + /** @var bool|float|int|resource|string|null */ $locales = $helper->ask($input, $output, $question); $locale = explode('|', \strval($locales))[0]; diff --git a/packages/core/src/Command/UserCreateCommand.php b/packages/core/src/Command/UserCreateCommand.php index 0cf02019f..ee74540cc 100755 --- a/packages/core/src/Command/UserCreateCommand.php +++ b/packages/core/src/Command/UserCreateCommand.php @@ -68,6 +68,7 @@ private function getOrAskIfNotSetted(InputInterface $input, OutputInterface $out { /** @var QuestionHelper $helper */ $helper = $this->getHelper('question'); + /** @var bool|float|int|resource|string|null */ $argumentValue = $input->getArgument($argument); if (null !== $argumentValue) { @@ -79,6 +80,7 @@ private function getOrAskIfNotSetted(InputInterface $input, OutputInterface $out $question->setHidden(true); } + /** @var bool|float|int|resource|string|null */ $argumentValue = $helper->ask($input, $output, $question); if (null === $argumentValue) { diff --git a/packages/core/src/Component/App/AppConfig.php b/packages/core/src/Component/App/AppConfig.php index e3f76e44d..bd02a535e 100755 --- a/packages/core/src/Component/App/AppConfig.php +++ b/packages/core/src/Component/App/AppConfig.php @@ -107,15 +107,14 @@ public function getStr(string $key, string $default = ''): string { $returnValue = $this->get($key) ?? $default; - if (! \is_string($returnValue) && ! \is_int($returnValue) && ! \is_float($returnValue)) { + if (! \is_scalar($returnValue)) { throw new \LogicException('`'.$key.'` is not stringable'); } return (string) $returnValue; } - /** @return mixed */ - public function get(string $key) + public function get(string $key): mixed { $camelCaseKey = static::normalizePropertyName($key); @@ -144,8 +143,7 @@ public function setCustomProperty(string $key, mixed $value): self return $this; } - /** @return mixed */ - public function getCustomProperty(string $key) + public function getCustomProperty(string $key): mixed { return $this->customProperties[$key] ?? null; } @@ -200,7 +198,7 @@ public function getAssetsVersionned(): array /** * @psalm-suppress InternalMethod */ - public function getView(?string $path = null, string $fallback = '@Pushword'): string + public function getView(string $path = null, string $fallback = '@Pushword'): string { if (null === $path) { return $this->template.'/page/page.html.twig'; diff --git a/packages/core/src/Component/App/AppPool.php b/packages/core/src/Component/App/AppPool.php index 157f2c1fb..46bc925e9 100755 --- a/packages/core/src/Component/App/AppPool.php +++ b/packages/core/src/Component/App/AppPool.php @@ -155,8 +155,7 @@ public function getApp(string $host = ''): AppConfig return $this->get($host); } - /** @return mixed */ - public function getAppValue(string $key, string $host = '') + public function getAppValue(string $key, string $host = ''): mixed { return $this->getApp($host)->get($key); } diff --git a/packages/core/src/Component/EntityFilter/Filter/AbstractFilter.php b/packages/core/src/Component/EntityFilter/Filter/AbstractFilter.php index 7abc4ef6c..37d329907 100755 --- a/packages/core/src/Component/EntityFilter/Filter/AbstractFilter.php +++ b/packages/core/src/Component/EntityFilter/Filter/AbstractFilter.php @@ -4,4 +4,17 @@ abstract class AbstractFilter implements FilterInterface { + protected function scalar(mixed $value): bool|float|int|string|null + { + if (null !== $value && ! \is_scalar($value)) { + throw new \LogicException(\gettype($value)); + } + + return $value; + } + + protected function string(mixed $value): string + { + return \strval($this->scalar($value)); + } } diff --git a/packages/core/src/Component/EntityFilter/Filter/Date.php b/packages/core/src/Component/EntityFilter/Filter/Date.php index 24ffc53af..4bec8d3cb 100755 --- a/packages/core/src/Component/EntityFilter/Filter/Date.php +++ b/packages/core/src/Component/EntityFilter/Filter/Date.php @@ -11,11 +11,10 @@ class Date extends AbstractFilter public function apply(mixed $propertyValue): string { - return $this->convertDateShortCode(\strval($propertyValue), $this->getApp()->getDefaultLocale()); + return $this->convertDateShortCode($this->string($propertyValue), $this->getApp()->getDefaultLocale()); } - /** @psalm-suppress RedundantCast */ - private function convertDateShortCode(string $string, ?string $locale = null): string + private function convertDateShortCode(string $string, string $locale = null): string { $locale = null !== $locale ? $this->convertLocale($locale) : 'fr_FR'; $intlDateFormatter = new \IntlDateFormatter($locale, \IntlDateFormatter::FULL, \IntlDateFormatter::NONE); diff --git a/packages/core/src/Component/EntityFilter/Filter/Email.php b/packages/core/src/Component/EntityFilter/Filter/Email.php index bda3d9ca1..b230358f2 100755 --- a/packages/core/src/Component/EntityFilter/Filter/Email.php +++ b/packages/core/src/Component/EntityFilter/Filter/Email.php @@ -14,7 +14,7 @@ class Email extends AbstractFilter public function apply(mixed $propertyValue): string { - return $this->convertEmail(\strval($propertyValue)); + return $this->convertEmail($this->string($propertyValue)); } /** diff --git a/packages/core/src/Component/EntityFilter/Filter/EncryptedLink.php b/packages/core/src/Component/EntityFilter/Filter/EncryptedLink.php index 7a971c3ab..ccbed20c3 100755 --- a/packages/core/src/Component/EntityFilter/Filter/EncryptedLink.php +++ b/packages/core/src/Component/EntityFilter/Filter/EncryptedLink.php @@ -14,7 +14,7 @@ class EncryptedLink extends AbstractFilter public function apply(mixed $propertyValue): string { - return $this->convertEncryptedLink(\strval($propertyValue)); + return $this->convertEncryptedLink($this->string($propertyValue)); } public function convertEncryptedLink(string $body): string diff --git a/packages/core/src/Component/EntityFilter/Filter/Extended.php b/packages/core/src/Component/EntityFilter/Filter/Extended.php index 08fff852b..7c9677f2b 100755 --- a/packages/core/src/Component/EntityFilter/Filter/Extended.php +++ b/packages/core/src/Component/EntityFilter/Filter/Extended.php @@ -18,7 +18,7 @@ class Extended extends AbstractFilter use RequiredManagerPoolTrait; use RequiredPropertyTrait; - public function apply(mixed $propertyValue) + public function apply(mixed $propertyValue) // @phpstan-ignore-line { return $this->loadExtendedValue($propertyValue); } diff --git a/packages/core/src/Component/EntityFilter/Filter/FilterInterface.php b/packages/core/src/Component/EntityFilter/Filter/FilterInterface.php index 971b63baa..a47d72ea6 100755 --- a/packages/core/src/Component/EntityFilter/Filter/FilterInterface.php +++ b/packages/core/src/Component/EntityFilter/Filter/FilterInterface.php @@ -4,8 +4,5 @@ interface FilterInterface { - /** - * @return mixed - */ - public function apply(mixed $propertyValue); + public function apply(mixed $propertyValue); // @phpstan-ignore-line } diff --git a/packages/core/src/Component/EntityFilter/Filter/HtmlLinkMultisite.php b/packages/core/src/Component/EntityFilter/Filter/HtmlLinkMultisite.php index af61585ad..0dd7c616d 100755 --- a/packages/core/src/Component/EntityFilter/Filter/HtmlLinkMultisite.php +++ b/packages/core/src/Component/EntityFilter/Filter/HtmlLinkMultisite.php @@ -42,7 +42,7 @@ public function setRouter(RouterInterface $router): void public function apply(mixed $propertyValue): string { - $propertyValue = \strval($propertyValue); + $propertyValue = $this->string($propertyValue); if (! $this->router instanceof Router) { return $propertyValue; } diff --git a/packages/core/src/Component/EntityFilter/Filter/Image.php b/packages/core/src/Component/EntityFilter/Filter/Image.php index 484758250..7e6af80cc 100755 --- a/packages/core/src/Component/EntityFilter/Filter/Image.php +++ b/packages/core/src/Component/EntityFilter/Filter/Image.php @@ -12,7 +12,7 @@ class Image extends AbstractFilter public function apply(mixed $propertyValue): string { - return $this->convertMarkdownImage(\strval($propertyValue)); + return $this->convertMarkdownImage($this->string($propertyValue)); } /** diff --git a/packages/core/src/Component/EntityFilter/Filter/MainContentSplitter.php b/packages/core/src/Component/EntityFilter/Filter/MainContentSplitter.php index 98c278797..6b81e3c8a 100755 --- a/packages/core/src/Component/EntityFilter/Filter/MainContentSplitter.php +++ b/packages/core/src/Component/EntityFilter/Filter/MainContentSplitter.php @@ -29,7 +29,7 @@ class MainContentSplitter extends AbstractFilter public function apply(mixed $propertyValue): self { - $this->split(\strval($propertyValue)); + $this->split($this->string($propertyValue)); return $this; } @@ -43,8 +43,8 @@ private function split(string $mainContent): void $this->chapeau = isset($parsedContent[1]) ? $parsedContent[0] : ''; $this->content = $parsedContent[1] ?? $parsedContent[0]; - if ($this->entity instanceof CustomPropertiesInterface && - (null !== $this->entity->getCustomProperty('toc') || null !== $this->entity->getCustomProperty('tocTitle'))) { + if ($this->entity instanceof CustomPropertiesInterface + && (null !== $this->entity->getCustomProperty('toc') || null !== $this->entity->getCustomProperty('tocTitle'))) { $this->parseToc(); } diff --git a/packages/core/src/Component/EntityFilter/Filter/MainContentToBody.php b/packages/core/src/Component/EntityFilter/Filter/MainContentToBody.php index fe997815d..dc6dffefe 100755 --- a/packages/core/src/Component/EntityFilter/Filter/MainContentToBody.php +++ b/packages/core/src/Component/EntityFilter/Filter/MainContentToBody.php @@ -8,7 +8,7 @@ class MainContentToBody extends AbstractFilter public function apply(mixed $propertyValue): self { - $this->body = \strval($propertyValue); + $this->body = $this->string($propertyValue); return $this; } diff --git a/packages/core/src/Component/EntityFilter/Filter/Markdown.php b/packages/core/src/Component/EntityFilter/Filter/Markdown.php index 974d655f1..0ad5ac32a 100755 --- a/packages/core/src/Component/EntityFilter/Filter/Markdown.php +++ b/packages/core/src/Component/EntityFilter/Filter/Markdown.php @@ -8,7 +8,7 @@ class Markdown extends AbstractFilter { public function apply(mixed $propertyValue): string { - return $this->render(\strval($propertyValue)); + return $this->render($this->string($propertyValue)); } private function render(string $string): string diff --git a/packages/core/src/Component/EntityFilter/Filter/Name.php b/packages/core/src/Component/EntityFilter/Filter/Name.php index 0fb488c3b..4f85cf878 100755 --- a/packages/core/src/Component/EntityFilter/Filter/Name.php +++ b/packages/core/src/Component/EntityFilter/Filter/Name.php @@ -16,7 +16,7 @@ class Name extends AbstractFilter public function apply(mixed $propertyValue): ?string { - $names = explode("\n", \strval($propertyValue)); + $names = explode("\n", $this->string($propertyValue)); return isset($names[0]) && '' !== $names[0] ? trim($names[0]) : ('' !== $propertyValue ? $propertyValue : $this->entityFilterManager->getH1()); // @phpstan-ignore-line diff --git a/packages/core/src/Component/EntityFilter/Filter/PhoneNumber.php b/packages/core/src/Component/EntityFilter/Filter/PhoneNumber.php index 1895c0014..413e77edb 100755 --- a/packages/core/src/Component/EntityFilter/Filter/PhoneNumber.php +++ b/packages/core/src/Component/EntityFilter/Filter/PhoneNumber.php @@ -14,7 +14,7 @@ class PhoneNumber extends AbstractFilter public function apply(mixed $propertyValue): string { - return $this->convertPhoneNumber(\strval($propertyValue)); + return $this->convertPhoneNumber($this->string($propertyValue)); } private function convertPhoneNumber(string $body): string diff --git a/packages/core/src/Component/EntityFilter/Filter/Punctuation.php b/packages/core/src/Component/EntityFilter/Filter/Punctuation.php index 6ebf769ef..3aa7a6b78 100755 --- a/packages/core/src/Component/EntityFilter/Filter/Punctuation.php +++ b/packages/core/src/Component/EntityFilter/Filter/Punctuation.php @@ -8,7 +8,7 @@ class Punctuation extends AbstractFilter { public function apply(mixed $propertyValue): string { - $propertyValue = \strval($propertyValue); + $propertyValue = $this->string($propertyValue); $propertyValue = str_replace(' .', '.', $propertyValue); $propertyValue = str_replace(' ,', ',', $propertyValue); diff --git a/packages/core/src/Component/EntityFilter/Filter/ShowMore.php b/packages/core/src/Component/EntityFilter/Filter/ShowMore.php index 3393ea806..a96c645fb 100755 --- a/packages/core/src/Component/EntityFilter/Filter/ShowMore.php +++ b/packages/core/src/Component/EntityFilter/Filter/ShowMore.php @@ -12,7 +12,7 @@ class ShowMore extends AbstractFilter public function apply(mixed $propertyValue): string { - return $this->showMore(\strval($propertyValue)); + return $this->showMore($this->string($propertyValue)); } private function showMore(string $body): string diff --git a/packages/core/src/Component/EntityFilter/Filter/Twig.php b/packages/core/src/Component/EntityFilter/Filter/Twig.php index f46596381..fa8948a12 100755 --- a/packages/core/src/Component/EntityFilter/Filter/Twig.php +++ b/packages/core/src/Component/EntityFilter/Filter/Twig.php @@ -13,7 +13,7 @@ class Twig extends AbstractFilter public function apply(mixed $propertyValue): string { - return $this->render(\strval($propertyValue)); + return $this->render($this->string($propertyValue)); } protected function render(string $string): string diff --git a/packages/core/src/Component/EntityFilter/Manager.php b/packages/core/src/Component/EntityFilter/Manager.php index a81d4c22f..70042b7dd 100755 --- a/packages/core/src/Component/EntityFilter/Manager.php +++ b/packages/core/src/Component/EntityFilter/Manager.php @@ -54,10 +54,8 @@ public function getEntity(): object * Magic getter for Entity properties. * * @param array $arguments - * - * @return mixed */ - public function __call(string $method, array $arguments = []) + public function __call(string $method, array $arguments = []): mixed { if (\Safe\preg_match('/^get/', $method) < 1) { $method = 'get'.ucfirst($method); @@ -69,6 +67,10 @@ public function __call(string $method, array $arguments = []) $returnValue = [] !== $arguments ? \call_user_func_array([$this->entity, $method], $arguments) // @phpstan-ignore-line : \call_user_func([$this->entity, $method]); // @phpstan-ignore-line + if (! \is_scalar($returnValue)) { + throw new \LogicException(); + } + $returnValue = $this->filter(substr($method, 3), $returnValue); $this->eventDispatcher->dispatch($filterEvent, FilterEvent::NAME_AFTER); @@ -80,7 +82,7 @@ public function __call(string $method, array $arguments = []) * main_content => apply filters on mainContent (*_filters => camelCase(*)) * string => apply filters on each string property. */ - private function filter(string $property, mixed $propertyValue): mixed + private function filter(string $property, bool|float|int|string|null $propertyValue): mixed { $filters = $this->getFilters($this->camelCaseToSnakeCase($property)); @@ -167,10 +169,8 @@ private function getFilterClass(string $filter): FilterInterface /** * @param string[] $filters - * - * @return mixed */ - private function applyFilters(string $property, mixed $propertyValue, array $filters) + private function applyFilters(string $property, bool|float|int|string|null $propertyValue, array $filters): mixed { foreach ($filters as $filter) { if ($this->entity instanceof CustomPropertiesInterface diff --git a/packages/core/src/Component/EntityFilter/ManagerPool.php b/packages/core/src/Component/EntityFilter/ManagerPool.php index 66274202d..158583961 100755 --- a/packages/core/src/Component/EntityFilter/ManagerPool.php +++ b/packages/core/src/Component/EntityFilter/ManagerPool.php @@ -53,7 +53,7 @@ public function getManager(IdInterface $id): Manager /** * @return mixed|\Pushword\Core\Component\EntityFilter\Manager */ - public function getProperty(IdInterface $id, string $property = '') + public function getProperty(IdInterface $id, string $property = ''): mixed { $manager = $this->getManager($id); diff --git a/packages/core/src/Component/EntityFilter/ManagerPoolInterface.php b/packages/core/src/Component/EntityFilter/ManagerPoolInterface.php index 254715031..03b25be92 100755 --- a/packages/core/src/Component/EntityFilter/ManagerPoolInterface.php +++ b/packages/core/src/Component/EntityFilter/ManagerPoolInterface.php @@ -9,8 +9,7 @@ */ interface ManagerPoolInterface { - /** @return mixed */ - public function getProperty(IdInterface $id, string $property = ''); + public function getProperty(IdInterface $id, string $property = ''): mixed; /** * @return Manager diff --git a/packages/core/src/Controller/PageController.php b/packages/core/src/Controller/PageController.php index 2bdc7aa73..bc3e54d08 100755 --- a/packages/core/src/Controller/PageController.php +++ b/packages/core/src/Controller/PageController.php @@ -16,14 +16,11 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Translation\DataCollectorTranslator; use Symfony\Contracts\Translation\TranslatorInterface; -use Twig\Environment as Twig; final class PageController extends AbstractController { use RenderTrait; - private Twig $twig; - /** @var DataCollectorTranslator|Translator */ private readonly TranslatorInterface $translator; @@ -50,7 +47,7 @@ private function initHost(RequestStack|Request $request): void return; } - $host = \strval($request->attributes->get('host', '')); + $host = \strval($request->attributes->get('host', '')); // @phpstan-ignore-line if ('' !== $host) { $this->apps->switchCurrentApp($host); @@ -204,11 +201,11 @@ public function showRobotsTxt(): Response } /** - . + * . * * @return mixed //array */ - private function getPages(Request $request, ?int $limit = null) + private function getPages(Request $request, int $limit = null) { $requestedLocale = rtrim($request->getLocale(), '/'); @@ -242,7 +239,7 @@ private function extractPager( string &$slug, bool $throwException ): ?PageInterface { - if (1 !== \Safe\preg_match('#(/([1-9][0-9]*)|^([1-9][0-9]*))$#', $slug, $match)) { + if (1 !== \Safe\preg_match('#(/([1-9]\d*)|^([1-9]\d*))$#', $slug, $match)) { return null; } diff --git a/packages/core/src/Entity/MediaInterface.php b/packages/core/src/Entity/MediaInterface.php index e29ed528e..56acdb882 100755 --- a/packages/core/src/Entity/MediaInterface.php +++ b/packages/core/src/Entity/MediaInterface.php @@ -51,13 +51,13 @@ public function setMediaBeforeUpdate(?string $mediaBeforeUpdate): self; public function setName(?string $name): self; - public function setMediaFile(?File $file = null): void; + public function setMediaFile(File $file = null): void; public function getMimeType(): ?string; public function getName(bool $onlyName = false): string; - public function getNameLocalized(?string $getLocalized = null, bool $onlyLocalized = false): string; + public function getNameLocalized(string $getLocalized = null, bool $onlyLocalized = false): string; public function getMediaFile(): ?File; @@ -73,7 +73,7 @@ public function getMainImagePages(): array|Collection; public function getHash(): string; - public function setHash(?string $hash = null): self; + public function setHash(string $hash = null): self; public function resetHash(): self; diff --git a/packages/core/src/Entity/MediaTrait/MediaHashTrait.php b/packages/core/src/Entity/MediaTrait/MediaHashTrait.php index 6b99a2edd..f1e393e87 100755 --- a/packages/core/src/Entity/MediaTrait/MediaHashTrait.php +++ b/packages/core/src/Entity/MediaTrait/MediaHashTrait.php @@ -11,7 +11,7 @@ trait MediaHashTrait * @var ?string */ #[ORM\Column(type: 'binary', length: 20, options: ['default' => ''])] - protected $hash = null; + protected $hash; abstract public function getMediaFile(): ?File; @@ -31,7 +31,7 @@ public function resetHash(): self return $this; } - public function setHash(?string $hash = null): self + public function setHash(string $hash = null): self { if (null !== $hash) { $this->hash = $hash; diff --git a/packages/core/src/Entity/MediaTrait/MediaNameTrait.php b/packages/core/src/Entity/MediaTrait/MediaNameTrait.php index 1124dd19b..5afb439a1 100755 --- a/packages/core/src/Entity/MediaTrait/MediaNameTrait.php +++ b/packages/core/src/Entity/MediaTrait/MediaNameTrait.php @@ -27,7 +27,7 @@ public function getName(bool $onlyName = false): string return '' === $this->name && null !== $this->getMediaFile() ? $this->getMediaFileName() : $this->name; } - public function getNameLocalized(?string $getLocalized = null, bool $onlyLocalized = false): string + public function getNameLocalized(string $getLocalized = null, bool $onlyLocalized = false): string { $names = $this->getNamesParsed(); @@ -51,10 +51,7 @@ public function getNamesParsed(): array return $return; } - /** - * @return mixed - */ - public function getNames(bool $yamlParsed = false) + public function getNames(bool $yamlParsed = false): mixed { $this->names = (string) $this->names; diff --git a/packages/core/src/Entity/MediaTrait/MediaTrait.php b/packages/core/src/Entity/MediaTrait/MediaTrait.php index d534ada85..d77a9ed98 100755 --- a/packages/core/src/Entity/MediaTrait/MediaTrait.php +++ b/packages/core/src/Entity/MediaTrait/MediaTrait.php @@ -50,7 +50,7 @@ trait MediaTrait * @var UploadedFile|File|null */ #[Vich\UploadableField(mapping: 'media_media', fileNameProperty: 'slug', mimeType: 'mimeType', size: 'size', dimensions: 'dimensions')] - protected $mediaFile = null; + protected $mediaFile; // todo Rename to $file /** @@ -132,7 +132,7 @@ public function validate(ExecutionContextInterface $executionContext): void ; } - public function setMediaFile(?File $file = null): void + public function setMediaFile(File $file = null): void { $this->mediaFile = $file; diff --git a/packages/core/src/Entity/PageTrait/PageEditorTrait.php b/packages/core/src/Entity/PageTrait/PageEditorTrait.php index dd31f1557..2d353b413 100755 --- a/packages/core/src/Entity/PageTrait/PageEditorTrait.php +++ b/packages/core/src/Entity/PageTrait/PageEditorTrait.php @@ -57,38 +57,38 @@ public function setCreatedBy(?UserInterface $user): void } /** - public function setPageHasEditors($pageHasEditors): void - { - $this->pageHasEditors = new ArrayCollection(); - foreach ($pageHasEditors as $pageHasEditor) { - $this->addPageHasEditor($pageHasEditor); - } - } - - public function getPageHasEditors(): ArrayCollection - { - return $this->pageHasEditors ?? new ArrayCollection(); - } - - public function addPageHasEditor(PageHasEditor $pageHasEditor): void - { - $this->getPageHasEditors(); - $pageHasEditor->setPage($this); - $this->pageHasEditors[] = $pageHasEditor; - } - - public function resetPageHasEditors(): void - { - foreach ($this->getPageHasEditors() as $pageHasEditor) { - $this->removePageHasEditor($pageHasEditor); - } - } - - public function removePageHasEditor(PageHasEditor $pageHasEditor): void - { - $this->getPageHasEditors()->removeElement($pageHasEditor); - } - /**/ + * public function setPageHasEditors($pageHasEditors): void + * { + * $this->pageHasEditors = new ArrayCollection(); + * foreach ($pageHasEditors as $pageHasEditor) { + * $this->addPageHasEditor($pageHasEditor); + * } + * }. + * + * public function getPageHasEditors(): ArrayCollection + * { + * return $this->pageHasEditors ?? new ArrayCollection(); + * } + * + * public function addPageHasEditor(PageHasEditor $pageHasEditor): void + * { + * $this->getPageHasEditors(); + * $pageHasEditor->setPage($this); + * $this->pageHasEditors[] = $pageHasEditor; + * } + * + * public function resetPageHasEditors(): void + * { + * foreach ($this->getPageHasEditors() as $pageHasEditor) { + * $this->removePageHasEditor($pageHasEditor); + * } + * } + * + * public function removePageHasEditor(PageHasEditor $pageHasEditor): void + * { + * $this->getPageHasEditors()->removeElement($pageHasEditor); + * } + * /**/ /** * Get the value of editMessage. diff --git a/packages/core/src/Entity/PageTrait/PageParentTrait.php b/packages/core/src/Entity/PageTrait/PageParentTrait.php index a88e01570..787b66027 100755 --- a/packages/core/src/Entity/PageTrait/PageParentTrait.php +++ b/packages/core/src/Entity/PageTrait/PageParentTrait.php @@ -17,7 +17,7 @@ trait PageParentTrait */ #[ORM\OneToMany(targetEntity: \Pushword\Core\Entity\PageInterface::class, mappedBy: 'parentPage')] #[ORM\OrderBy(['publishedAt' => 'DESC', 'priority' => 'DESC'])] - protected $childrenPages = null; + protected $childrenPages; public function getParentPage(): ?PageInterface { diff --git a/packages/core/src/Entity/PageTrait/PageRedirectionTrait.php b/packages/core/src/Entity/PageTrait/PageRedirectionTrait.php index 8e09b3020..18974529e 100755 --- a/packages/core/src/Entity/PageTrait/PageRedirectionTrait.php +++ b/packages/core/src/Entity/PageTrait/PageRedirectionTrait.php @@ -9,7 +9,7 @@ trait PageRedirectionTrait /** * @var string|false|null */ - protected $redirectionUrl = null; + protected $redirectionUrl; protected ?int $redirectionCode = null; @@ -24,9 +24,9 @@ protected function manageRedirection(): void $code = 301; // default symfony is 302... if (str_starts_with($content, 'Location:')) { $url = trim(substr($content, 9)); - if (1 === \Safe\preg_match('/ [1-5][0-9]{2}$/', $url, $match)) { + if (1 === \Safe\preg_match('/ [1-5]\d{2}$/', $url, $match)) { $code = (int) trim((string) $match[0]); - $url = F::preg_replace_str('/ [1-5][0-9]{2}$/', '', $url); + $url = F::preg_replace_str('/ [1-5]\d{2}$/', '', $url); } if (false !== filter_var($url, \FILTER_VALIDATE_URL) || 1 === \Safe\preg_match('/^[^ ]+$/', $url)) { diff --git a/packages/core/src/Entity/SharedTrait/CustomPropertiesInterface.php b/packages/core/src/Entity/SharedTrait/CustomPropertiesInterface.php index dffd4b589..3c34182d1 100755 --- a/packages/core/src/Entity/SharedTrait/CustomPropertiesInterface.php +++ b/packages/core/src/Entity/SharedTrait/CustomPropertiesInterface.php @@ -22,10 +22,9 @@ public function isStandAloneCustomProperty(string $name): bool; public function setCustomProperty(string $name, mixed $value): self; - /** - * @return mixed - */ - public function getCustomProperty(string $name); + public function getCustomProperty(string $name): mixed; + + public function getCustomPropertyScalar(string $name): bool|float|int|string|null; public function removeCustomProperty(string $name): void; } diff --git a/packages/core/src/Entity/SharedTrait/CustomPropertiesTrait.php b/packages/core/src/Entity/SharedTrait/CustomPropertiesTrait.php index 106a2fc9d..b727581f2 100755 --- a/packages/core/src/Entity/SharedTrait/CustomPropertiesTrait.php +++ b/packages/core/src/Entity/SharedTrait/CustomPropertiesTrait.php @@ -145,14 +145,21 @@ public function setCustomProperty(string $name, mixed $value): self return $this; } - /** - * @return mixed - */ - public function getCustomProperty(string $name) + public function getCustomProperty(string $name): mixed { return $this->customProperties[$name] ?? null; } + public function getCustomPropertyScalar(string $name): bool|float|int|string|null + { + $return = $this->customProperties[$name] ?? null; + if (null !== $return && ! \is_scalar($return)) { + throw new \LogicException(\gettype($return)); + } + + return $return; + } + public function removeCustomProperty(string $name): void { unset($this->customProperties[$name]); @@ -164,7 +171,7 @@ public function removeCustomProperty(string $name): void * * @param mixed[] $arguments * - * @return mixed + * @return mixed|void */ public function __call(string $method, array $arguments = []) { diff --git a/packages/core/src/Entity/UserTrait.php b/packages/core/src/Entity/UserTrait.php index 319cecabb..73cf7a54d 100755 --- a/packages/core/src/Entity/UserTrait.php +++ b/packages/core/src/Entity/UserTrait.php @@ -68,7 +68,7 @@ public function getPlainPassword(): ?string } /** - * @return string[] The user roles + * @return string[] The user roles */ public function getRoles(): array { diff --git a/packages/core/src/EventListener/MediaListener.php b/packages/core/src/EventListener/MediaListener.php index f7287032b..a4cc1593f 100755 --- a/packages/core/src/EventListener/MediaListener.php +++ b/packages/core/src/EventListener/MediaListener.php @@ -247,7 +247,7 @@ private function getFlashBag(): ?FlashBagInterface $this->flashBag = $request->getSession()->getFlashBag() : null; } - private function updateMainColor(MediaInterface $media, ?Image $image = null): void + private function updateMainColor(MediaInterface $media, Image $image = null): void { if (! $image instanceof \Intervention\Image\Image) { return; @@ -257,7 +257,7 @@ private function updateMainColor(MediaInterface $media, ?Image $image = null): v $color = $imageForPalette->limitColors(1)->pickColor(0, 0, 'hex'); $imageForPalette->destroy(); - $media->setMainColor(\strval($color)); + $media->setMainColor(\strval($color)); // @phpstan-ignore-line } /* Palette was good, but not ready for PHP 8 diff --git a/packages/core/src/Repository/PageRepository.php b/packages/core/src/Repository/PageRepository.php index 6c6f21f1c..6a263abb7 100755 --- a/packages/core/src/Repository/PageRepository.php +++ b/packages/core/src/Repository/PageRepository.php @@ -30,9 +30,9 @@ class PageRepository extends ServiceEntityRepository implements ObjectRepository /** * Can be used via a twig function. * - * @param string|array $host - * @param array<(string|int), string> $orderBy - * @param array $where + * @param string|array $host + * @param array<(string|int), string> $orderBy + * @param array $where * @param int|array<(string|int), int> $limit * * @return PageInterface[] @@ -60,9 +60,9 @@ public function getPublishedPages( /** * Can be used via a twig function. * - * @param string|array $host - * @param array<(string|int), string> $orderBy - * @param array $where + * @param string|array $host + * @param array<(string|int), string> $orderBy + * @param array $where * @param int|array<(string|int), int> $limit */ public function getPublishedPageQueryBuilder(string|array $host = '', array $where = [], array $orderBy = [], int|array $limit = 0): QueryBuilder @@ -124,7 +124,7 @@ public function findByHost(string|array $host): array public function getIndexablePagesQuery( string|array $host, string $locale, - ?int $limit = null + int $limit = null ): QueryBuilder { $qb = $this->buildPublishedPageQuery('p'); $qb = $this->andIndexable($qb); diff --git a/packages/core/src/Router/Router.php b/packages/core/src/Router/Router.php index 280eb4eee..63c7bf87a 100755 --- a/packages/core/src/Router/Router.php +++ b/packages/core/src/Router/Router.php @@ -27,7 +27,7 @@ public function __construct( * and / for YY page home if your default language is YY * X/Y may be en/fr/... */ - public function generatePathForHomePage(?PageInterface $page = null, bool $canonical = false): string + public function generatePathForHomePage(PageInterface $page = null, bool $canonical = false): string { $homepage = (new Page())->setSlug(''); diff --git a/packages/core/src/Router/RouterInterface.php b/packages/core/src/Router/RouterInterface.php index 73ee66934..5ed5e56c2 100755 --- a/packages/core/src/Router/RouterInterface.php +++ b/packages/core/src/Router/RouterInterface.php @@ -17,7 +17,7 @@ interface RouterInterface */ public const CUSTOM_HOST_PATH = 'custom_host_pushword_page'; - public function generatePathForHomePage(?PageInterface $page = null, bool $canonical = false): string; + public function generatePathForHomePage(PageInterface $page = null, bool $canonical = false): string; /** * @param int|string|null $pager diff --git a/packages/core/src/Service/ImageManager.php b/packages/core/src/Service/ImageManager.php index 90eaacf05..6ac928a8a 100755 --- a/packages/core/src/Service/ImageManager.php +++ b/packages/core/src/Service/ImageManager.php @@ -71,7 +71,7 @@ public function getLastThumb(): ?Image /** * @param array|string $filter */ - public function generateFilteredCache(MediaInterface|string $media, array|string $filter, ?Image $originalImage = null): Image + public function generateFilteredCache(MediaInterface|string $media, array|string $filter, Image $originalImage = null): Image { if (\is_array($filter)) { $filterName = array_keys($filter)[0]; @@ -154,7 +154,7 @@ private function normalizeFilter(string &$filter, array &$parameters): void } } - public function getFilterPath(MediaInterface|string $media, string $filterName, ?string $extension = null, bool $browserPath = false): string + public function getFilterPath(MediaInterface|string $media, string $filterName, string $extension = null, bool $browserPath = false): string { /** @var string $media */ $media = $media instanceof MediaInterface ? $media->getMedia() : Filepath::filename($media); @@ -164,7 +164,7 @@ public function getFilterPath(MediaInterface|string $media, string $filterName, return ($browserPath ? '' : $this->publicDir).'/'.$this->publicMediaDir.'/'.$filterName.'/'.$fileName; } - public function getBrowserPath(MediaInterface|string $media, string $filterName = 'default', ?string $extension = null): string + public function getBrowserPath(MediaInterface|string $media, string $filterName = 'default', string $extension = null): string { return $this->getFilterPath($media, $filterName, $extension, true); } diff --git a/packages/core/src/Service/PageOpenGraphImageGenerator.php b/packages/core/src/Service/PageOpenGraphImageGenerator.php index a02b1165e..4e7720981 100644 --- a/packages/core/src/Service/PageOpenGraphImageGenerator.php +++ b/packages/core/src/Service/PageOpenGraphImageGenerator.php @@ -112,6 +112,7 @@ private function drawLogo(ImageInterface $image): void { $logo = $this->apps->get()->getView('/page/OpenGrapImageGenerator/logo.png'); $logo = $this->getImagine()->open($this->twig->getLoader()->getSourceContext($logo)->getPath()); + $logoSize = $logo->getSize(); $bottomRight = new \Imagine\Image\Point( $this->imageWidth - $logoSize->getWidth() - $this->marginSize, @@ -120,7 +121,7 @@ private function drawLogo(ImageInterface $image): void $image->paste($logo, $bottomRight); } - private function getFont(string $fontType = 'bold', int $size = 37, ?ColorInterface $color = null): Font + private function getFont(string $fontType = 'bold', int $size = 37, ColorInterface $color = null): Font { $font = $this->apps->get()->getView('@Pushword/page/OpenGrapImageGenerator/'.$fontType.'.ttf'); diff --git a/packages/core/src/Twig/AppExtension.php b/packages/core/src/Twig/AppExtension.php index e391e33e2..f7157b77f 100755 --- a/packages/core/src/Twig/AppExtension.php +++ b/packages/core/src/Twig/AppExtension.php @@ -133,9 +133,9 @@ public function getPagePosition(PageInterface $page): int } /** - * @param string|string[]|null $host - * @param array<(string|int), string> $orderBy - * @param array $where + * @param string|string[]|null $host + * @param array<(string|int), string> $orderBy + * @param array $where * @param int|array<(string|int), int> $limit * * @return PageInterface[] @@ -163,7 +163,7 @@ public function getPublishedPage(string $slug, $host = null): ?PageInterface return $pages[0] ?? null; } - public function getView(string $path, ?string $fallback = null): string + public function getView(string $path, string $fallback = null): string { return null !== $fallback ? $this->apps->get()->getView($path, $fallback) : $this->apps->get()->getView($path); diff --git a/packages/core/src/Twig/GalleryTwigTrait.php b/packages/core/src/Twig/GalleryTwigTrait.php index 9a885e63a..2bd95ecab 100755 --- a/packages/core/src/Twig/GalleryTwigTrait.php +++ b/packages/core/src/Twig/GalleryTwigTrait.php @@ -13,9 +13,9 @@ abstract public function getApp(): AppConfig; */ public function renderGallery( array $images, - ?string $gridCols = null, - ?string $imageFilter = null, - ?string $imageContainer = null + string $gridCols = null, + string $imageFilter = null, + string $imageContainer = null ): string { $template = $this->getApp()->getView('/component/images_gallery.html.twig'); diff --git a/packages/core/src/Twig/PageListTwigTrait.php b/packages/core/src/Twig/PageListTwigTrait.php index f36ccd850..9b2f6634a 100755 --- a/packages/core/src/Twig/PageListTwigTrait.php +++ b/packages/core/src/Twig/PageListTwigTrait.php @@ -104,7 +104,7 @@ private function stringToSearch(string $search, ?PageInterface $currentPage): ar /** * @return mixed[]|null */ - private function simpleStringToSearchChildren(string $search, ?PageInterface $currentPage = null): ?array + private function simpleStringToSearchChildren(string $search, PageInterface $currentPage = null): ?array { if (null === $currentPage) { return null; @@ -135,7 +135,7 @@ private function simpleStringToSearchChildren(string $search, ?PageInterface $cu /** * @return array */ - private function simpleStringToSearch(string $search, ?PageInterface $currentPage = null): array + private function simpleStringToSearch(string $search, PageInterface $currentPage = null): array { if (($return = $this->simpleStringToSearchChildren($search, $currentPage)) !== null) { return $return; @@ -157,11 +157,11 @@ private function simpleStringToSearch(string $search, ?PageInterface $currentPag } /** - * @param string|array $search + * @param string|array $search * @param string|array<(string|int), string> $order - * @param string|string[] $host - * @param int|array<(string|int), int> $max if max is int => max result, - * if max is array => paginate where 0 => item per page and 1 (fac) maxPage + * @param string|string[] $host + * @param int|array<(string|int), int> $max if max is int => max result, + * if max is array => paginate where 0 => item per page and 1 (fac) maxPage */ public function renderPagesList( Twig $twig, @@ -170,7 +170,7 @@ public function renderPagesList( array|string $order = 'publishedAt,priority', string $view = '', array|string $host = '', - ?PageInterface $currentPage = null + PageInterface $currentPage = null ): string { $currentPage ??= $this->apps->getCurrentPage(); // todo : drop app's current page @@ -260,6 +260,6 @@ private function getCurrentPage(): int return 1; } - return \intval($this->requestStack->getCurrentRequest()->attributes->get('pager', 1)); + return \intval($this->requestStack->getCurrentRequest()->attributes->getInt('pager', 1)); } } diff --git a/packages/core/src/Twig/PhoneNumberTwigTrait.php b/packages/core/src/Twig/PhoneNumberTwigTrait.php index 9229c1344..d6aea80bc 100755 --- a/packages/core/src/Twig/PhoneNumberTwigTrait.php +++ b/packages/core/src/Twig/PhoneNumberTwigTrait.php @@ -17,7 +17,7 @@ public function renderPhoneNumber(string $number, string $class = ''): string return trim($this->twig->render($template, [ 'number' => str_replace([' ', ' ', '.'], '', $number), - 'number_readable' => str_replace(' ', ' ', F::preg_replace_str('#^\+[0-9]{2} ?#', '0', $number)), + 'number_readable' => str_replace(' ', ' ', F::preg_replace_str('#^\+\d{2} ?#', '0', $number)), 'class' => $class, ])); } diff --git a/packages/core/src/Utils/LastTime.php b/packages/core/src/Utils/LastTime.php index b00c3f125..ccc5225fa 100755 --- a/packages/core/src/Utils/LastTime.php +++ b/packages/core/src/Utils/LastTime.php @@ -3,7 +3,6 @@ namespace Pushword\Core\Utils; use DateInterval; -use DateTime; /** * Usage @@ -28,7 +27,7 @@ public function wasRunSince(\DateInterval $dateInterval): bool * * @return \DateTime|\DateTimeImmutable|null */ - public function get(?string $default = null): ?\DateTimeInterface + public function get(string $default = null): ?\DateTimeInterface { if (! file_exists($this->filePath)) { return null === $default ? null : new \DateTime($default); diff --git a/packages/core/src/Utils/MediaRenamer.php b/packages/core/src/Utils/MediaRenamer.php index 73ffb0c1d..edfe55244 100755 --- a/packages/core/src/Utils/MediaRenamer.php +++ b/packages/core/src/Utils/MediaRenamer.php @@ -16,7 +16,7 @@ public function reset(): void public function rename(MediaInterface $media): MediaInterface { $newName = (1 === $this->iterate ? $media->getName() - : F::preg_replace_str('/ \([0-9]+\)$/', '', $media->getName())); + : F::preg_replace_str('/ \(\d+\)$/', '', $media->getName())); $newName .= ' ('.($this->iterate + 1).')'; $media->setName($newName); diff --git a/packages/core/src/Validator/Constraints/PageRenderingValidator.php b/packages/core/src/Validator/Constraints/PageRenderingValidator.php index 030499c3c..786be7dab 100755 --- a/packages/core/src/Validator/Constraints/PageRenderingValidator.php +++ b/packages/core/src/Validator/Constraints/PageRenderingValidator.php @@ -13,10 +13,7 @@ public function __construct(private readonly \Pushword\Core\Controller\PageContr { } - /** - * @param mixed $value - */ - public function validate($value, Constraint $constraint): void + public function validate(mixed $value, Constraint $constraint): void { if (! $constraint instanceof PageRendering) { throw new UnexpectedTypeException($constraint, PageRendering::class); diff --git a/packages/core/tests/Command/MediaCacheGeneratorCommandTest.php b/packages/core/tests/Command/MediaCacheGeneratorCommandTest.php index 683affe66..93ae00ba8 100755 --- a/packages/core/tests/Command/MediaCacheGeneratorCommandTest.php +++ b/packages/core/tests/Command/MediaCacheGeneratorCommandTest.php @@ -19,12 +19,12 @@ public function testExecute() // the output of the command in the console $output = $commandTester->getDisplay(); - $this->assertTrue(false !== strpos($output, '100%')); + $this->assertTrue(str_contains($output, '100%')); $commandTester->execute(['media' => 'piedweb-logo.png']); // the output of the command in the console $output = $commandTester->getDisplay(); - $this->assertTrue(false !== strpos($output, '100%')); + $this->assertTrue(str_contains($output, '100%')); } } diff --git a/packages/core/tests/Command/UserCommandTest.php b/packages/core/tests/Command/UserCommandTest.php index 11b5f796a..cd0f24745 100755 --- a/packages/core/tests/Command/UserCommandTest.php +++ b/packages/core/tests/Command/UserCommandTest.php @@ -23,6 +23,6 @@ public function testExecute() // the output of the command in the console $output = $commandTester->getDisplay(); - $this->assertTrue(false !== strpos($output, 'success')); + $this->assertTrue(str_contains($output, 'success')); } } diff --git a/packages/flat/src/Importer/PageImporter.php b/packages/flat/src/Importer/PageImporter.php index 54af4bab9..90ce726bb 100755 --- a/packages/flat/src/Importer/PageImporter.php +++ b/packages/flat/src/Importer/PageImporter.php @@ -137,7 +137,7 @@ private function editPage(string $slug, array $data, string $content, \DateTime| $setter = 'set'.ucfirst($camelKey); if (method_exists($page, $setter)) { - if (\in_array($camelKey, ['publishedAt', 'createdAt', 'updatedAt'], true)) { + if (\in_array($camelKey, ['publishedAt', 'createdAt', 'updatedAt'], true) && \is_scalar($value)) { $value = new \DateTime(\strval($value)); } diff --git a/packages/flat/tests/CommandTest.php b/packages/flat/tests/CommandTest.php index 1e7c3a99d..f4e4c2114 100755 --- a/packages/flat/tests/CommandTest.php +++ b/packages/flat/tests/CommandTest.php @@ -21,7 +21,7 @@ public function testImport() // the output of the command in the console $output = $commandTester->getDisplay(); - $this->assertTrue(false !== strpos($output, 'ended')); + $this->assertTrue(str_contains($output, 'ended')); $exportDir = $kernel->getCacheDir().'/test-exporter'; diff --git a/packages/installer/composer.json b/packages/installer/composer.json index 455dbea30..a5ff415bc 100755 --- a/packages/installer/composer.json +++ b/packages/installer/composer.json @@ -5,7 +5,7 @@ "homepage": "https://pushword.piedweb.com", "license": "MIT", "require": { - "symfony/filesystem": "6.2.*" + "symfony/filesystem": "6.3.*" }, "extra": { "branch-alias": { diff --git a/packages/new/composer.json b/packages/new/composer.json index 97728013e..8641c7eb3 100755 --- a/packages/new/composer.json +++ b/packages/new/composer.json @@ -12,17 +12,17 @@ "symfony/flex": "^1.3.1" }, "flex-require": { - "symfony/console": "6.2.*", - "symfony/dotenv": "6.2.*", - "symfony/framework-bundle": "6.2.*", + "symfony/console": "6.3.*", + "symfony/dotenv": "6.3.*", + "symfony/framework-bundle": "6.3.*", "symfony/runtime": "*", - "symfony/yaml": "6.2.*", + "symfony/yaml": "6.3.*", "pushword/core": "*" }, "require-dev": { "symfony/profiler-pack": "*", "pushword/installer": "*", - "symfony/filesystem": "6.2.*" + "symfony/filesystem": "6.3.*" }, "config": { "optimize-autoloader": true, diff --git a/packages/page-scanner/src/Scanner/LinkedDocsScanner.php b/packages/page-scanner/src/Scanner/LinkedDocsScanner.php index 2c2350aa1..2c39ca125 100755 --- a/packages/page-scanner/src/Scanner/LinkedDocsScanner.php +++ b/packages/page-scanner/src/Scanner/LinkedDocsScanner.php @@ -84,7 +84,7 @@ protected function run(): void /** * @param string|string[] $var */ - private static function prepareForRegex(array|string $var): string + private function prepareForRegex(array|string $var): string { if (\is_string($var)) { return preg_quote($var, '/'); @@ -95,7 +95,7 @@ private static function prepareForRegex(array|string $var): string return '('.implode('|', $var).')'; } - private static function isWebLink(string $url): bool + private function isWebLink(string $url): bool { return (bool) \Safe\preg_match('@^((?:(http:|https:)//([\wà-üÀ-Ü-]+\.)+[\w-]+){0,1}(/?[\wà-üÀ-Ü~,;\-\./?%&+#=]*))$@', $url); } @@ -105,7 +105,7 @@ private static function isWebLink(string $url): bool */ private function getLinkedDocs(): array { - $urlInAttributes = ' '.self::prepareForRegex(['href', 'data-rot', 'src', 'data-img', 'data-bg']); + $urlInAttributes = ' '.$this->prepareForRegex(['href', 'data-rot', 'src', 'data-img', 'data-bg']); $regex = '/'.$urlInAttributes.'=((["\'])([^\3]+)\3|([^\s>]+)[\s>])/iU'; \Safe\preg_match_all($regex, $this->pageHtml, $matches); @@ -115,9 +115,9 @@ private function getLinkedDocs(): array $uri = $matches[4][$k] ?? $matches[5][$k]; $uri = 'data-rot' == $matches[1][$k] ? AppExtension::decrypt($uri) : $uri; $uri .= $matches[4][$k] ? '' : '#(encrypt)'; // not elegant but permit to remember it's an encrypted link - if (self::isMailtoOrTelLink($uri) && 'data-rot' != $matches[1][$k]) { + if ($this->isMailtoOrTelLink($uri) && 'data-rot' != $matches[1][$k]) { $this->addError(''.$uri.' '.$this->trans('page_scan.encrypt_mail')); - } elseif ('' !== $uri && self::isWebLink($uri)) { + } elseif ('' !== $uri && $this->isWebLink($uri)) { $linkedDocs[] = $uri; } } @@ -125,7 +125,7 @@ private function getLinkedDocs(): array return array_unique($linkedDocs); } - private static function isMailtoOrTelLink(string $uri): bool + private function isMailtoOrTelLink(string $uri): bool { return str_contains($uri, 'tel:') || str_contains($uri, 'mailto:'); } diff --git a/packages/page-scanner/tests/PageScannerCommandTest.php b/packages/page-scanner/tests/PageScannerCommandTest.php index 64817637c..938e01ede 100755 --- a/packages/page-scanner/tests/PageScannerCommandTest.php +++ b/packages/page-scanner/tests/PageScannerCommandTest.php @@ -19,6 +19,6 @@ public function testPageScannerCommand() // the output of the command in the console $output = $commandTester->getDisplay(); - $this->assertTrue(false !== strpos($output, 'done...')); + $this->assertTrue(str_contains($output, 'done...')); } } diff --git a/packages/page-update-notifier/src/PageUpdateNotifier.php b/packages/page-update-notifier/src/PageUpdateNotifier.php index f39defe57..0ddce2516 100755 --- a/packages/page-update-notifier/src/PageUpdateNotifier.php +++ b/packages/page-update-notifier/src/PageUpdateNotifier.php @@ -89,10 +89,10 @@ protected function getPageUpdatedSince(\DateTimeInterface $datetime) protected function init(PageInterface $page): void { $this->app = $this->apps->get($page->getHost()); - $this->emailFrom = \strval($this->app->get('page_update_notification_from')); - $this->emailTo = \strval($this->app->get('page_update_notification_to')); - $this->interval = \strval($this->app->get('page_update_notification_interval')); - $this->appName = \strval($this->app->get('name')); + $this->emailFrom = \strval($this->app->getStr('page_update_notification_from')); + $this->emailTo = \strval($this->app->getStr('page_update_notification_to')); + $this->interval = \strval($this->app->getStr('page_update_notification_interval')); + $this->appName = \strval($this->app->getStr('name')); } protected function checkConfig(PageInterface $page): void diff --git a/packages/skeleton/config/bundles.php b/packages/skeleton/config/bundles.php index a0726b833..5a2f3c9a1 100755 --- a/packages/skeleton/config/bundles.php +++ b/packages/skeleton/config/bundles.php @@ -49,6 +49,7 @@ // Used for tests Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true, 'test'=>true], Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true], + Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true], // No need for testing purpose, useful else //Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], diff --git a/packages/skeleton/config/packages/dev/web_profiler.yaml b/packages/skeleton/config/packages/dev/web_profiler.yaml index e92166a7f..0c9d54b3d 100755 --- a/packages/skeleton/config/packages/dev/web_profiler.yaml +++ b/packages/skeleton/config/packages/dev/web_profiler.yaml @@ -4,3 +4,6 @@ web_profiler: framework: profiler: { only_exceptions: false } + +debug: + dump_destination: "tcp://%env(VAR_DUMPER_SERVER)%" \ No newline at end of file diff --git a/packages/skeleton/var/app.db b/packages/skeleton/var/app.db index 70f187bab..5b0811c5d 100644 Binary files a/packages/skeleton/var/app.db and b/packages/skeleton/var/app.db differ diff --git a/packages/static-generator/src/DependencyInjection/Configuration.php b/packages/static-generator/src/DependencyInjection/Configuration.php index 3b0c9e9ab..e4700b9d3 100755 --- a/packages/static-generator/src/DependencyInjection/Configuration.php +++ b/packages/static-generator/src/DependencyInjection/Configuration.php @@ -9,6 +9,7 @@ use Pushword\StaticGenerator\Generator\MediaGenerator; use Pushword\StaticGenerator\Generator\PagesGenerator; use Pushword\StaticGenerator\Generator\RobotsGenerator; +use Pushword\StaticGenerator\Helper; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; @@ -74,7 +75,7 @@ public function getConfigTreeBuilder(): TreeBuilder ->defaultValue('%kernel.project_dir%/%main_host%') ->info('If null or empty, static dir will be %kernel.project_dir%/host.tld/.') ->validate() - ->ifTrue(static fn ($value): bool => ! self::isAbsolutePath($value)) + ->ifTrue(static fn ($value): bool => ! Helper::isAbsolutePath($value)) ->thenInvalid('Invalid static dir path `%s`, it must be absolute (eg: /home/pushword/host.tld/)') ->end() ->end() @@ -86,9 +87,4 @@ public function getConfigTreeBuilder(): TreeBuilder return $treeBuilder; } - - private static function isAbsolutePath(string $path): bool - { - return '' !== $path && (\in_array($path[0], [\DIRECTORY_SEPARATOR, '%'], true) || 1 === \Safe\preg_match('#\A[A-Z]:(?![^/\\\\])#i', $path)); - } } diff --git a/packages/static-generator/src/Generator/AbstractGenerator.php b/packages/static-generator/src/Generator/AbstractGenerator.php index 02fe02c95..9ea9ae39c 100755 --- a/packages/static-generator/src/Generator/AbstractGenerator.php +++ b/packages/static-generator/src/Generator/AbstractGenerator.php @@ -4,7 +4,6 @@ use Pushword\Core\Component\App\AppConfig; use Pushword\Core\Component\App\AppPool; -use Pushword\Core\Entity\PageInterface as Page; use Pushword\Core\Repository\PageRepository; use Pushword\Core\Router\RouterInterface; use Pushword\Core\Utils\GenerateLivePathForTrait; @@ -58,12 +57,12 @@ public function __construct( $newKernelRouter->setUseCustomHostPath(false); } - public function generate(?string $host = null): void + public function generate(string $host = null): void { $this->init($host); } - protected function init(?string $host = null): void + protected function init(string $host = null): void { $this->app = null !== $host ? $this->apps->switchCurrentApp($host)->get() : $this->apps->get(); } @@ -90,7 +89,7 @@ protected function copy(string $file): void protected function getStaticDir(): string { - return \strval($this->app->get('static_dir')); + return $this->app->getStr('static_dir'); } protected function getPageRepository(): PageRepository diff --git a/packages/static-generator/src/Generator/CNAMEGenerator.php b/packages/static-generator/src/Generator/CNAMEGenerator.php index 0fc54b0dd..491fbbf3e 100755 --- a/packages/static-generator/src/Generator/CNAMEGenerator.php +++ b/packages/static-generator/src/Generator/CNAMEGenerator.php @@ -4,7 +4,7 @@ class CNAMEGenerator extends AbstractGenerator { - public function generate(?string $host = null): void + public function generate(string $host = null): void { parent::generate($host); diff --git a/packages/static-generator/src/Generator/CopierGenerator.php b/packages/static-generator/src/Generator/CopierGenerator.php index 8225d3b3d..38c19b3a7 100755 --- a/packages/static-generator/src/Generator/CopierGenerator.php +++ b/packages/static-generator/src/Generator/CopierGenerator.php @@ -4,7 +4,7 @@ class CopierGenerator extends AbstractGenerator { - public function generate(?string $host = null): void + public function generate(string $host = null): void { parent::generate($host); diff --git a/packages/static-generator/src/Generator/ErrorPageGenerator.php b/packages/static-generator/src/Generator/ErrorPageGenerator.php index b1e9c20aa..aa4c5fae2 100755 --- a/packages/static-generator/src/Generator/ErrorPageGenerator.php +++ b/packages/static-generator/src/Generator/ErrorPageGenerator.php @@ -6,7 +6,7 @@ class ErrorPageGenerator extends AbstractGenerator { - public function generate(?string $host = null): void + public function generate(string $host = null): void { parent::generate($host); @@ -23,7 +23,7 @@ public function generate(?string $host = null): void } // TODO : make it useful when using a .htaccess else disable it - protected function generateErrorPage(?string $locale = null, string $uri = '404.html'): void + protected function generateErrorPage(string $locale = null, string $uri = '404.html'): void { $request = $this->requestStack->getCurrentRequest(); if (! $request instanceof \Symfony\Component\HttpFoundation\Request) { diff --git a/packages/static-generator/src/Generator/GeneratorInterface.php b/packages/static-generator/src/Generator/GeneratorInterface.php index 11df9ccc1..fbdc01b95 100755 --- a/packages/static-generator/src/Generator/GeneratorInterface.php +++ b/packages/static-generator/src/Generator/GeneratorInterface.php @@ -6,7 +6,7 @@ interface GeneratorInterface { - public function generate(?string $host = null): void; + public function generate(string $host = null): void; public function setStaticAppGenerator(StaticAppGenerator $staticAppGenerator): self; } diff --git a/packages/static-generator/src/Generator/HtaccessGenerator.php b/packages/static-generator/src/Generator/HtaccessGenerator.php index f7b87c045..4e4517e3f 100755 --- a/packages/static-generator/src/Generator/HtaccessGenerator.php +++ b/packages/static-generator/src/Generator/HtaccessGenerator.php @@ -4,7 +4,7 @@ class HtaccessGenerator extends PageGenerator { - public function generate(?string $host = null): void + public function generate(string $host = null): void { $this->init($host); diff --git a/packages/static-generator/src/Generator/MediaGenerator.php b/packages/static-generator/src/Generator/MediaGenerator.php index c3257f4b3..bcc81d538 100755 --- a/packages/static-generator/src/Generator/MediaGenerator.php +++ b/packages/static-generator/src/Generator/MediaGenerator.php @@ -4,7 +4,7 @@ class MediaGenerator extends AbstractGenerator { - public function generate(?string $host = null): void + public function generate(string $host = null): void { parent::generate($host); diff --git a/packages/static-generator/src/Generator/PageGenerator.php b/packages/static-generator/src/Generator/PageGenerator.php index 1d55a5b8d..8ea9fc704 100755 --- a/packages/static-generator/src/Generator/PageGenerator.php +++ b/packages/static-generator/src/Generator/PageGenerator.php @@ -14,7 +14,7 @@ class PageGenerator extends AbstractGenerator #[\Symfony\Contracts\Service\Attribute\Required] public RedirectionManager $redirectionManager; - public function generate(?string $host = null): void + public function generate(string $host = null): void { parent::generate($host); @@ -36,7 +36,7 @@ public function generatePage(Page $page): void $this->generateFeedFor($page); } - protected function generateFilePath(Page $page, ?int $pager = null): string + protected function generateFilePath(Page $page, int $pager = null): string { $slug = '' == $page->getRealSlug() ? 'index' : $page->getRealSlug(); @@ -69,7 +69,7 @@ protected function generateFeedFor(Page $page): void $this->saveAsStatic($liveUri, $staticFile, $page); } - protected function saveAsStatic(string $liveUri, string $destination, ?Page $page = null): void + protected function saveAsStatic(string $liveUri, string $destination, Page $page = null): void { $request = Request::create($liveUri); // $request->headers->set('host', $this->app->getMainHost()); @@ -110,7 +110,7 @@ protected function saveAsStatic(string $liveUri, string $destination, ?Page $pag $this->filesystem->dumpFile($destination, $content); } - private function setErrorFor(string $liveUri, ?Page $page = null, string $msg = ''): void + private function setErrorFor(string $liveUri, Page $page = null, string $msg = ''): void { $identifier = null !== $page && class_exists(PushwordAdminBundle::class) ? '['.$liveUri.']('.$this->router->getRouter()->generate('admin_app_page_edit', ['id' => $page->getId()]).')' @@ -126,7 +126,7 @@ private function responseIsHtml(Response $response): bool private function extractPager(Page $page, string $content): void { - \Safe\preg_match('##', $content, $match); + \Safe\preg_match('##', $content, $match); $pager = (int) $match[1]; $this->saveAsStatic(rtrim($this->generateLivePathFor($page), '/').'/'.$pager, $this->generateFilePath($page, $pager), $page); } diff --git a/packages/static-generator/src/Generator/PagesGenerator.php b/packages/static-generator/src/Generator/PagesGenerator.php index eb39debd0..bc77e18e9 100755 --- a/packages/static-generator/src/Generator/PagesGenerator.php +++ b/packages/static-generator/src/Generator/PagesGenerator.php @@ -4,7 +4,7 @@ class PagesGenerator extends PageGenerator { - public function generate(?string $host = null): void + public function generate(string $host = null): void { parent::generate($host); @@ -16,7 +16,7 @@ public function generate(?string $host = null): void } } - public function generatePageBySlug(string $slug, ?string $host = null): void + public function generatePageBySlug(string $slug, string $host = null): void { parent::generate($host); diff --git a/packages/static-generator/src/Generator/RobotsGenerator.php b/packages/static-generator/src/Generator/RobotsGenerator.php index b6afba5f5..c13e4b0fa 100755 --- a/packages/static-generator/src/Generator/RobotsGenerator.php +++ b/packages/static-generator/src/Generator/RobotsGenerator.php @@ -4,7 +4,7 @@ class RobotsGenerator extends PageGenerator { - public function generate(?string $host = null): void + public function generate(string $host = null): void { parent::generate($host); diff --git a/packages/static-generator/src/Helper.php b/packages/static-generator/src/Helper.php new file mode 100644 index 000000000..542910096 --- /dev/null +++ b/packages/static-generator/src/Helper.php @@ -0,0 +1,11 @@ +apps->getHosts() as $host) { @@ -64,7 +64,7 @@ private function generateHost(string $host): void { $app = $this->apps->switchCurrentApp($host)->get(); - $staticDir = \strval($app->get('static_dir')); + $staticDir = \strval($app->getStr('static_dir')); $app->staticDir = $staticDir.'~'; // @phpstan-ignore-line $filesystem = new Filesystem(); @@ -72,7 +72,10 @@ private function generateHost(string $host): void $filesystem->mkdir($staticDir.'~'); foreach ($app->get('static_generators') as $generator) { // @phpstan-ignore-line - $this->getGenerator(\strval($generator))->generate(); + if (! \is_string($generator)) { + throw new \LogicException(); + } + $this->getGenerator($generator)->generate(); } if (! $this->abortGeneration) { diff --git a/packages/static-generator/src/StaticController.php b/packages/static-generator/src/StaticController.php index b969cf63d..2e8425e2e 100755 --- a/packages/static-generator/src/StaticController.php +++ b/packages/static-generator/src/StaticController.php @@ -9,7 +9,7 @@ class StaticController extends AbstractController { #[IsGranted('ROLE_PUSHWORD_ADMIN')] - public function generateStatic(StaticAppGenerator $staticAppGenerator, ?string $host = null): Response + public function generateStatic(StaticAppGenerator $staticAppGenerator, string $host = null): Response { exec('cd ../ && php bin/console pushword:static:generate '.$host.' > /dev/null 2>/dev/null &'); // $staticAppGenerator->generate($host); // TODO : fixed why it's logged me out diff --git a/packages/static-generator/tests/StaticGeneratorTest.php b/packages/static-generator/tests/StaticGeneratorTest.php index 77706a2ac..841620430 100755 --- a/packages/static-generator/tests/StaticGeneratorTest.php +++ b/packages/static-generator/tests/StaticGeneratorTest.php @@ -38,7 +38,7 @@ public function testStaticCommand() // the output of the command in the console $output = $commandTester->getDisplay(); - $this->assertTrue(false !== strpos($output, 'success')); + $this->assertTrue(str_contains($output, 'success')); $this->assertTrue(file_exists(__DIR__.'/../../skeleton/localhost.dev/.htaccess')); $this->assertTrue(file_exists(__DIR__.'/../../skeleton/localhost.dev/index.html')); diff --git a/packages/svg/src/TwigExtension.php b/packages/svg/src/TwigExtension.php index 3e4c93cc7..847773903 100755 --- a/packages/svg/src/TwigExtension.php +++ b/packages/svg/src/TwigExtension.php @@ -58,10 +58,10 @@ public function getSvg(string $name, array $attr = ['class' => 'fill-current w-4 throw new \Exception('`'.$name.'` seems not be a valid svg file.'); } - return self::replaceOnce('replaceOnce('templateDir = $realPathTemplateDir; if (null !== $path) { - $this->path = self::normalizePath($path); + $this->path = $this->normalizePath($path); } $this->code = $this->loadCode(); @@ -60,7 +60,7 @@ public function getEncodedPath(): string return md5($this->path); } - private static function normalizePath(string $path): string + private function normalizePath(string $path): string { return '/'.ltrim($path, '/'); } @@ -71,7 +71,7 @@ public function setPath(string $path): self throw new \Exception("You can't do that..."); } - $path = self::normalizePath($path); + $path = $this->normalizePath($path); if (null === $this->path) { $this->path = $path; diff --git a/packages/template-editor/src/ElementAdmin.php b/packages/template-editor/src/ElementAdmin.php index b6040e87b..3b79611df 100755 --- a/packages/template-editor/src/ElementAdmin.php +++ b/packages/template-editor/src/ElementAdmin.php @@ -68,7 +68,7 @@ private function clearTwigCache(): void } } - public function editElement(?string $encodedPath = null, Request $request = null): Response + public function editElement(string $encodedPath = null, Request $request = null): Response { $element = $this->getElement($encodedPath); diff --git a/packages/version/composer.json b/packages/version/composer.json index e2aa85532..aa34fe470 100755 --- a/packages/version/composer.json +++ b/packages/version/composer.json @@ -7,7 +7,7 @@ "license": "MIT", "require": { "pushword/core": "^0.0", - "symfony/serializer": "6.2.*" + "symfony/serializer": "6.3.*" }, "extra": { "branch-alias": { diff --git a/packages/version/src/Versionner.php b/packages/version/src/Versionner.php index 25c20820d..e1ef544ef 100755 --- a/packages/version/src/Versionner.php +++ b/packages/version/src/Versionner.php @@ -93,7 +93,7 @@ public function loadVersion(string $pageId, string $version): void static::$version = true; } - public function populate(PageInterface $page, string $version, ?int $pageId = null): PageInterface + public function populate(PageInterface $page, string $version, int $pageId = null): PageInterface { $pageVersionned = $this->getPageVersion($pageId ?? $page, $version); @@ -138,7 +138,7 @@ private function getVersionDir(int|PageInterface $page): string return $this->logDir.'/version/'.$pageId; } - private function getVersionFile(int|PageInterface $page, ?string $version = null): string + private function getVersionFile(int|PageInterface $page, string $version = null): string { return $this->getVersionDir($page).'/'.($version ?? uniqid()); }