Skip to content

Commit

Permalink
coding standards fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Bartłomiej Nowak committed Aug 13, 2024
1 parent 0d3480f commit 5d47f63
Show file tree
Hide file tree
Showing 10 changed files with 291 additions and 272 deletions.
60 changes: 31 additions & 29 deletions src/Symfony/Message.php
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
<?php

declare(strict_types=1);
<?php declare(strict_types = 1);

namespace PHPStan\Symfony;

use function count;

final class Message
{
/** @var string */
private $class;

/** @var array */
private $returnTypes;

public function __construct(string $class, array $returnTypes)
{
$this->class = $class;
$this->returnTypes = $returnTypes;
}

public function getClass(): string
{
return $this->class;
}

public function getReturnTypes(): array
{
return $this->returnTypes;
}

public function countReturnTypes(): int
{
return count($this->returnTypes);
}

/** @var string */
private $class;

/** @var array */
private $returnTypes;

Check failure on line 14 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, lowest)

Property PHPStan\Symfony\Message::$returnTypes type has no value type specified in iterable type array.

Check failure on line 14 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, lowest)

Property PHPStan\Symfony\Message::$returnTypes type has no value type specified in iterable type array.

Check failure on line 14 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, highest)

Property PHPStan\Symfony\Message::$returnTypes type has no value type specified in iterable type array.

Check failure on line 14 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, lowest)

Property PHPStan\Symfony\Message::$returnTypes type has no value type specified in iterable type array.

Check failure on line 14 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, highest)

Property PHPStan\Symfony\Message::$returnTypes type has no value type specified in iterable type array.

Check failure on line 14 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, highest)

Property PHPStan\Symfony\Message::$returnTypes type has no value type specified in iterable type array.

Check failure on line 14 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, highest)

Property PHPStan\Symfony\Message::$returnTypes type has no value type specified in iterable type array.

Check failure on line 14 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, highest)

Property PHPStan\Symfony\Message::$returnTypes type has no value type specified in iterable type array.

Check failure on line 14 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, lowest)

Property PHPStan\Symfony\Message::$returnTypes type has no value type specified in iterable type array.

Check failure on line 14 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, lowest)

Property PHPStan\Symfony\Message::$returnTypes type has no value type specified in iterable type array.

Check failure on line 14 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, lowest)

Property PHPStan\Symfony\Message::$returnTypes type has no value type specified in iterable type array.

Check failure on line 14 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, highest)

Property PHPStan\Symfony\Message::$returnTypes type has no value type specified in iterable type array.

public function __construct(string $class, array $returnTypes)

Check failure on line 16 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, lowest)

Method PHPStan\Symfony\Message::__construct() has parameter $returnTypes with no value type specified in iterable type array.

Check failure on line 16 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, lowest)

Method PHPStan\Symfony\Message::__construct() has parameter $returnTypes with no value type specified in iterable type array.

Check failure on line 16 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, highest)

Method PHPStan\Symfony\Message::__construct() has parameter $returnTypes with no value type specified in iterable type array.

Check failure on line 16 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, lowest)

Method PHPStan\Symfony\Message::__construct() has parameter $returnTypes with no value type specified in iterable type array.

Check failure on line 16 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, highest)

Method PHPStan\Symfony\Message::__construct() has parameter $returnTypes with no value type specified in iterable type array.

Check failure on line 16 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, highest)

Method PHPStan\Symfony\Message::__construct() has parameter $returnTypes with no value type specified in iterable type array.

Check failure on line 16 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, highest)

Method PHPStan\Symfony\Message::__construct() has parameter $returnTypes with no value type specified in iterable type array.

Check failure on line 16 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, highest)

Method PHPStan\Symfony\Message::__construct() has parameter $returnTypes with no value type specified in iterable type array.

Check failure on line 16 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, lowest)

Method PHPStan\Symfony\Message::__construct() has parameter $returnTypes with no value type specified in iterable type array.

Check failure on line 16 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, lowest)

