Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinDev committed Nov 12, 2021
1 parent 7d5c721 commit 14ac461
Show file tree
Hide file tree
Showing 51 changed files with 68 additions and 185 deletions.
Expand Up @@ -24,10 +24,7 @@ class Configuration implements ConfigurationInterface
*/
public const DEFAULT_TYPE_TO_PROSE = ['paragraph', 'image', 'list', 'blockquote', 'code', 'delimiter', 'header'];

/**
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('admin_block_editor');
$treeBuilder->getRootNode()->children()
Expand Down
Expand Up @@ -62,10 +62,7 @@ public function replaceFields(FormEvent $formEvent): void
$page->jsMainContent = $this->transformMainContent($page->getMainContent());
}

/**
* @return string
*/
private function transformMainContent(string $content)
private function transformMainContent(string $content): string
{
// We never come to false here because we ever checked before with mayUseEditorBlock
/*
Expand Down
4 changes: 1 addition & 3 deletions packages/admin-block-editor/src/Form/EditorjsType.php
Expand Up @@ -8,10 +8,8 @@ class EditorjsType extends TextType
{
/**
* {@inheritdoc}
*
* @return string
*/
public function getBlockPrefix()
public function getBlockPrefix(): string
{
return 'editorjs';
}
Expand Down
5 changes: 1 addition & 4 deletions packages/admin/src/DependencyInjection/Configuration.php
Expand Up @@ -84,10 +84,7 @@ class Configuration implements ConfigurationInterface
[MediaPreviewField::class],
];

