Skip to content

Commit

Permalink
Update PHPStan and Psalm config
Browse files Browse the repository at this point in the history
  • Loading branch information
emodric committed Mar 17, 2023
1 parent 9019100 commit 6daf5b3
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public function provideViewTypes(?Block $block = null): array
continue;
}

/** @var array<string, mixed[]> $contentView */
$contentView = $this->configResolver->getParameter($this->configResolverParameterName, null, $siteAccess);

foreach ($contentView as $view => $viewConfigList) {
Expand All @@ -87,10 +88,13 @@ public function provideViewTypes(?Block $block = null): array
$validViews[$view] = $view;
$validParameters[$view] ??= null;

if (is_array($viewConfig['params']['valid_parameters'] ?? null)) {
/** @var array<string>|null $viewConfigValidParameters */
$viewConfigValidParameters = $viewConfig['params']['valid_parameters'] ?? null;

if (is_array($viewConfigValidParameters)) {
$validParameters[$view] = is_array($validParameters[$view]) ?
array_merge($validParameters[$view], $viewConfig['params']['valid_parameters']) :
$viewConfig['params']['valid_parameters'];
array_merge($validParameters[$view], $viewConfigValidParameters) :
$viewConfigValidParameters;
}
}
}
Expand Down
5 changes: 0 additions & 5 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ includes:
- vendor/phpstan/phpstan-symfony/rules.neon

parameters:
dynamicConstantNames:
- Symfony\Component\HttpKernel\Kernel::VERSION_ID

ignoreErrors:
# Symfony

Expand All @@ -28,5 +25,3 @@ parameters:
- "#Casting to (int|string) something that's already (int|string).#"

- '#EzSystems\\PlatformHttpCacheBundle\\RequestAwarePurger#'

- '#Parameter \#2 \$validParameters of method Netgen\\Layouts\\Ez\\Block\\BlockDefinition\\Configuration\\Provider\\EzPlatformConfigProvider::buildViewTypes#'
9 changes: 2 additions & 7 deletions phpstan.tests.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,13 @@ includes:
- vendor/phpstan/phpstan-phpunit/rules.neon

parameters:
treatPhpDocTypesAsCertain: false
dynamicConstantNames:
- Symfony\Component\HttpKernel\Kernel::VERSION_ID

ignoreErrors:
- '#Symfony\\Component\\Security\\Core\\Role\\Role#'

- '#Call to an undefined method Netgen\\Layouts\\Ez\\Security\\Role\\RoleHierarchy::getReachableRoles\(\).#'

# Disable errors about missing value types in PHPUnit data providers

- '#Method .+Test(Base)?::\w+DataProvider\(\) return type has no value type specified in iterable type array.#'

# Disable errors for various tests that verify arrays not having certain elements
- '#Call to static method PHPUnit\\Framework\\Assert::assertArrayHasKey\(\)#'
# Disable errors for various tests that verify the instance of the value
- '#Call to static method PHPUnit\\Framework\\Assert::assertInstanceOf\(\)#'
42 changes: 3 additions & 39 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,9 @@
<UndefinedInterfaceMethod>
<errorLevel type="suppress">
<referencedMethod name="Symfony\Component\Security\Core\Role\RoleHierarchyInterface::getReachableRoles" />
<referencedMethod name="Doctrine\DBAL\Driver\ResultStatement::fetchAllAssociative" />
</errorLevel>
</UndefinedInterfaceMethod>

<DuplicateArrayKey>
<errorLevel type="suppress">
<file name="bundle/DependencyInjection/ExtensionPlugin.php" />
</errorLevel>
</DuplicateArrayKey>

<UndefinedMethod>
<errorLevel type="suppress">
<referencedMethod name="Symfony\Component\Security\Core\Role\Role::getRole" />
Expand All @@ -41,25 +34,11 @@
</errorLevel>
</InternalClass>

<TooManyArguments>
<errorLevel type="suppress">
<referencedFunction name="Symfony\Component\Security\Core\Role\Role::__construct" />
</errorLevel>
</TooManyArguments>

<InternalMethod>
<errorLevel type="suppress">
<file name="lib/Security/Authorization/Voter/RepositoryAccessVoter.php" />
<referencedMethod name="Symfony\Component\Security\Core\Role\Role::__construct" />
</errorLevel>
</InternalMethod>

<InaccessibleMethod>
<PossiblyUndefinedMethod>
<errorLevel type="suppress">
<file name="lib/Security/Authorization/Voter/RepositoryAccessVoter.php" />
<referencedMethod name="Symfony\Component\Security\Core\Role\Role::__construct" />
<referencedMethod name="Symfony\Component\Config\Definition\Builder\NodeDefinition::addDefaultsIfNotSet" />
</errorLevel>
</InaccessibleMethod>
</PossiblyUndefinedMethod>

<!-- Doctrine DBAL -->

Expand All @@ -77,17 +56,10 @@

<!-- eZ Platform -->

<UndefinedDocblockClass>
<errorLevel type="suppress">
<referencedClass name="EzSystems\PlatformHttpCacheBundle\RequestAwarePurger" />
</errorLevel>
</UndefinedDocblockClass>

<UndefinedClass>
<errorLevel type="suppress">
<referencedClass name="EzSystems\PlatformHttpCacheBundle\RequestAwarePurger" />
<referencedClass name="eZ\Publish\SPI\FieldType\Nameable" />
<referencedClass name="Symfony\Component\Security\Core\Role\Role" />
</errorLevel>
</UndefinedClass>

Expand All @@ -96,13 +68,5 @@
<referencedMethod name="EzSystems\PlatformHttpCacheBundle\RepositoryTagPrefix::getRepositoryPrefix" />
</errorLevel>
</InternalMethod>

<!-- Symfony -->

<PossiblyUndefinedMethod>
<errorLevel type="suppress">
<referencedMethod name="Symfony\Component\Config\Definition\Builder\NodeDefinition::addDefaultsIfNotSet" />
</errorLevel>
</PossiblyUndefinedMethod>
</issueHandlers>
</psalm>
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public function testGetDynamicParameters(): void

$this->handler->getDynamicParameters($params, new Block());

self::assertArrayHasKey('content', $params);
self::assertArrayHasKey('location', $params);
self::assertTrue($params->offsetExists('content'));
self::assertTrue($params->offsetExists('location'));

self::assertSame($content, $params['content']);
self::assertSame($location, $params['location']);
Expand Down

0 comments on commit 6daf5b3

Please sign in to comment.