Method PHPStan\Symfony\Message::__construct() has parameter $returnTypes with no value type specified in iterable type array.

Check failure on line 16 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, lowest)

Method PHPStan\Symfony\Message::__construct() has parameter $returnTypes with no value type specified in iterable type array.

Check failure on line 16 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, highest)

Method PHPStan\Symfony\Message::__construct() has parameter $returnTypes with no value type specified in iterable type array.
{
$this->class = $class;
$this->returnTypes = $returnTypes;
}

public function getClass(): string
{
return $this->class;
}

public function getReturnTypes(): array

Check failure on line 27 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, lowest)

Method PHPStan\Symfony\Message::getReturnTypes() return type has no value type specified in iterable type array.

Check failure on line 27 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, lowest)

Method PHPStan\Symfony\Message::getReturnTypes() return type has no value type specified in iterable type array.

Check failure on line 27 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, highest)

Method PHPStan\Symfony\Message::getReturnTypes() return type has no value type specified in iterable type array.

Check failure on line 27 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, lowest)

Method PHPStan\Symfony\Message::getReturnTypes() return type has no value type specified in iterable type array.

Check failure on line 27 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, highest)

Method PHPStan\Symfony\Message::getReturnTypes() return type has no value type specified in iterable type array.

Check failure on line 27 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, highest)

Method PHPStan\Symfony\Message::getReturnTypes() return type has no value type specified in iterable type array.

Check failure on line 27 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, highest)

Method PHPStan\Symfony\Message::getReturnTypes() return type has no value type specified in iterable type array.

Check failure on line 27 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, highest)

Method PHPStan\Symfony\Message::getReturnTypes() return type has no value type specified in iterable type array.

Check failure on line 27 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, lowest)

Method PHPStan\Symfony\Message::getReturnTypes() return type has no value type specified in iterable type array.

Check failure on line 27 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, lowest)

Method PHPStan\Symfony\Message::getReturnTypes() return type has no value type specified in iterable type array.

Check failure on line 27 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, lowest)

Method PHPStan\Symfony\Message::getReturnTypes() return type has no value type specified in iterable type array.

Check failure on line 27 in src/Symfony/Message.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, highest)

Method PHPStan\Symfony\Message::getReturnTypes() return type has no value type specified in iterable type array.
{
return $this->returnTypes;
}

public function countReturnTypes(): int
{
return count($this->returnTypes);
}

}
52 changes: 27 additions & 25 deletions src/Symfony/MessageMap.php
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
<?php

declare(strict_types=1);
<?php declare(strict_types = 1);

namespace PHPStan\Symfony;

use function array_key_exists;

final class MessageMap
{
/** @var Message[] */
private $messages = [];

/**
* @param Message[] $messages
*/
public function __construct(array $messages)
{
foreach ($messages as $message) {
$this->messages[$message->getClass()] = $message;
}
}

public function getMessageForClass(string $class): ?Message
{
return $this->messages[$class] ?? null;
}

public function hasMessageForClass(string $class): bool
{
return array_key_exists($class, $this->messages);
}

/** @var Message[] */
private $messages = [];

/**
* @param Message[] $messages
*/
public function __construct(array $messages)
{
foreach ($messages as $message) {
$this->messages[$message->getClass()] = $message;
}
}

public function getMessageForClass(string $class): ?Message
{
return $this->messages[$class] ?? null;
}

public function hasMessageForClass(string $class): bool
{
return array_key_exists($class, $this->messages);
}

}
227 changes: 117 additions & 110 deletions src/Symfony/MessageMapFactory.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php declare(strict_types=1);
<?php declare(strict_types = 1);

namespace PHPStan\Symfony;

Expand All @@ -7,118 +7,125 @@
use PHPStan\Reflection\ReflectionProvider;
use PHPStan\Type\ObjectType;
use PHPStan\Type\UnionType;
use RuntimeException;
use Symfony\Component\Messenger\Handler\MessageSubscriberInterface;
use function count;
use function is_int;
use function is_null;
use function is_string;

