Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinDev committed Jun 20, 2023
1 parent 9c174a3 commit 02e3571
Show file tree
Hide file tree
Showing 90 changed files with 280 additions and 272 deletions.
43 changes: 22 additions & 21 deletions composer.json
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
5 changes: 1 addition & 4 deletions packages/admin-block-editor/src/Block/AbstractBlock.php
Expand Up @@ -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');

Expand Down
3 changes: 1 addition & 2 deletions packages/admin-block-editor/src/Block/BlockInterface.php
Expand Up @@ -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;

Expand Down
3 changes: 0 additions & 3 deletions packages/admin-block-editor/src/Form/EditorjsType.php
Expand Up @@ -6,9 +6,6 @@

class EditorjsType extends TextType
{
/**
* {@inheritdoc}
*/
public function getBlockPrefix(): string
{
return 'editorjs';
Expand Down
6 changes: 3 additions & 3 deletions packages/admin/src/Menu/PageMenuProvider.php
Expand Up @@ -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];
}
Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src/UserAdmin.php
Expand Up @@ -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);
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -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.");
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions packages/conversation/src/Form/FormTrait.php
Expand Up @@ -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;
Expand Down
10 changes: 4 additions & 6 deletions packages/conversation/src/Service/NewMessageMailNotifier.php
Expand Up @@ -24,8 +24,6 @@ class NewMessageMailNotifier
private readonly string $host;

/**
.
*
* @param class-string<MessageInterface> $message Entity
*/
public function __construct(
Expand All @@ -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();
}

Expand Down
44 changes: 22 additions & 22 deletions packages/core/composer.json
Expand Up @@ -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",
Expand All @@ -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"
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/Command/NewCommand.php
Expand Up @@ -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];

Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/Command/UserCreateCommand.php
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
10 changes: 4 additions & 6 deletions packages/core/src/Component/App/AppConfig.php
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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';
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/Component/App/AppPool.php
Expand Up @@ -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);
}
Expand Down
13 changes: 13 additions & 0 deletions packages/core/src/Component/EntityFilter/Filter/AbstractFilter.php
Expand Up @@ -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));
}
}
5 changes: 2 additions & 3 deletions packages/core/src/Component/EntityFilter/Filter/Date.php
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/Component/EntityFilter/Filter/Email.php
Expand Up @@ -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));
}

/**
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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);
}
Expand Down
Expand Up @@ -4,8 +4,5 @@

interface FilterInterface
{
/**
* @return mixed
*/
public function apply(mixed $propertyValue);
public function apply(mixed $propertyValue); // @phpstan-ignore-line
}
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/Component/EntityFilter/Filter/Image.php
Expand Up @@ -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));
}

/**
Expand Down

0 comments on commit 02e3571

Please sign in to comment.