Skip to content

Commit

Permalink
Crank up phpstan to level 9
Browse files Browse the repository at this point in the history
  • Loading branch information
luispabon committed Feb 8, 2022
1 parent 31c7968 commit 71eebd3
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ composer-cache-dir:
@composer config cache-files-dir

static-analysis:
$(PHP_RUN) vendor/bin/phpstan --ansi -v analyse -l 8 src
$(PHP_RUN) vendor/bin/phpstan --ansi -v analyse -l 9 src

unit-tests:
$(PHP_RUN) vendor/bin/phpunit --testdox --colors=always
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
parameters:
checkMissingIterableValueType: false
ignoreErrors:
- '#Access to an undefined property Symfony\\Component\\Validator\\Constraint::\$message#'
2 changes: 1 addition & 1 deletion src/Assert/PostgresTypeValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class PostgresTypeValidator extends ConstraintValidator
*/
public function validate(mixed $value, Constraint|PostgresType $constraint): void
{
if ($value !== null && array_key_exists($value, Postgres::getChoices()) === false) {
if ($value !== null && is_string($value) && array_key_exists($value, Postgres::getChoices()) === false) {
$this
->context
->buildViolation($constraint->message)
Expand Down
7 changes: 3 additions & 4 deletions src/Controller/GeneratorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ public function create(Request $request): BinaryFileResponse|Response
$form->handleRequest($request);

if ($form->isSubmitted() === true && $form->isValid() === true) {
$project = $this->hydrateProject($form->getData());
/** @var array $data */
$data = $form->getData();
$project = $this->hydrateProject($data);

// Generate zip file with docker project
$zipFile = $this->generator->generate($project);
Expand All @@ -68,9 +70,6 @@ public function create(Request $request): BinaryFileResponse|Response
]);
}

/**
* @param array<string, mixed> $formData
*/
private function hydrateProject(array $formData): Project
{
$phpData = $formData['phpOptions'];
Expand Down
1 change: 1 addition & 0 deletions src/Form/Generator/AbstractMySQLType.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
protected function getValidationGroups(): callable
{
return function (FormInterface $form) {
/** @var array<mixed> $data */
$data = $form->getData();
$groups = ['Default'];

Expand Down
1 change: 1 addition & 0 deletions src/Form/Generator/PostgresType.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
protected function getValidationGroups(): callable
{
return static function (FormInterface $form) {
/** @var array<mixed> $data */
$data = $form->getData();
$groups = ['Default'];

Expand Down
2 changes: 1 addition & 1 deletion src/PHPDocker/Generator/Files/PhpIni.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
class PhpIni implements GeneratedFileInterface
{

public function __construct(private Environment $twig, private Project $project)
public function __construct(private Environment $twig)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/PHPDocker/Generator/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function __construct(
public function generate(Project $project): ArchiveInterface
{
$readmeMd = new ReadmeMd($this->twig, $project);
$phpIni = new PhpIni($this->twig, $project);
$phpIni = new PhpIni($this->twig);

$this->archiver
->addFile($readmeMd)
Expand Down

0 comments on commit 71eebd3

Please sign in to comment.