// todo add tests
final class MessageMapFactory
{
/** @var ReflectionProvider */
private $reflectionProvider;

/** @var ServiceMap */
private $serviceMap;

public function __construct(ServiceMap $symfonyServiceMap, ReflectionProvider $reflectionProvider)
{
$this->serviceMap = $symfonyServiceMap;
$this->reflectionProvider = $reflectionProvider;
}

public function create(): MessageMap
{
$returnTypesMap = [];

foreach ($this->serviceMap->getServices() as $service) {
$serviceClass = $service->getClass();

// todo handle abstract/parent services somehow?
if (is_null($serviceClass)) {
continue;
}

foreach ($service->getTags() as $tag) {
// todo could there be more tags with the same name for the same service?
// todo check if message handler tag name is constant or configurable
if ($tag->getName() !== 'messenger.message_handler') {
continue;
}

$tagAttributes = $tag->getAttributes();
$reflectionClass = $this->reflectionProvider->getClass($serviceClass);

if (isset($tagAttributes['handles'])) {
$handles = isset($tag['method']) ? [$tag['handles'] => $tag['method']] : [$tag['handles']];
} else {
$handles = $this->guessHandledMessages($reflectionClass);
}

foreach ($handles as $messageClassName => $options) {
if (\is_int($messageClassName) && \is_string($options)) {
$messageClassName = $options;
$options = [];
}

$options['method'] = $options['method'] ?? '__invoke';

$methodReflection = $reflectionClass->getNativeMethod($options['method']);
$variant = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants());

$returnTypesMap[$messageClassName][] = $variant->getReturnType();
}
}
}

$messages = [];
foreach ($returnTypesMap as $messageClassName => $returnTypes) {
$messages[] = new Message($messageClassName, $returnTypes);
}

return new MessageMap($messages);
}

private function guessHandledMessages(ClassReflection $reflectionClass): iterable
{
if ($reflectionClass->implementsInterface(MessageSubscriberInterface::class)) {
// todo handle different return formats
return $reflectionClass->getName()::getHandledMessages();
}

// todo handle if doesn't exists
$methodReflection = $reflectionClass->getNativeMethod('__invoke');

$variant = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants());
$parameters = $variant->getParameters();

if (1 !== count($parameters)) {
// todo handle error
throw new \RuntimeException('invalid handler');
}

$type = $parameters[0]->getType();

if ($type instanceof UnionType) {
$types = [];
foreach ($type->getTypes() as $type) {
if (!$type instanceof ObjectType) {
// todo handle error
throw new \RuntimeException('invalid handler');
}

$types[] = $type->getClassName();
}

if ($types) {
return $types;
}

// todo handle error
throw new \RuntimeException('invalid handler');
}

if (!$type instanceof ObjectType) {
throw new \RuntimeException('invalid handler');
}

return [$type->getClassName()];
}

/** @var ReflectionProvider */
private $reflectionProvider;

/** @var ServiceMap */
private $serviceMap;

public function __construct(ServiceMap $symfonyServiceMap, ReflectionProvider $reflectionProvider)
{
$this->serviceMap = $symfonyServiceMap;
$this->reflectionProvider = $reflectionProvider;
}

public function create(): MessageMap
{
$returnTypesMap = [];

foreach ($this->serviceMap->getServices() as $service) {
$serviceClass = $service->getClass();

// todo handle abstract/parent services somehow?
if (is_null($serviceClass)) {
continue;
}

foreach ($service->getTags() as $tag) {
// todo could there be more tags with the same name for the same service?
// todo check if message handler tag name is constant or configurable
if ($tag->getName() !== 'messenger.message_handler') {
continue;
}

$tagAttributes = $tag->getAttributes();
$reflectionClass = $this->reflectionProvider->getClass($serviceClass);

if (isset($tagAttributes['handles'])) {
$handles = isset($tag['method']) ? [$tag['handles'] => $tag['method']] : [$tag['handles']];
} else {
$handles = $this->guessHandledMessages($reflectionClass);
}

foreach ($handles as $messageClassName => $options) {
if (is_int($messageClassName) && is_string($options)) {
$messageClassName = $options;
$options = [];
}

$options['method'] = $options['method'] ?? '__invoke';

$methodReflection = $reflectionClass->getNativeMethod($options['method']);
$variant = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants());

$returnTypesMap[$messageClassName][] = $variant->getReturnType();
}
}
}

