Skip to content

Commit

Permalink
Update phpstan (sulu#308)
Browse files Browse the repository at this point in the history
* Update phpstan

* Fix phpstan issues

* Update with baseline
  • Loading branch information
alexander-schranz authored Dec 10, 2021
1 parent 31b54d4 commit a3e1665
Show file tree
Hide file tree
Showing 41 changed files with 1,866 additions and 100 deletions.
2 changes: 1 addition & 1 deletion Admin/DynamicListAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static function getPriority(): int
private $viewBuilderFactory;

/**
* @var array
* @var mixed[]
*/
private $config;

Expand Down
11 changes: 11 additions & 0 deletions Admin/FormAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,19 @@ class FormAdmin extends Admin
const EDIT_FORM_VIEW = 'sulu_form.edit_form';
const EDIT_FORM_DETAILS_VIEW = 'sulu_form.edit_form.details';

/**
* @var SecurityCheckerInterface
*/
private $securityChecker;

/**
* @var ViewBuilderFactoryInterface
*/
private $viewBuilderFactory;

/**
* @var WebspaceManagerInterface
*/
private $webspaceManager;

/**
Expand Down
26 changes: 12 additions & 14 deletions Command/FormGeneratorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,16 @@ public function __construct(
$this->webspaceManager = $webspaceManager;
}

protected function configure()
protected function configure(): void
{
$this->setDescription('Generates a form with all basic form types');
}

protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$form = $this->loadTestForm() ?: new Form();

/** @var non-empty-array<string> $locales */
$locales = $this->webspaceManager->getAllLocales();
$form->setDefaultLocale(current($locales));

Expand Down Expand Up @@ -115,11 +116,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
],
[
'type' => 'headline',
'width' => 'full',
],
[
'type' => 'freeText',
'width' => 'full',
],
[
'type' => 'function',
Expand Down Expand Up @@ -148,47 +147,39 @@ protected function execute(InputInterface $input, OutputInterface $output)
],
[
'type' => 'attachment',
'width' => 'full',
],
[
'type' => 'radioButtons',
'width' => 'full',
'options' => [
'choices' => $this->getChoices(),
],
],
[
'type' => 'checkboxMultiple',
'width' => 'full',
'options' => [
'choices' => $this->getChoices(),
],
],
[
'type' => 'dropdown',
'width' => 'full',
'options' => [
'choices' => $this->getChoices(),
],
],
[
'type' => 'dropdownMultiple',
'width' => 'full',
'options' => [
'choices' => $this->getChoices(),
],
],
[
'type' => 'checkbox',
'width' => 'full',
],
[
'type' => 'text',
'width' => 'full',
],
[
'type' => 'textarea',
'width' => 'full',
],
];

Expand Down Expand Up @@ -226,6 +217,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
return 0;
}

/**
* @param non-empty-array<string> $locales
* @param mixed[] $options
*/
private function addField(
Form $form,
array $locales,
Expand All @@ -235,7 +230,7 @@ private function addField(
string $width = 'full',
bool $required = false,
array $options = []
) {
): void {
$formField = $form->getField($fieldKey) ?: new FormField();
$formField->setForm($form);
$formField->setDefaultLocale(current($locales));
Expand Down Expand Up @@ -272,7 +267,10 @@ private function loadTestForm(): ?Form
}
}

private function getChoices()
/**
* @return string
*/
private function getChoices(): string
{
return
'Choice 1' . PHP_EOL .
Expand Down
3 changes: 3 additions & 0 deletions Configuration/FormConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ public function getFileSave(): bool
return $this->fileSave;
}

