Skip to content

Commit

Permalink
Merge pull request #952 from msmakouz/fix-psalm-issues
Browse files Browse the repository at this point in the history
Fixing Psalm issues
  • Loading branch information
butschster authored Jul 18, 2023
2 parents 0e4b58e + acf4dc8 commit 67a0200
Show file tree
Hide file tree
Showing 14 changed files with 9 additions and 22 deletions.
1 change: 0 additions & 1 deletion src/Cache/src/Bootloader/CacheBootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public function init(BinderInterface $binder, EnvironmentInterface $env, Directo
{
$this->initConfig($env, $dirs);

/** @psalm-suppress InvalidCast https://github.com/vimeo/psalm/issues/8810 */
$binder->bindInjector(CacheInterface::class, CacheInjector::class);
}

Expand Down
6 changes: 6 additions & 0 deletions src/Console/src/InputProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ public function getParameterOption(
return $this->input->getParameterOption($values, $default, $onlyParams);
}

/**
* Since v4.0 the return type will be changed to void {@see InputInterface::bind}.
*
* @return void
* @psalm-suppress InvalidReturnStatement
*/
public function bind(InputDefinition $definition): mixed
{
return $this->input->bind($definition);
Expand Down
5 changes: 0 additions & 5 deletions src/Core/src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ public function make(string $alias, array $parameters = [], string $context = nu
*
* @throws ContainerException
* @throws \Throwable
*
* @psalm-suppress InvalidArgument, InvalidCast
*/
public function get(string|Autowire $id, string $context = null): mixed
{
Expand Down Expand Up @@ -298,9 +296,6 @@ public function invoke(mixed $target, array $parameters = []): mixed

/**
* Bind class or class interface to the injector source (InjectorInterface).
*
* Todo: remove suppression after {@link https://github.com/vimeo/psalm/issues/8298} fixing.
* @psalm-suppress InvalidArgument,InvalidCast
*/
public function bindInjector(string $class, string $injector): void
{
Expand Down
1 change: 0 additions & 1 deletion src/Events/tests/Stub/PlainListenerRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

/**
* @internal
* @psalm-suppress MissingConstructor
*/
final class PlainListenerRegistry implements ListenerRegistryInterface
{
Expand Down
1 change: 0 additions & 1 deletion src/Framework/Bootloader/Security/FiltersBootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public function __construct(
*/
public function init(): void
{
/** @psalm-suppress InvalidCast https://github.com/vimeo/psalm/issues/8810 */
$this->binder->bindInjector(FilterInterface::class, self::class);

$this->config->setDefaults(
Expand Down
1 change: 0 additions & 1 deletion src/Queue/src/Bootloader/QueueBootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public function init(
$this->initQueueConfig($env);

$this->registerDriverAlias(SyncDriver::class, 'sync');
/** @psalm-suppress InvalidCast https://github.com/vimeo/psalm/issues/8810 */
$binder->bindInjector(QueueInterface::class, QueueInjector::class);

$kernel->booted(static function () use ($container): void {
Expand Down
1 change: 0 additions & 1 deletion src/Queue/src/Interceptor/Push/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public function callAction(

$tracer = $this->getTracer();

/** @psalm-suppress RedundantCondition */
if (\method_exists($parameters['options'], 'withHeader')) {
foreach ($tracer->getContext() as $key => $data) {
$parameters['options'] = $parameters['options']->withHeader($key, $data);
Expand Down
1 change: 0 additions & 1 deletion src/Router/src/UriHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ public function isCompiled(): bool
* @return Matches|null
*
* @psalm-external-mutation-free
* @psalm-suppress MoreSpecificReturnType, LessSpecificReturnStatement
*/
public function match(UriInterface $uri, array $defaults): ?array
{
Expand Down
2 changes: 0 additions & 2 deletions src/Scaffolder/src/Declaration/ConfigDeclaration.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
class ConfigDeclaration extends AbstractDeclaration implements HasInstructions
{
public const TYPE = 'config';
private bool $reverse = false;

public function __construct(
ScaffolderConfig $config,
Expand All @@ -41,7 +40,6 @@ public function __construct(

public function create(bool $reverse, string $configName): void
{
$this->reverse = $reverse;
$this->class->addConstant('CONFIG', $configName)->setPublic();

$filename = $this->makeConfigFilename($configName);
Expand Down
2 changes: 1 addition & 1 deletion src/Scaffolder/src/Declaration/HasInstructions.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
interface HasInstructions
{
/**
* @return non-empty-string[]
* @return array<int, non-empty-string>
*/
public function getInstructions(): array;
}
2 changes: 0 additions & 2 deletions src/Tokenizer/src/AbstractLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ protected function classReflection(string $class): \ReflectionClass
*
* @param class-string $enum
*
* @return \ReflectionEnum
*
* @throws LocatorException
*/
protected function enumReflection(string $enum): \ReflectionEnum
Expand Down
4 changes: 0 additions & 4 deletions src/Tokenizer/src/Bootloader/TokenizerBootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,9 @@ public function __construct(

public function init(BinderInterface $binder, DirectoriesInterface $dirs): void
{
/** @psalm-suppress InvalidCast https://github.com/vimeo/psalm/issues/8810 */
$binder->bindInjector(ClassLocator::class, ClassLocatorInjector::class);
/** @psalm-suppress InvalidCast https://github.com/vimeo/psalm/issues/8810 */
$binder->bindInjector(EnumLocator::class, EnumLocatorInjector::class);
/** @psalm-suppress InvalidCast https://github.com/vimeo/psalm/issues/8810 */
$binder->bindInjector(InterfaceLocator::class, InterfaceLocatorInjector::class);
/** @psalm-suppress InvalidCast https://github.com/vimeo/psalm/issues/8810 */
$binder->bindInjector(InvocationLocator::class, InvocationLocatorInjector::class);

$this->config->setDefaults(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ private function loadInterfaces(
}

/**
* @param ListenerInvoker $invoker
* @param callable(): array<class-string, \ReflectionClass> $reflections
* @param callable(TokenizationListenerInterface): bool $loader
*/
Expand Down
3 changes: 2 additions & 1 deletion src/Tokenizer/src/EnumLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,13 @@ protected function availableEnums(): array
*/
protected function isTargeted(\ReflectionEnum $enum, \ReflectionClass $target = null): bool
{
if (empty($target)) {
if ($target === null) {
return true;
}

if (!$target->isTrait()) {
//Target is interface or class
/** @psalm-suppress RedundantCondition https://github.com/vimeo/psalm/issues/9489 */
return $enum->isSubclassOf($target) || $enum->getName() === $target->getName();
}

Expand Down

0 comments on commit 67a0200

Please sign in to comment.