$messages = [];
foreach ($returnTypesMap as $messageClassName => $returnTypes) {
$messages[] = new Message($messageClassName, $returnTypes);

Check failure on line 79 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, lowest)

Parameter #1 $class of class PHPStan\Symfony\Message constructor expects string, int|string given.

Check failure on line 79 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, lowest)

Parameter #1 $class of class PHPStan\Symfony\Message constructor expects string, int|string given.

Check failure on line 79 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, highest)

Parameter #1 $class of class PHPStan\Symfony\Message constructor expects string, int|string given.

Check failure on line 79 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, lowest)

Parameter #1 $class of class PHPStan\Symfony\Message constructor expects string, int|string given.

Check failure on line 79 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, highest)

Parameter #1 $class of class PHPStan\Symfony\Message constructor expects string, int|string given.

Check failure on line 79 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, highest)

Parameter #1 $class of class PHPStan\Symfony\Message constructor expects string, int|string given.

Check failure on line 79 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, highest)

Parameter #1 $class of class PHPStan\Symfony\Message constructor expects string, int|string given.

Check failure on line 79 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, highest)

Parameter #1 $class of class PHPStan\Symfony\Message constructor expects string, int|string given.

Check failure on line 79 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, lowest)

Parameter #1 $class of class PHPStan\Symfony\Message constructor expects string, int|string given.

Check failure on line 79 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, lowest)

Parameter #1 $class of class PHPStan\Symfony\Message constructor expects string, int|string given.

Check failure on line 79 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, lowest)

Parameter #1 $class of class PHPStan\Symfony\Message constructor expects string, int|string given.

Check failure on line 79 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, highest)

Parameter #1 $class of class PHPStan\Symfony\Message constructor expects string, int|string given.
}

return new MessageMap($messages);
}

private function guessHandledMessages(ClassReflection $reflectionClass): iterable

Check failure on line 85 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, lowest)

Method PHPStan\Symfony\MessageMapFactory::guessHandledMessages() return type has no value type specified in iterable type iterable.

Check failure on line 85 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, lowest)

Method PHPStan\Symfony\MessageMapFactory::guessHandledMessages() return type has no value type specified in iterable type iterable.

Check failure on line 85 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, highest)

Method PHPStan\Symfony\MessageMapFactory::guessHandledMessages() return type has no value type specified in iterable type iterable.

Check failure on line 85 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, lowest)

Method PHPStan\Symfony\MessageMapFactory::guessHandledMessages() return type has no value type specified in iterable type iterable.

Check failure on line 85 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, highest)

Method PHPStan\Symfony\MessageMapFactory::guessHandledMessages() return type has no value type specified in iterable type iterable.

Check failure on line 85 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, highest)

Method PHPStan\Symfony\MessageMapFactory::guessHandledMessages() return type has no value type specified in iterable type iterable.

Check failure on line 85 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, highest)

Method PHPStan\Symfony\MessageMapFactory::guessHandledMessages() return type has no value type specified in iterable type iterable.

Check failure on line 85 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, highest)

Method PHPStan\Symfony\MessageMapFactory::guessHandledMessages() return type has no value type specified in iterable type iterable.

Check failure on line 85 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, lowest)

Method PHPStan\Symfony\MessageMapFactory::guessHandledMessages() return type has no value type specified in iterable type iterable.

Check failure on line 85 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, lowest)

Method PHPStan\Symfony\MessageMapFactory::guessHandledMessages() return type has no value type specified in iterable type iterable.

Check failure on line 85 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, lowest)

