diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index e110e70..936d43b 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -10,15 +10,6 @@
$finder
-
- $display
-
-
- string
-
-
- $this->display
-
$this->loader
@@ -117,12 +108,15 @@
+
+ Container
+
setContainer
-
- $container
-
+
+ $this->container
+
@@ -275,10 +269,6 @@
-
- !$this->parent
- $this->parent
-
$size
$size
@@ -310,9 +300,6 @@
getText
getText
-
- $parent
-
$callback
@@ -336,27 +323,10 @@
-
- $errors
- $unrecognizedExpressions
-
-
- $this->errors
-
-
- $this->errors[]
- $this->unrecognizedExpressions[]
-
-
- array
-
getColumn
getColumn
-
- $this->unrecognizedExpressions
-
@@ -986,75 +956,9 @@
-
- $arraySpacingPattern
- $arrowFunctionSpacingPattern
- $binaryOpSpacingPattern
- $elseifSpacingPattern
- $embedSpacingPattern
- $emptyArraySpacingPattern
- $emptyHashSpacingPattern
- $emptyListWhitespaces
- $emptyParenthesesSpacingPattern
- $forSpacingPattern
- $fromSpacingPattern
- $funcSpacingPattern
- $hashSpacingPattern
- $ifSpacingPattern
- $importSpacingPattern
- $includeSpacingPattern
- $listSpacingPattern
- $macroSpacingPattern
- $namedArgsSpacingPattern
- $parenthesesSpacingPattern
- $printStatementSpacingPattern
- $propertySpacingPattern
- $rangeOpSpacingPattern
- $setSpacingPattern
- $sliceSpacingPattern
- $tagDefaultArgSpacing
- $tagSpacingPattern
- $ternarySpacingPattern
- $twigMajorVersion
- $unaryOpSpacingPattern
-
getProcessedConfiguration
-
- $this->arraySpacingPattern
- $this->arrowFunctionSpacingPattern
- $this->binaryOpSpacingPattern
- $this->elseifSpacingPattern
- $this->embedSpacingPattern
- $this->emptyArraySpacingPattern
- $this->emptyHashSpacingPattern
- $this->emptyParenthesesSpacingPattern
- $this->forSpacingPattern
- $this->fromSpacingPattern
- $this->funcSpacingPattern
- $this->hashSpacingPattern
- $this->ifSpacingPattern
- $this->importSpacingPattern
- $this->includeSpacingPattern
- $this->listSpacingPattern
- $this->macroSpacingPattern
- $this->namedArgsSpacingPattern
- $this->parenthesesSpacingPattern
- $this->printStatementSpacingPattern
- $this->propertySpacingPattern
- $this->rangeOpSpacingPattern
- $this->setSpacingPattern
- $this->sliceSpacingPattern
- $this->tagSpacingPattern
- $this->ternarySpacingPattern
- $this->unaryOpSpacingPattern
-
-
- $config['empty_list_whitespaces']
- $config['tag_default_arg_spacing']
- $config['twigMajorVersion']
-
@@ -1316,15 +1220,9 @@
-
- $twigMajorVersion
-
setTemplateResolver
-
- $this->twigMajorVersion
-
@@ -1490,37 +1388,6 @@
$namespace
-
-
- $columnno
- $lineno
- $source
-
-
- Source|null
- int
- int
- string|null
- string|null
- string|null
-
-
- getCode
- getName
- getPath
-
-
- $this->columnno
- $this->lineno
- $this->source
- $this->source ? $this->source->getCode() : null
- $this->source ? $this->source->getCode() : null
- $this->source ? $this->source->getName() : null
- $this->source ? $this->source->getName() : null
- $this->source ? $this->source->getPath() : null
- $this->source ? $this->source->getPath() : null
-
-
$type
@@ -1549,59 +1416,25 @@
$type
$value
-
- $current
- $source
- $tokens
-
injectTokens
nextIf
-
+
$column
$column
$column
$line
$line
$line
- $this->current
- $this->current
- $this->source
- $this->source
- $this->source
- $this->tokens
- $this->tokens
- $this->tokens
$token->getType()
$token->getValue()
$type
$value
-
- $this->tokens[$this->current + $number - 1]
- $this->tokens[$this->current + $number]
- $this->tokens[$this->current - 1]
- $this->tokens[$this->current - 1]
- $this->tokens[$this->current]
- $this->tokens[$this->current]
- $this->tokens[$this->current]
- $this->tokens[$this->current]
- $this->tokens[$this->current]
-
-
- $this->tokens[$this->current + $number - 1]
- $this->tokens[$this->current + $number]
- $this->tokens[$this->current + $number]
- $this->tokens[$this->current - 1]
- $this->tokens[$this->current - 1]
- $this->tokens[$this->current]
- $this->tokens[$this->current]
- $this->tokens[$this->current]
- $this->tokens[$this->current]
- $this->tokens[$this->current]
- $this->tokens[++$this->current]
-
+
+ $this->tokens
+
$column
$column
@@ -1613,8 +1446,7 @@
$token
$token
-
- Source
+
Token
Token
Token
@@ -1636,16 +1468,7 @@
test
test
-
- $this->current
- $this->current
- $this->current
- $this->current
- $this->current
- $this->current
-
-
- $this->source
+
$this->tokens[$this->current + $number]
$this->tokens[$this->current - 1]
$this->tokens[$this->current]
@@ -1989,20 +1812,6 @@
$token
-
-
- $collectedData
-
-
- $this->collectedData[get_class($rule)]
-
-
- array
-
-
- $this->collectedData
-
-
$column
diff --git a/src/Config/Config.php b/src/Config/Config.php
index fa464fd..51476b2 100644
--- a/src/Config/Config.php
+++ b/src/Config/Config.php
@@ -18,7 +18,7 @@ class Config implements ConfigInterface
private string $reporter = 'console';
private string $ruleset = Official::class;
private array $specificRulesets = [];
- private $display = ConfigInterface::DISPLAY_ALL;
+ private string $display = ConfigInterface::DISPLAY_ALL;
public function __construct(string $name = 'default')
{
diff --git a/src/Config/ConfigResolver.php b/src/Config/ConfigResolver.php
index 0c87ac1..36120ec 100644
--- a/src/Config/ConfigResolver.php
+++ b/src/Config/ConfigResolver.php
@@ -14,15 +14,9 @@
*/
final class ConfigResolver
{
- /**
- * @var ConfigInterface|null
- */
- private $config;
+ private ?ConfigInterface $config = null;
- /**
- * @var string|null
- */
- private $configFile;
+ private ?string $configFile = null;
/**
* @var ConfigInterface
@@ -33,10 +27,8 @@ final class ConfigResolver
/**
* Options which can be set via Cli.
- *
- * @var array
*/
- private $options = [
+ private array $options = [
'path' => [],
'severity' => null,
'reporter-service-name' => 'console',
@@ -49,10 +41,7 @@ final class ConfigResolver
private $finders;
- /**
- * @var Container
- */
- private $container;
+ private Container $container;
private $cwd;
diff --git a/src/Console/Application.php b/src/Console/Application.php
index 1dcb6cf..2311564 100644
--- a/src/Console/Application.php
+++ b/src/Console/Application.php
@@ -11,10 +11,7 @@ class Application extends BaseApplication
public const NAME = 'twigcs';
public const VERSION = '@__VERSION__@';
- /**
- * @var Container
- */
- private $container;
+ private Container $container;
public function __construct(bool $singleCommand = true)
{
diff --git a/src/Console/ContainerAwareCommand.php b/src/Console/ContainerAwareCommand.php
index 902afe9..d4e2606 100644
--- a/src/Console/ContainerAwareCommand.php
+++ b/src/Console/ContainerAwareCommand.php
@@ -7,10 +7,7 @@
class ContainerAwareCommand extends Command
{
- /**
- * @var Container
- */
- private $container;
+ private ?Container $container = null;
public function setContainer(Container $container)
{
diff --git a/src/RegEngine/Checker/Capture.php b/src/RegEngine/Checker/Capture.php
index 039b723..a0acc8f 100644
--- a/src/RegEngine/Checker/Capture.php
+++ b/src/RegEngine/Checker/Capture.php
@@ -4,30 +4,15 @@
class Capture
{
- /**
- * @var string
- */
- private $type;
-
- /**
- * @var string
- */
- private $text;
-
- /**
- * @var int
- */
- private $offset;
-
- /**
- * @var Regex
- */
- private $source;
-
- /**
- * @var array
- */
- private $offsetsMap;
+ private string $type;
+
+ private string $text;
+
+ private int $offset;
+
+ private Regex $source;
+
+ private array $offsetsMap;
public function __construct(string $type, string $text, int $offset, Regex $source)
{
diff --git a/src/RegEngine/Checker/Handler.php b/src/RegEngine/Checker/Handler.php
index 14cdc15..8032751 100644
--- a/src/RegEngine/Checker/Handler.php
+++ b/src/RegEngine/Checker/Handler.php
@@ -9,10 +9,7 @@ class Handler
*/
private $callback;
- /**
- * @var Handler
- */
- private $parent;
+ private ?Handler $parent;
public static function create(): self
{
diff --git a/src/RegEngine/Checker/Regex.php b/src/RegEngine/Checker/Regex.php
index 40b68d8..74e9cff 100644
--- a/src/RegEngine/Checker/Regex.php
+++ b/src/RegEngine/Checker/Regex.php
@@ -4,20 +4,11 @@
class Regex
{
- /**
- * @var string
- */
- private $rule;
+ private string $rule;
- /**
- * @var string
- */
- private $regex;
+ private string $regex;
- /**
- * @var array
- */
- private $captureTypes;
+ private array $captureTypes;
/**
* @var callable
diff --git a/src/RegEngine/Checker/Report.php b/src/RegEngine/Checker/Report.php
index b2471c5..d1ff1b7 100644
--- a/src/RegEngine/Checker/Report.php
+++ b/src/RegEngine/Checker/Report.php
@@ -4,9 +4,9 @@
class Report
{
- private $errors;
+ private array $errors;
- private $unrecognizedExpressions;
+ private array $unrecognizedExpressions;
public function __construct()
{
diff --git a/src/RegEngine/Checker/RuleChecker.php b/src/RegEngine/Checker/RuleChecker.php
index bace879..806e7f3 100644
--- a/src/RegEngine/Checker/RuleChecker.php
+++ b/src/RegEngine/Checker/RuleChecker.php
@@ -16,25 +16,13 @@ function split($str, $len = 1)
class RuleChecker
{
- /**
- * @var array
- */
- private $rules;
-
- /**
- * @var bool
- */
- private $explain;
-
- /**
- * @var array
- */
- private $unrecognizedExpressions;
-
- /**
- * @var array
- */
- private $log;
+ private array $rules;
+
+ private bool $explain;
+
+ private array $unrecognizedExpressions;
+
+ private array $log;
public function __construct(array $rulesets)
{
diff --git a/src/RegEngine/Checker/RuleError.php b/src/RegEngine/Checker/RuleError.php
index a377270..d76fc56 100644
--- a/src/RegEngine/Checker/RuleError.php
+++ b/src/RegEngine/Checker/RuleError.php
@@ -4,20 +4,11 @@
class RuleError
{
- /**
- * @var int
- */
- private $column;
-
- /**
- * @var string
- */
- private $reason;
-
- /**
- * @var Regex
- */
- private $source;
+ private int $column;
+
+ private string $reason;
+
+ private Regex $source;
public function __construct(string $reason, int $column, Regex $source)
{
diff --git a/src/RegEngine/ExpressionNode.php b/src/RegEngine/ExpressionNode.php
index 45f690e..273c25c 100644
--- a/src/RegEngine/ExpressionNode.php
+++ b/src/RegEngine/ExpressionNode.php
@@ -4,15 +4,9 @@
class ExpressionNode
{
- /**
- * @var string
- */
- private $expr;
+ private string $expr;
- /**
- * @var array
- */
- private $children;
+ private array $children;
/**
* @var int
@@ -24,10 +18,7 @@ class ExpressionNode
*/
private $type;
- /**
- * @var array
- */
- private $offsetsMap;
+ private array $offsetsMap;
public static function fromString($expr)
{
diff --git a/src/RegEngine/Linter.php b/src/RegEngine/Linter.php
index 0c76b75..ef99357 100644
--- a/src/RegEngine/Linter.php
+++ b/src/RegEngine/Linter.php
@@ -8,15 +8,9 @@
class Linter
{
- /**
- * @var RuleChecker
- */
- private $ruleChecker;
-
- /**
- * @var StringSanitizer
- */
- private $stringSanitizer;
+ private RuleChecker $ruleChecker;
+
+ private StringSanitizer $stringSanitizer;
public function __construct(array $ruleset)
{
diff --git a/src/RegEngine/RulesetConfigurator.php b/src/RegEngine/RulesetConfigurator.php
index 4f88404..168e2a8 100644
--- a/src/RegEngine/RulesetConfigurator.php
+++ b/src/RegEngine/RulesetConfigurator.php
@@ -33,36 +33,36 @@ class RulesetConfigurator
public const ARROW_FUNCTION_SPACING_PATTERN = '#^args( *)=>( *)expr$#';
public const NAMED_ARGS_SPACING_PATTERN = '#^name( *)=( *)value( *),( *)expr$#';
- private $macroSpacingPattern = 'macro name(expr)';
- private $tagSpacingPattern = '{% expr %}';
- private $printStatementSpacingPattern = '{{ expr }}';
- private $funcSpacingPattern = 'func(expr)';
- private $arraySpacingPattern = '[expr]';
- private $emptyArraySpacingPattern = '[]';
- private $hashSpacingPattern = '{key: expr, key: expr}';
- private $emptyHashSpacingPattern = '{}';
- private $emptyParenthesesSpacingPattern = '()';
- private $parenthesesSpacingPattern = '(expr)';
- private $ifSpacingPattern = 'if expr';
- private $elseifSpacingPattern = 'elseif expr';
- private $forSpacingPattern = 'for item in expr< if expr>';
- private $setSpacingPattern = 'set expr = expr';
- private $binaryOpSpacingPattern = 'expr op expr';
- private $rangeOpSpacingPattern = 'expr..expr';
- private $unaryOpSpacingPattern = 'op expr';
- private $sliceSpacingPattern = '[expr:expr]';
- private $listSpacingPattern = 'expr, expr';
- private $importSpacingPattern = 'import expr as list, expr as list';
- private $fromSpacingPattern = 'from expr import expr< as list>';
- private $embedSpacingPattern = 'embed expr< ignore missing>< with list>< only>';
- private $includeSpacingPattern = 'include expr< ignore missing>< with list>< only>';
- private $ternarySpacingPattern = 'expr ? expr : expr||expr ?: expr';
- private $propertySpacingPattern = 'expr.expr|filter';
- private $tagDefaultArgSpacing = 1; // Default space used between tag arguments : {% foo arg1 arg2 %}
- private $emptyListWhitespaces = 0;
- private $arrowFunctionSpacingPattern = 'args => expr';
- private $namedArgsSpacingPattern = 'name=value, expr';
- private $twigMajorVersion = 3;
+ private string $macroSpacingPattern = 'macro name(expr)';
+ private string $tagSpacingPattern = '{% expr %}';
+ private string $printStatementSpacingPattern = '{{ expr }}';
+ private string $funcSpacingPattern = 'func(expr)';
+ private string $arraySpacingPattern = '[expr]';
+ private string $emptyArraySpacingPattern = '[]';
+ private string $hashSpacingPattern = '{key: expr, key: expr}';
+ private string $emptyHashSpacingPattern = '{}';
+ private string $emptyParenthesesSpacingPattern = '()';
+ private string $parenthesesSpacingPattern = '(expr)';
+ private string $ifSpacingPattern = 'if expr';
+ private string $elseifSpacingPattern = 'elseif expr';
+ private string $forSpacingPattern = 'for item in expr< if expr>';
+ private string $setSpacingPattern = 'set expr = expr';
+ private string $binaryOpSpacingPattern = 'expr op expr';
+ private string $rangeOpSpacingPattern = 'expr..expr';
+ private string $unaryOpSpacingPattern = 'op expr';
+ private string $sliceSpacingPattern = '[expr:expr]';
+ private string $listSpacingPattern = 'expr, expr';
+ private string $importSpacingPattern = 'import expr as list, expr as list';
+ private string $fromSpacingPattern = 'from expr import expr< as list>';
+ private string $embedSpacingPattern = 'embed expr< ignore missing>< with list>< only>';
+ private string $includeSpacingPattern = 'include expr< ignore missing>< with list>< only>';
+ private string $ternarySpacingPattern = 'expr ? expr : expr||expr ?: expr';
+ private string $propertySpacingPattern = 'expr.expr|filter';
+ private int $tagDefaultArgSpacing = 1; // Default space used between tag arguments : {% foo arg1 arg2 %}
+ private int $emptyListWhitespaces = 0;
+ private string $arrowFunctionSpacingPattern = 'args => expr';
+ private string $namedArgsSpacingPattern = 'name=value, expr';
+ private int $twigMajorVersion = 3;
public function getProcessedConfiguration()
{
diff --git a/src/RegEngine/ScopedExpression.php b/src/RegEngine/ScopedExpression.php
index 4b645e7..15b95cd 100644
--- a/src/RegEngine/ScopedExpression.php
+++ b/src/RegEngine/ScopedExpression.php
@@ -4,25 +4,16 @@
class ScopedExpression
{
- /**
- * @var array
- */
- private $content;
+ private array $content;
/**
* @var string|self
*/
private $head;
- /**
- * @var bool
- */
- private $open;
+ private bool $open;
- /**
- * @var string
- */
- private $kind;
+ private string $kind;
public function __construct(string $kind = 'EXPR')
{
diff --git a/src/Reporter/GithubActionReporter.php b/src/Reporter/GithubActionReporter.php
index 3f6a696..518baf2 100644
--- a/src/Reporter/GithubActionReporter.php
+++ b/src/Reporter/GithubActionReporter.php
@@ -26,10 +26,7 @@ class GithubActionReporter implements ReporterInterface
',' => '%2C',
];
- /**
- * @var ReporterInterface
- */
- private $reporter;
+ private ReporterInterface $reporter;
public function __construct(ReporterInterface $reporter)
{
diff --git a/src/Rule/RegEngineRule.php b/src/Rule/RegEngineRule.php
index 75bb573..7f2e73f 100644
--- a/src/Rule/RegEngineRule.php
+++ b/src/Rule/RegEngineRule.php
@@ -8,20 +8,11 @@
class RegEngineRule extends AbstractRule implements RuleInterface
{
- /**
- * @var array
- */
- private $ruleset;
-
- /**
- * @var array
- */
- private $unrecognizedExpressions;
-
- /**
- * @var Linter
- */
- private $linter;
+ private array $ruleset;
+
+ private array $unrecognizedExpressions;
+
+ private Linter $linter;
public function __construct(int $severity, array $ruleset)
{
diff --git a/src/Ruleset/Official.php b/src/Ruleset/Official.php
index 295dcbc..5c12a63 100644
--- a/src/Ruleset/Official.php
+++ b/src/Ruleset/Official.php
@@ -16,7 +16,7 @@
*/
class Official implements RulesetInterface, TemplateResolverAwareInterface
{
- private $twigMajorVersion;
+ private int $twigMajorVersion;
private TemplateResolverInterface $resolver;
diff --git a/src/Scope/Declaration.php b/src/Scope/Declaration.php
index f0b7946..857b9e6 100644
--- a/src/Scope/Declaration.php
+++ b/src/Scope/Declaration.php
@@ -6,20 +6,11 @@
class Declaration
{
- /**
- * @var string
- */
- private $name;
-
- /**
- * @var Token
- */
- private $token;
-
- /**
- * @var Scope
- */
- private $origin;
+ private string $name;
+
+ private Token $token;
+
+ private Scope $origin;
public function __construct(string $name, Token $token, Scope $origin)
{
diff --git a/src/Scope/FlattenedScope.php b/src/Scope/FlattenedScope.php
index b920c81..35aafcf 100644
--- a/src/Scope/FlattenedScope.php
+++ b/src/Scope/FlattenedScope.php
@@ -4,20 +4,11 @@
class FlattenedScope
{
- /**
- * @var array
- */
- private $isolatedScopes;
-
- /**
- * @var array
- */
- private $queue;
-
- /**
- * @var array
- */
- private $blocks;
+ private array $isolatedScopes;
+
+ private array $queue;
+
+ private array $blocks;
public function __construct(Scope $scope, array $blocks = [])
{
diff --git a/src/Scope/Scope.php b/src/Scope/Scope.php
index 09310f1..d851eaa 100644
--- a/src/Scope/Scope.php
+++ b/src/Scope/Scope.php
@@ -6,35 +6,17 @@
class Scope
{
- /**
- * @var Scope|null
- */
- private $parent;
+ private ?Scope $parent = null;
- /**
- * @var array
- */
- private $queue;
+ private array $queue;
- /**
- * @var string
- */
- private $name;
+ private string $name;
- /**
- * @var string
- */
- private $type;
+ private string $type;
- /**
- * @var bool
- */
- private $isolated;
+ private bool $isolated;
- /**
- * @var Scope|null
- */
- private $extends;
+ private ?Scope $extends = null;
public function __construct(string $type, string $name)
{
diff --git a/src/TwigPort/Source.php b/src/TwigPort/Source.php
index c5da976..18e5462 100644
--- a/src/TwigPort/Source.php
+++ b/src/TwigPort/Source.php
@@ -11,9 +11,9 @@
final class Source
{
- private $code;
- private $name;
- private $path;
+ private string $code;
+ private string $name;
+ private string $path;
public function __construct(string $code, string $name, string $path = '')
{
diff --git a/src/TwigPort/SyntaxError.php b/src/TwigPort/SyntaxError.php
index ec7acd4..8a26eba 100644
--- a/src/TwigPort/SyntaxError.php
+++ b/src/TwigPort/SyntaxError.php
@@ -11,9 +11,9 @@
class SyntaxError extends \Exception
{
- private $lineno;
- private $columnno;
- private $source;
+ private int $lineno;
+ private int $columnno;
+ private ?Source $source;
/**
* @param string $message The error message
diff --git a/src/TwigPort/Token.php b/src/TwigPort/Token.php
index 8dec8bf..d3c1e32 100644
--- a/src/TwigPort/Token.php
+++ b/src/TwigPort/Token.php
@@ -12,9 +12,9 @@
class Token
{
private $value;
- private $type;
- private $lineno;
- private $columnno;
+ private int $type;
+ private int $lineno;
+ private int $columnno;
public const EOF_TYPE = -1;
public const TEXT_TYPE = 0;
diff --git a/src/TwigPort/TokenStream.php b/src/TwigPort/TokenStream.php
index 2960b01..49d543d 100644
--- a/src/TwigPort/TokenStream.php
+++ b/src/TwigPort/TokenStream.php
@@ -11,9 +11,9 @@
final class TokenStream
{
- private $tokens;
- private $current = 0;
- private $source;
+ private array $tokens;
+ private int $current = 0;
+ private Source $source;
public function __construct(array $tokens, Source $source = null)
{
diff --git a/src/Validator/Validator.php b/src/Validator/Validator.php
index a04d3a0..6385650 100644
--- a/src/Validator/Validator.php
+++ b/src/Validator/Validator.php
@@ -7,7 +7,7 @@
class Validator
{
- private $collectedData;
+ private array $collectedData;
public function __construct()
{