/**
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('pushword_admin');
$treeBuilder
Expand Down
5 changes: 1 addition & 4 deletions packages/admin/src/FormField/PageSlugField.php
Expand Up @@ -8,10 +8,7 @@

class PageSlugField extends AbstractField
{
/**
* @return string
*/
protected function getSlugHelp()
protected function getSlugHelp(): string
{
if ('' === $this->admin->getSubject()->getSlug()) {
return 'admin.page.slug.help';
Expand Down
Expand Up @@ -14,10 +14,7 @@ class Configuration implements ConfigurationInterface
'advanced_main_image',
];

/**
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('admin_block_editor');
$treeBuilder->getRootNode()->children()
Expand Down
2 changes: 1 addition & 1 deletion packages/advanced-main-image/src/Twig/AppExtension.php
Expand Up @@ -11,7 +11,7 @@ class AppExtension extends AbstractExtension
/**
* @return \Twig\TwigFunction[]
*/
public function getFunctions()
public function getFunctions(): array
{
return [
new TwigFunction('heroSize', [PageAdvancedMainImageFormField::class, 'formatToRatio']),
Expand Down
5 changes: 1 addition & 4 deletions packages/conversation/src/Command/NotificationCommand.php
Expand Up @@ -29,10 +29,7 @@ protected function configure(): void
;
}

/**
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
if (true === $this->notifier->send()) {
$output->writeln('Notification sent with success.');
Expand Down
Expand Up @@ -77,10 +77,8 @@ private function getFormManagerClass(string $type)

/**
* Return current form manager depending on `type` (request).
*
* @return object
*/
private function getFormManager(string $type, Request $request)
private function getFormManager(string $type, Request $request): object
{
if (null !== $this->form) {
return $this->form;
Expand Down
Expand Up @@ -25,10 +25,7 @@ class Configuration implements ConfigurationInterface
'possible_origins',
];

/**
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('conversation');
$treeBuilder
Expand Down
Expand Up @@ -12,10 +12,7 @@ class PushwordConversationExtension extends ConfigurableExtension implements Pre

private $configFolder = __DIR__.'/../Resources/config';

/**
* @return string
*/
public function getAlias()
public function getAlias(): string
{
return 'conversation';
}
Expand Down
16 changes: 4 additions & 12 deletions packages/conversation/src/Entity/Message.php
Expand Up @@ -107,10 +107,8 @@ public function getAuthorName(): ?string

/**
* Set the value of authorName.
*
* @return self
*/
public function setAuthorName(?string $authorName)
public function setAuthorName(?string $authorName): self
{
$this->authorName = $authorName;

Expand All @@ -129,10 +127,8 @@ public function getAuthorEmail(): ?string

/**
* Set the value of authorEmail.
*
* @return self
*/
public function setAuthorEmail(?string $authorEmail)
public function setAuthorEmail(?string $authorEmail): self
{
$this->authorEmail = $authorEmail;

Expand All @@ -153,10 +149,8 @@ public function getReferring(): ?string
* Set identifier referring.
*
* @param string $from Identifier referring
*
* @return self
*/
public function setReferring(string $referring)
public function setReferring(string $referring): self
{
$this->referring = $referring;

Expand All @@ -173,10 +167,8 @@ public function getAuthorIp(): ?int

/**
* Set the value of authorIp.
*
* @return self
*/
public function setAuthorIp(?int $authorIp)
public function setAuthorIp(?int $authorIp): self
{
if (null !== $authorIp) {
$this->authorIp = $authorIp;
Expand Down
5 changes: 1 addition & 4 deletions packages/conversation/src/PushwordConversationBundle.php
Expand Up @@ -7,10 +7,7 @@

class PushwordConversationBundle extends Bundle
{
/**
* @return \Pushword\Conversation\DependencyInjection\PushwordConversationExtension|null
*/
public function getContainerExtension()
public function getContainerExtension(): ?PushwordConversationExtension
{
if (null === $this->extension) {
$this->extension = new PushwordConversationExtension();
Expand Down
2 changes: 1 addition & 1 deletion packages/conversation/src/Twig/AppExtension.php
Expand Up @@ -35,7 +35,7 @@ public function __construct(EntityManagerInterface $entityManager, string $messa
/**
* @return \Twig\TwigFunction[]
*/
public function getFunctions()
public function getFunctions(): array
{
return [
new TwigFunction('showConversation', function (Twig $twig, string $referring, string $orderBy, $limit, string $view): string {
Expand Down
5 changes: 1 addition & 4 deletions packages/core/src/Command/ImageManagerCommand.php
Expand Up @@ -20,10 +20,7 @@ protected function configure(): void
->addArgument('media', InputArgument::OPTIONAL, 'Image name (eg: filename.jpg).');
}

/**
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$medias = $this->getMedias($input);

Expand Down
5 changes: 1 addition & 4 deletions packages/core/src/Command/ImageOptimizerCommand.php
Expand Up @@ -20,10 +20,7 @@ protected function configure(): void
->addArgument('media', InputArgument::OPTIONAL, 'Image name (eg: filename.jpg).');
}

/**
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$medias = $this->getMedias($input);

Expand Down
5 changes: 1 addition & 4 deletions packages/core/src/Command/NewCommand.php
Expand Up @@ -27,10 +27,7 @@ protected function configure(): void
$this->setDescription('Add a new website into your config file (config/packages/pushword.yaml).');
}

/**
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$configFile = $this->projectDir.'/config/packages/pushword.yaml';

Expand Down
5 changes: 1 addition & 4 deletions packages/core/src/Command/UserCreateCommand.php
Expand Up @@ -61,10 +61,7 @@ protected function createUser(string $email, string $password, string $role): vo
$this->em->flush();
}

/**
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$email = $this->getOrAskIfNotSetted($input, $output, 'email');
$password = $this->getOrAskIfNotSetted($input, $output, 'password');
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/Component/App/AppConfig.php
Expand Up @@ -86,10 +86,8 @@ public function getMainHost(): string

/**
* Used in Router Extension.
*
* @return bool
*/
public function isMainHost(?string $host)
public function isMainHost(?string $host): bool
{
return $this->getMainHost() === $host;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/Component/EntityFilter/Filter/ElseH1.php
Expand Up @@ -11,7 +11,7 @@ class ElseH1 extends AbstractFilter
use RequiredManagerTrait;

/** @return ?string */
public function apply($propertyValue)
public function apply($propertyValue): ?string
{
return '' !== \strval($propertyValue) ? $propertyValue : $this->entityFilterManager->getEntity()->getH1();
}
Expand Down
Expand Up @@ -27,10 +27,7 @@ class MainContentSplitter extends AbstractFilter
/** @var string[] */
private array $contentParts = [];

/**
* @return self
*/
public function apply($propertyValue)
public function apply($propertyValue): self
{
$this->split(\strval($propertyValue));

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/Component/EntityFilter/Filter/Name.php
Expand Up @@ -11,7 +11,7 @@ class Name extends AbstractFilter
use RequiredManagerTrait;

/** @return ?string */
public function apply($propertyValue)
public function apply($propertyValue): ?string
{
$names = explode("\n", \strval($propertyValue));

Expand Down
5 changes: 1 addition & 4 deletions packages/core/src/Component/EntityFilter/Filter/Unprose.php
Expand Up @@ -22,10 +22,7 @@ class Unprose extends AbstractFilter
use RequiredEntityTrait;
use UnproseTwigTrait;

/**
* @return string
*/
public function apply($propertyValue)
public function apply($propertyValue): string
{
$closeEncryptedTag = $this->encryptTag('div');
$openEncryptedTag = $this->encryptTag('/div');
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/Component/EntityFilter/Manager.php
Expand Up @@ -82,11 +82,11 @@ private function filter(string $property, $propertyValue)
{
$filters = $this->getFilters($this->camelCaseToSnakeCase($property));

if (null === $filters && \is_string($propertyValue)) {
if ([] === $filters && \is_string($propertyValue)) {
$filters = $this->getFilters('string');
}

return null !== $filters
return [] !== $filters
? $this->applyFilters($property, '' !== \strval($propertyValue) ? $propertyValue : '', $filters)
: $propertyValue;
}
Expand All @@ -97,7 +97,7 @@ private function camelCaseToSnakeCase(string $string): string
}

/** @return string[] */
private function getFilters(string $label): ?array
private function getFilters(string $label): array
{
if ($this->app->entityCanOverrideFilters() && $this->entity instanceof CustomPropertiesInterface) {
$filters = $this->entity->getCustomProperty($label.'_filters');
Expand All @@ -110,11 +110,11 @@ private function getFilters(string $label): ?array

$filters = \is_string($filters) ? explode(',', $filters) : $filters;

return $filters ? $filters : null; // @phpstan-ignore-line
return $filters ? $filters : []; // @phpstan-ignore-line
}

/**
* @return false|class-string<FilterInterface>
* @return false|class-string
*/
private function isFilter(string $className)
{
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/Controller/PageController.php
Expand Up @@ -209,7 +209,7 @@ public function setApp($host): void
* @psalm-suppress NullableReturnStatement
* @psalm-suppress InvalidNullableReturnType
*/
private function getPageElse404(Request $request, ?string &$slug, string $host, bool $extractPager = false): Page
private function getPageElse404(Request $request, ?string &$slug, string $host, bool $extractPager = false): ?PageInterface
{
return $this->getPage($request, $slug, $host, true, $extractPager); // @phpstan-ignore-line
}
Expand Down
5 changes: 1 addition & 4 deletions packages/core/src/DependencyInjection/Configuration.php
Expand Up @@ -131,10 +131,7 @@ final class Configuration implements ConfigurationInterface
],
];

/**
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('pushword');
$treeBuilder->getRootNode()->children()
Expand Down
Expand Up @@ -40,10 +40,7 @@ private function setPathParameters(ContainerBuilder $containerBuilder): void
$containerBuilder->setParameter('pw.package_dir', '%kernel.project_dir%/..');
}

/**
* @return string
*/
public function getAlias()
public function getAlias(): string
{
return 'pushword';
}
Expand Down
5 changes: 1 addition & 4 deletions packages/core/src/PushwordCoreBundle.php
Expand Up @@ -7,10 +7,7 @@

final class PushwordCoreBundle extends Bundle
{
/**
* @return \Pushword\Core\DependencyInjection\PushwordCoreExtension|null
*/
public function getContainerExtension()
public function getContainerExtension(): ?PushwordCoreExtension
{
if (null === $this->extension) {
$this->extension = new PushwordCoreExtension();
Expand Down
5 changes: 1 addition & 4 deletions packages/core/src/Router/Router.php
Expand Up @@ -90,10 +90,7 @@ public function generate($slug = 'homepage', bool $canonical = false, $pager = n
return $url;
}

/**
* @return bool
*/
private function mayUseCustomPath()
private function mayUseCustomPath(): bool
{
return $this->useCustomHostPath
&& $this->currentHost // we have a request
Expand Down

0 comments on commit 14ac461

Please sign in to comment.