Method PHPStan\Symfony\MessageMapFactory::guessHandledMessages() return type has no value type specified in iterable type iterable.

Check failure on line 85 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, highest)

Method PHPStan\Symfony\MessageMapFactory::guessHandledMessages() return type has no value type specified in iterable type iterable.
{
if ($reflectionClass->implementsInterface(MessageSubscriberInterface::class)) {
// todo handle different return formats
return $reflectionClass->getName()::getHandledMessages();
}

// todo handle if doesn't exists
$methodReflection = $reflectionClass->getNativeMethod('__invoke');

$variant = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants());
$parameters = $variant->getParameters();

if (count($parameters) !== 1) {
// todo handle error
throw new RuntimeException('invalid handler');
}

$type = $parameters[0]->getType();

if ($type instanceof UnionType) {
$types = [];
foreach ($type->getTypes() as $type) {

Check failure on line 107 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, lowest)

Foreach overwrites $type with its value variable.

Check failure on line 107 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, lowest)

Foreach overwrites $type with its value variable.

Check failure on line 107 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, highest)

Foreach overwrites $type with its value variable.

Check failure on line 107 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, lowest)

Foreach overwrites $type with its value variable.

Check failure on line 107 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, highest)

Foreach overwrites $type with its value variable.

Check failure on line 107 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, highest)

Foreach overwrites $type with its value variable.

Check failure on line 107 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, highest)

Foreach overwrites $type with its value variable.

Check failure on line 107 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, highest)

Foreach overwrites $type with its value variable.

Check failure on line 107 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, lowest)

Foreach overwrites $type with its value variable.

Check failure on line 107 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, lowest)

Foreach overwrites $type with its value variable.

Check failure on line 107 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, lowest)

Foreach overwrites $type with its value variable.

Check failure on line 107 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, highest)

Foreach overwrites $type with its value variable.
if (!$type instanceof ObjectType) {

Check failure on line 108 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, lowest)

Doing instanceof PHPStan\Type\ObjectType is error-prone and deprecated. Use Type::isObject() or Type::getObjectClassNames() instead.

Check failure on line 108 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, lowest)

Doing instanceof PHPStan\Type\ObjectType is error-prone and deprecated. Use Type::isObject() or Type::getObjectClassNames() instead.

Check failure on line 108 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, highest)

Doing instanceof PHPStan\Type\ObjectType is error-prone and deprecated. Use Type::isObject() or Type::getObjectClassNames() instead.

Check failure on line 108 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, lowest)

Doing instanceof PHPStan\Type\ObjectType is error-prone and deprecated. Use Type::isObject() or Type::getObjectClassNames() instead.

Check failure on line 108 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, highest)

Doing instanceof PHPStan\Type\ObjectType is error-prone and deprecated. Use Type::isObject() or Type::getObjectClassNames() instead.

Check failure on line 108 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, highest)

Doing instanceof PHPStan\Type\ObjectType is error-prone and deprecated. Use Type::isObject() or Type::getObjectClassNames() instead.

Check failure on line 108 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, highest)

Doing instanceof PHPStan\Type\ObjectType is error-prone and deprecated. Use Type::isObject() or Type::getObjectClassNames() instead.

Check failure on line 108 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, highest)

Doing instanceof PHPStan\Type\ObjectType is error-prone and deprecated. Use Type::isObject() or Type::getObjectClassNames() instead.

Check failure on line 108 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, lowest)

Doing instanceof PHPStan\Type\ObjectType is error-prone and deprecated. Use Type::isObject() or Type::getObjectClassNames() instead.

Check failure on line 108 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, lowest)

Doing instanceof PHPStan\Type\ObjectType is error-prone and deprecated. Use Type::isObject() or Type::getObjectClassNames() instead.

Check failure on line 108 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, lowest)

Doing instanceof PHPStan\Type\ObjectType is error-prone and deprecated. Use Type::isObject() or Type::getObjectClassNames() instead.

Check failure on line 108 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, highest)

