Skip to content

Commit

Permalink
PHP CS fix (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
seferov committed Dec 23, 2022
1 parent 6a1723f commit 6671a91
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 28 deletions.
4 changes: 1 addition & 3 deletions src/Handler/ContainerHandler.php
Expand Up @@ -2,8 +2,6 @@

namespace Psalm\SymfonyPsalmPlugin\Handler;

use function constant;

use PhpParser\Node\Arg;
use PhpParser\Node\Expr\ClassConstFetch;
use PhpParser\Node\Identifier;
Expand Down Expand Up @@ -105,7 +103,7 @@ public static function afterMethodCallAnalysis(AfterMethodCallAnalysisEvent $eve
$serviceId = $className;
} else {
try {
$serviceId = constant($className.'::'.$idArgument->name->name);
$serviceId = \constant($className.'::'.$idArgument->name->name);
} catch (\Exception $e) {
return;
}
Expand Down
8 changes: 3 additions & 5 deletions src/Handler/DoctrineRepositoryHandler.php
Expand Up @@ -17,8 +17,6 @@
use Psalm\SymfonyPsalmPlugin\Issue\RepositoryStringShortcut;
use Psalm\Type\Atomic\TNamedObject;
use Psalm\Type\Union;
use ReflectionClass;
use ReflectionException;

class DoctrineRepositoryHandler implements AfterMethodCallAnalysisInterface, AfterClassLikeVisitInterface
{
Expand Down Expand Up @@ -51,9 +49,9 @@ public static function afterMethodCallAnalysis(AfterMethodCallAnalysisEvent $eve
}

try {
$reflectionClass = new ReflectionClass($className);
$reflectionClass = new \ReflectionClass($className);

if (\PHP_VERSION_ID >= 80000 && method_exists(ReflectionClass::class, 'getAttributes')) {
if (\PHP_VERSION_ID >= 80000 && method_exists(\ReflectionClass::class, 'getAttributes')) {
$entityAttributes = $reflectionClass->getAttributes(EntityAnnotation::class);

foreach ($entityAttributes as $entityAttribute) {
Expand All @@ -76,7 +74,7 @@ public static function afterMethodCallAnalysis(AfterMethodCallAnalysisEvent $eve
$event->setReturnTypeCandidate(new Union([new TNamedObject($entityAnnotation->repositoryClass)]));
}
}
} catch (ReflectionException $e) {
} catch (\ReflectionException $e) {
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/Plugin.php
Expand Up @@ -21,7 +21,6 @@
use Psalm\SymfonyPsalmPlugin\Twig\CachedTemplatesMapping;
use Psalm\SymfonyPsalmPlugin\Twig\CachedTemplatesTainter;
use Psalm\SymfonyPsalmPlugin\Twig\TemplateFileAnalyzer;
use SimpleXMLElement;
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
use Symfony\Component\HttpKernel\Kernel;

Expand All @@ -33,7 +32,7 @@ class Plugin implements PluginEntryPointInterface
/**
* {@inheritdoc}
*/
public function __invoke(RegistrationInterface $api, SimpleXMLElement $config = null): void
public function __invoke(RegistrationInterface $api, \SimpleXMLElement $config = null): void
{
require_once __DIR__.'/Handler/HeaderBagHandler.php';
require_once __DIR__.'/Handler/ContainerHandler.php';
Expand Down
3 changes: 1 addition & 2 deletions src/Test/CodeceptionModule.php
Expand Up @@ -8,7 +8,6 @@
use Codeception\Exception\ModuleRequireException;
use Codeception\Module as BaseModule;
use Codeception\TestInterface;
use InvalidArgumentException;
use Psalm\SymfonyPsalmPlugin\Twig\CachedTemplatesMapping;
use Twig\Cache\FilesystemCache;
use Twig\Environment;
Expand Down Expand Up @@ -182,7 +181,7 @@ private function loadTemplate(string $templateName, string $rootDirectory, strin
{
if (null === $this->twigCache) {
if (!is_dir($cacheDirectory)) {
throw new InvalidArgumentException(sprintf('The %s twig cache directory does not exist or is not readable.', $cacheDirectory));
throw new \InvalidArgumentException(sprintf('The %s twig cache directory does not exist or is not readable.', $cacheDirectory));
}
$this->twigCache = new FilesystemCache($cacheDirectory);
}
Expand Down
5 changes: 2 additions & 3 deletions src/Twig/AnalyzedTemplatesTainter.php
Expand Up @@ -16,7 +16,6 @@
use Psalm\StatementsSource;
use Psalm\SymfonyPsalmPlugin\Exception\TemplateNameUnresolvedException;
use Psalm\Type\Atomic\TKeyedArray;
use RuntimeException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Twig\Environment;

Expand Down Expand Up @@ -86,7 +85,7 @@ private static function generateTemplateParameters(Expr $templateParameters, Sta
{
$type = $source->getNodeTypeProvider()->getType($templateParameters);
if (null === $type) {
throw new RuntimeException(sprintf('Can not retrieve type for the given expression (%s)', get_class($templateParameters)));
throw new \RuntimeException(sprintf('Can not retrieve type for the given expression (%s)', get_class($templateParameters)));
}

if ($templateParameters instanceof Array_) {
Expand All @@ -112,6 +111,6 @@ private static function generateTemplateParameters(Expr $templateParameters, Sta
return $parameters;
}

throw new RuntimeException(sprintf('Can not retrieve template parameters from given expression (%s)', get_class($templateParameters)));
throw new \RuntimeException(sprintf('Can not retrieve template parameters from given expression (%s)', get_class($templateParameters)));
}
}
4 changes: 1 addition & 3 deletions src/Twig/CachedTemplateNotFoundException.php
Expand Up @@ -4,9 +4,7 @@

namespace Psalm\SymfonyPsalmPlugin\Twig;

use Exception;

class CachedTemplateNotFoundException extends Exception
class CachedTemplateNotFoundException extends \Exception
{
public function __construct()
{
Expand Down
3 changes: 1 addition & 2 deletions src/Twig/CachedTemplatesMapping.php
Expand Up @@ -6,7 +6,6 @@

use Psalm\Plugin\EventHandler\AfterCodebasePopulatedInterface;
use Psalm\Plugin\EventHandler\Event\AfterCodebasePopulatedEvent;
use RuntimeException;

/**
* This class is used to store a mapping of all analyzed twig template cache files with their corresponding actual templates.
Expand Down Expand Up @@ -66,7 +65,7 @@ public static function setCachePath(string $cachePath): void
public static function getCacheClassName(string $templateName): string
{
if (null === self::$cacheRegistry) {
throw new RuntimeException(sprintf('Can not load template %s, because no cache registry is provided.', $templateName));
throw new \RuntimeException(sprintf('Can not load template %s, because no cache registry is provided.', $templateName));
}

return self::$cacheRegistry->getCacheClassName($templateName);
Expand Down
6 changes: 2 additions & 4 deletions src/Twig/CachedTemplatesRegistry.php
Expand Up @@ -4,8 +4,6 @@

namespace Psalm\SymfonyPsalmPlugin\Twig;

use Generator;

class CachedTemplatesRegistry
{
/**
Expand Down Expand Up @@ -36,9 +34,9 @@ public function getCacheClassName(string $templateName): string
}

/**
* @return Generator<string>
* @return \Generator<string>
*/
private static function generateNames(string $baseName): Generator
private static function generateNames(string $baseName): \Generator
{
yield $baseName;

Expand Down
3 changes: 1 addition & 2 deletions src/Twig/CachedTemplatesTainter.php
Expand Up @@ -14,7 +14,6 @@
use Psalm\SymfonyPsalmPlugin\Exception\TemplateNameUnresolvedException;
use Psalm\Type\Atomic\TNamedObject;
use Psalm\Type\Union;
use RuntimeException;
use Twig\Environment;

/**
Expand All @@ -35,7 +34,7 @@ public static function getMethodReturnType(MethodReturnTypeProviderEvent $event)
$call_args = $event->getCallArgs();

if (!$source instanceof StatementsAnalyzer) {
throw new RuntimeException(sprintf('The %s::%s hook can only be called using a %s.', __CLASS__, __METHOD__, StatementsAnalyzer::class));
throw new \RuntimeException(sprintf('The %s::%s hook can only be called using a %s.', __CLASS__, __METHOD__, StatementsAnalyzer::class));
}

if ('render' !== $method_name_lowercase) {
Expand Down
3 changes: 1 addition & 2 deletions src/Twig/PrintNodeAnalyzer.php
Expand Up @@ -5,7 +5,6 @@
namespace Psalm\SymfonyPsalmPlugin\Twig;

use Psalm\Internal\DataFlow\DataFlowNode;
use RuntimeException;
use Twig\Node\Expression\AbstractExpression;
use Twig\Node\Expression\FilterExpression;
use Twig\Node\Expression\NameExpression;
Expand All @@ -25,7 +24,7 @@ public function analyzePrintNode(PrintNode $node): void
{
$expression = $node->getNode('expr');
if (!$expression instanceof AbstractExpression) {
throw new RuntimeException('The expr node has an expected type.');
throw new \RuntimeException('The expr node has an expected type.');
}

if ($this->expressionIsEscaped($expression)) {
Expand Down

0 comments on commit 6671a91

Please sign in to comment.