/**
* @return $this
*/
public function setFileSave(bool $fileSave)
{
$this->fileSave = $fileSave;
Expand Down
22 changes: 11 additions & 11 deletions Configuration/MailConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,27 @@ class MailConfiguration implements MailConfigurationInterface
private $subject;

/**
* @var string|array
* @var string|string[]
*/
private $from;

/**
* @var string|array
* @var string|string[]
*/
private $to = [];

/**
* @var string|array
* @var string|string[]
*/
private $cc = [];

/**
* @var string|array
* @var string|string[]
*/
private $bcc = [];

/**
* @var string|array
* @var string|string[]
*/
private $replyTo;

Expand All @@ -67,7 +67,7 @@ class MailConfiguration implements MailConfigurationInterface
private $plainTextTemplate;

/**
* @var array
* @var mixed[]
*/
private $templateAttributes;

Expand Down Expand Up @@ -110,7 +110,7 @@ public function getFrom()
/**
* Set from address.
*
* @param string|array $from
* @param string|string[] $from
*/
public function setFrom($from): self
{
Expand All @@ -130,7 +130,7 @@ public function getTo()
/**
* Set to addresses.
*
* @param string|array $to
* @param string|string[] $to
*/
public function setTo($to): self
{
Expand All @@ -150,7 +150,7 @@ public function getCc()
/**
* Set cc addresses.
*
* @param string|array $cc
* @param string|string[] $cc
*/
public function setCc($cc): self
{
Expand All @@ -170,7 +170,7 @@ public function getBcc()
/**
* Set bcc addresses.
*
* @param string|array $bcc
* @param string|string[] $bcc
*/
public function setBcc($bcc): self
{
Expand All @@ -190,7 +190,7 @@ public function getReplyTo()
/**
* Set reply to.
*
* @param string|array $replyTo
* @param string|string[] $replyTo
*/
public function setReplyTo($replyTo): self
{
Expand Down
10 changes: 5 additions & 5 deletions Configuration/MailConfigurationInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,35 @@ public function getSubject(): ?string;
/**
* Get from address.
*
* @return string|array
* @return string|string[]
*/
public function getFrom();

/**
* Get to addresses.
*
* @return string|array
* @return string|string[]
*/
public function getTo();

/**
* Get cc addresses.
*
* @return string|array
* @return string|string[]
*/
public function getCc();

/**
* Get bcc addresses.
*
* @return string|array
* @return string|string[]
*/
public function getBcc();

/**
* Get reply to.
*
* @return string|array
* @return string|string[]
*/
public function getReplyTo();

Expand Down
9 changes: 7 additions & 2 deletions Content/Types/SingleFormSelection.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Sulu\Component\Content\Compat\Structure\StructureBridge;
use Sulu\Component\Content\SimpleContentType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\Validator\Exception\MissingOptionsException;

/**
Expand Down Expand Up @@ -54,13 +55,15 @@ public function __construct(

/**
* {@inheritdoc}
*
* @return FormView|null
*/
public function getContentData(PropertyInterface $property)
{
$id = (int) $property->getValue();

if (!$id) {
return;
return null;
}

if (!isset($property->getParams()['resourceKey'])) {
Expand All @@ -85,7 +88,7 @@ public function getContentData(PropertyInterface $property)
$form = $this->loadShadowForm($property, $id, $resourceKey);

if (!$form) {
return;
return null;
}
}

Expand Down Expand Up @@ -117,6 +120,8 @@ private function loadShadowForm(PropertyInterface $property, int $id, string $ty

/**
* {@inheritdoc}
*
* @return mixed[]
*/
public function getViewData(PropertyInterface $property)
{
Expand Down
2 changes: 2 additions & 0 deletions Controller/FormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public function __construct(

/**
* {@inheritdoc}
*
* @return string
*/
public function getSecurityContext()
{
Expand Down
13 changes: 9 additions & 4 deletions Controller/FormWebsiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
class FormWebsiteController extends DefaultController
{
/**
* @var FormInterface
* @var FormInterface|null
*/
protected $form;

/**
* @var array
* @var mixed[]
*/
protected $attributes;

Expand Down Expand Up @@ -185,7 +185,7 @@ private function handleFormOnlySubmit(Request $request, AbstractType $type): ?Re
/**
* Get errors.
*
* @return array[]
* @return array<string, string[]>
*/
protected function getErrors(): array
{
Expand Down Expand Up @@ -217,14 +217,19 @@ protected function getErrors(): array

/**
* {@inheritdoc}
*
* @param mixed[] $attributes
* @param bool $preview
*
* @return mixed[]
*/
protected function getAttributes($attributes, StructureInterface $structure = null, $preview = false)
{
if (null === $this->attributes) { // for performance only called once
$this->attributes = parent::getAttributes($attributes, $structure, $preview);
}

if (!empty($this->form)) {
if ($this->form) {
$this->attributes['form'] = $this->form->createView();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

/**
* Add all available dynamic list builders to the factory.
*
* @internal
*/
class DynamicListBuilderCompilerPass implements CompilerPassInterface
{
Expand Down
3 changes: 3 additions & 0 deletions DependencyInjection/CompilerPass/ListProviderCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

/**
* @internal
*/
class ListProviderCompilerPass implements CompilerPassInterface
{
/**
Expand Down
Loading

0 comments on commit a3e1665

Please sign in to comment.