Doing instanceof PHPStan\Type\ObjectType is error-prone and deprecated. Use Type::isObject() or Type::getObjectClassNames() instead.
// todo handle error
throw new RuntimeException('invalid handler');
}

$types[] = $type->getClassName();
}

if ($types) {

Check failure on line 116 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, lowest)

Only booleans are allowed in an if condition, array<int, string> given.

Check failure on line 116 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, lowest)

Only booleans are allowed in an if condition, array<int, string> given.

Check failure on line 116 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, highest)

Only booleans are allowed in an if condition, array<int, string> given.

Check failure on line 116 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, lowest)

Only booleans are allowed in an if condition, array<int, string> given.

Check failure on line 116 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, highest)

Only booleans are allowed in an if condition, array<int, string> given.

Check failure on line 116 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, highest)

Only booleans are allowed in an if condition, array<int, string> given.

Check failure on line 116 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, highest)

Only booleans are allowed in an if condition, array<int, string> given.

Check failure on line 116 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, highest)

Only booleans are allowed in an if condition, array<int, string> given.

Check failure on line 116 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, lowest)

Only booleans are allowed in an if condition, array<int, string> given.

Check failure on line 116 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, lowest)

Only booleans are allowed in an if condition, array<int, string> given.

Check failure on line 116 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, lowest)

Only booleans are allowed in an if condition, array<int, string> given.

Check failure on line 116 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, highest)

Only booleans are allowed in an if condition, array<int, string> given.
return $types;
}

// todo handle error
throw new RuntimeException('invalid handler');
}

if (!$type instanceof ObjectType) {

Check failure on line 124 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, lowest)

Doing instanceof PHPStan\Type\ObjectType is error-prone and deprecated. Use Type::isObject() or Type::getObjectClassNames() instead.

Check failure on line 124 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, lowest)

Doing instanceof PHPStan\Type\ObjectType is error-prone and deprecated. Use Type::isObject() or Type::getObjectClassNames() instead.

Check failure on line 124 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, highest)

Doing instanceof PHPStan\Type\ObjectType is error-prone and deprecated. Use Type::isObject() or Type::getObjectClassNames() instead.

Check failure on line 124 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, lowest)

Doing instanceof PHPStan\Type\ObjectType is error-prone and deprecated. Use Type::isObject() or Type::getObjectClassNames() instead.

Check failure on line 124 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, highest)

Doing instanceof PHPStan\Type\ObjectType is error-prone and deprecated. Use Type::isObject() or Type::getObjectClassNames() instead.

Check failure on line 124 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, highest)

Doing instanceof PHPStan\Type\ObjectType is error-prone and deprecated. Use Type::isObject() or Type::getObjectClassNames() instead.

Check failure on line 124 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, highest)

Doing instanceof PHPStan\Type\ObjectType is error-prone and deprecated. Use Type::isObject() or Type::getObjectClassNames() instead.

Check failure on line 124 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, highest)

Doing instanceof PHPStan\Type\ObjectType is error-prone and deprecated. Use Type::isObject() or Type::getObjectClassNames() instead.

Check failure on line 124 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, lowest)

Doing instanceof PHPStan\Type\ObjectType is error-prone and deprecated. Use Type::isObject() or Type::getObjectClassNames() instead.

Check failure on line 124 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, lowest)

Doing instanceof PHPStan\Type\ObjectType is error-prone and deprecated. Use Type::isObject() or Type::getObjectClassNames() instead.

Check failure on line 124 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, lowest)

Doing instanceof PHPStan\Type\ObjectType is error-prone and deprecated. Use Type::isObject() or Type::getObjectClassNames() instead.

Check failure on line 124 in src/Symfony/MessageMapFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, highest)

Doing instanceof PHPStan\Type\ObjectType is error-prone and deprecated. Use Type::isObject() or Type::getObjectClassNames() instead.
throw new RuntimeException('invalid handler');
}

return [$type->getClassName()];
}

}
Loading

0 comments on commit 5d47f63

Please sign in to comment.