Skip to content

Commit

Permalink
Fix: Add property type declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Jan 5, 2023
1 parent 261b6ef commit a6f9850
Show file tree
Hide file tree
Showing 20 changed files with 78 additions and 307 deletions.
143 changes: 12 additions & 131 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@
<MissingParamType occurrences="1">
<code>$finder</code>
</MissingParamType>
<MissingPropertyType occurrences="1">
<code>$display</code>
</MissingPropertyType>
<MixedInferredReturnType occurrences="1">
<code>string</code>
</MixedInferredReturnType>
<MixedReturnStatement occurrences="1">
<code>$this-&gt;display</code>
</MixedReturnStatement>
<NullableReturnStatement occurrences="1">
<code>$this-&gt;loader</code>
</NullableReturnStatement>
Expand Down Expand Up @@ -117,12 +108,15 @@
</PossiblyNullArgument>
</file>
<file src="src/Console/ContainerAwareCommand.php">
<InvalidNullableReturnType occurrences="1">
<code>Container</code>
</InvalidNullableReturnType>
<MissingReturnType occurrences="1">
<code>setContainer</code>
</MissingReturnType>
<PropertyNotSetInConstructor occurrences="1">
<code>$container</code>
</PropertyNotSetInConstructor>
<NullableReturnStatement occurrences="1">
<code>$this-&gt;container</code>
</NullableReturnStatement>
</file>
<file src="src/Console/LintCommand.php">
<InvalidMethodCall occurrences="1">
Expand Down Expand Up @@ -275,10 +269,6 @@
</MissingReturnType>
</file>
<file src="src/RegEngine/Checker/Handler.php">
<DocblockTypeContradiction occurrences="2">
<code>!$this-&gt;parent</code>
<code>$this-&gt;parent</code>
</DocblockTypeContradiction>
<InvalidArgument occurrences="2">
<code>$size</code>
<code>$size</code>
Expand Down Expand Up @@ -310,9 +300,6 @@
<code>getText</code>
<code>getText</code>
</MixedMethodCall>
<PossiblyNullPropertyAssignmentValue occurrences="1">
<code>$parent</code>
</PossiblyNullPropertyAssignmentValue>
<PropertyNotSetInConstructor occurrences="1">
<code>$callback</code>
</PropertyNotSetInConstructor>
Expand All @@ -336,27 +323,10 @@
</UnusedVariable>
</file>
<file src="src/RegEngine/Checker/Report.php">
<MissingPropertyType occurrences="2">
<code>$errors</code>
<code>$unrecognizedExpressions</code>
</MissingPropertyType>
<MixedArgument occurrences="1">
<code>$this-&gt;errors</code>
</MixedArgument>
<MixedArrayAssignment occurrences="2">
<code>$this-&gt;errors[]</code>
<code>$this-&gt;unrecognizedExpressions[]</code>
</MixedArrayAssignment>
<MixedInferredReturnType occurrences="1">
<code>array</code>
</MixedInferredReturnType>
<MixedMethodCall occurrences="2">
<code>getColumn</code>
<code>getColumn</code>
</MixedMethodCall>
<MixedReturnStatement occurrences="1">
<code>$this-&gt;unrecognizedExpressions</code>
</MixedReturnStatement>
</file>
<file src="src/RegEngine/Checker/RuleChecker.php">
<MissingParamType occurrences="2">
Expand Down Expand Up @@ -1490,37 +1460,6 @@
<code>$namespace</code>
</PossiblyNullArgument>
</file>
<file src="src/TwigPort/SyntaxError.php">
<MissingPropertyType occurrences="3">
<code>$columnno</code>
<code>$lineno</code>
<code>$source</code>
</MissingPropertyType>
<MixedInferredReturnType occurrences="6">
<code>Source|null</code>
<code>int</code>
<code>int</code>
<code>string|null</code>
<code>string|null</code>
<code>string|null</code>
</MixedInferredReturnType>
<MixedMethodCall occurrences="3">
<code>getCode</code>
<code>getName</code>
<code>getPath</code>
</MixedMethodCall>
<MixedReturnStatement occurrences="9">
<code>$this-&gt;columnno</code>
<code>$this-&gt;lineno</code>
<code>$this-&gt;source</code>
<code>$this-&gt;source ? $this-&gt;source-&gt;getCode() : null</code>
<code>$this-&gt;source ? $this-&gt;source-&gt;getCode() : null</code>
<code>$this-&gt;source ? $this-&gt;source-&gt;getName() : null</code>
<code>$this-&gt;source ? $this-&gt;source-&gt;getName() : null</code>
<code>$this-&gt;source ? $this-&gt;source-&gt;getPath() : null</code>
<code>$this-&gt;source ? $this-&gt;source-&gt;getPath() : null</code>
</MixedReturnStatement>
</file>
<file src="src/TwigPort/Token.php">
<MissingParamType occurrences="3">
<code>$type</code>
Expand Down Expand Up @@ -1549,59 +1488,25 @@
<code>$type</code>
<code>$value</code>
</MissingParamType>
<MissingPropertyType occurrences="3">
<code>$current</code>
<code>$source</code>
<code>$tokens</code>
</MissingPropertyType>
<MissingReturnType occurrences="2">
<code>injectTokens</code>
<code>nextIf</code>
</MissingReturnType>
<MixedArgument occurrences="18">
<MixedArgument occurrences="10">
<code>$column</code>
<code>$column</code>
<code>$column</code>
<code>$line</code>
<code>$line</code>
<code>$line</code>
<code>$this-&gt;current</code>
<code>$this-&gt;current</code>
<code>$this-&gt;source</code>
<code>$this-&gt;source</code>
<code>$this-&gt;source</code>
<code>$this-&gt;tokens</code>
<code>$this-&gt;tokens</code>
<code>$this-&gt;tokens</code>
<code>$token-&gt;getType()</code>
<code>$token-&gt;getValue()</code>
<code>$type</code>
<code>$value</code>
</MixedArgument>
<MixedArrayAccess occurrences="9">
<code>$this-&gt;tokens[$this-&gt;current + $number - 1]</code>
<code>$this-&gt;tokens[$this-&gt;current + $number]</code>
<code>$this-&gt;tokens[$this-&gt;current - 1]</code>
<code>$this-&gt;tokens[$this-&gt;current - 1]</code>
<code>$this-&gt;tokens[$this-&gt;current]</code>
<code>$this-&gt;tokens[$this-&gt;current]</code>
<code>$this-&gt;tokens[$this-&gt;current]</code>
<code>$this-&gt;tokens[$this-&gt;current]</code>
<code>$this-&gt;tokens[$this-&gt;current]</code>
</MixedArrayAccess>
<MixedArrayOffset occurrences="11">
<code>$this-&gt;tokens[$this-&gt;current + $number - 1]</code>
<code>$this-&gt;tokens[$this-&gt;current + $number]</code>
<code>$this-&gt;tokens[$this-&gt;current + $number]</code>
<code>$this-&gt;tokens[$this-&gt;current - 1]</code>
<code>$this-&gt;tokens[$this-&gt;current - 1]</code>
<code>$this-&gt;tokens[$this-&gt;current]</code>
<code>$this-&gt;tokens[$this-&gt;current]</code>
<code>$this-&gt;tokens[$this-&gt;current]</code>
<code>$this-&gt;tokens[$this-&gt;current]</code>
<code>$this-&gt;tokens[$this-&gt;current]</code>
<code>$this-&gt;tokens[++$this-&gt;current]</code>
</MixedArrayOffset>
<MixedArgumentTypeCoercion occurrences="1">
<code>$this-&gt;tokens</code>
</MixedArgumentTypeCoercion>
<MixedAssignment occurrences="9">
<code>$column</code>
<code>$column</code>
Expand All @@ -1613,8 +1518,7 @@
<code>$token</code>
<code>$token</code>
</MixedAssignment>
<MixedInferredReturnType occurrences="6">
<code>Source</code>
<MixedInferredReturnType occurrences="5">
<code>Token</code>
<code>Token</code>
<code>Token</code>
Expand All @@ -1636,16 +1540,7 @@
<code>test</code>
<code>test</code>
</MixedMethodCall>
<MixedOperand occurrences="6">
<code>$this-&gt;current</code>
<code>$this-&gt;current</code>
<code>$this-&gt;current</code>
<code>$this-&gt;current</code>
<code>$this-&gt;current</code>
<code>$this-&gt;current</code>
</MixedOperand>
<MixedReturnStatement occurrences="6">
<code>$this-&gt;source</code>
<MixedReturnStatement occurrences="5">
<code>$this-&gt;tokens[$this-&gt;current + $number]</code>
<code>$this-&gt;tokens[$this-&gt;current - 1]</code>
<code>$this-&gt;tokens[$this-&gt;current]</code>
Expand Down Expand Up @@ -1989,20 +1884,6 @@
<code>$token</code>
</UnusedVariable>
</file>
<file src="src/Validator/Validator.php">
<MissingPropertyType occurrences="1">
<code>$collectedData</code>
</MissingPropertyType>
<MixedArrayAssignment occurrences="1">
<code>$this-&gt;collectedData[get_class($rule)]</code>
</MixedArrayAssignment>
<MixedInferredReturnType occurrences="1">
<code>array</code>
</MixedInferredReturnType>
<MixedReturnStatement occurrences="1">
<code>$this-&gt;collectedData</code>
</MixedReturnStatement>
</file>
<file src="src/Validator/Violation.php">
<MissingParamType occurrences="4">
<code>$column</code>
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
{
Expand Down
19 changes: 4 additions & 15 deletions src/Config/ConfigResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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',
Expand All @@ -49,10 +41,7 @@ final class ConfigResolver

private $finders;

/**
* @var Container
*/
private $container;
private Container $container;

private $cwd;

Expand Down
5 changes: 1 addition & 4 deletions src/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
5 changes: 1 addition & 4 deletions src/Console/ContainerAwareCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@

class ContainerAwareCommand extends Command
{
/**
* @var Container
*/
private $container;
private ?Container $container = null;

public function setContainer(Container $container)
{
Expand Down
33 changes: 9 additions & 24 deletions src/RegEngine/Checker/Capture.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
5 changes: 1 addition & 4 deletions src/RegEngine/Checker/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ class Handler
*/
private $callback;

/**
* @var Handler
*/
private $parent;
private ?Handler $parent;

public static function create(): self
{
Expand Down
15 changes: 3 additions & 12 deletions src/RegEngine/Checker/Regex.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/RegEngine/Checker/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

class Report
{
private $errors;
private array $errors;

private $unrecognizedExpressions;
private array $unrecognizedExpressions;

public function __construct()
{
Expand Down
Loading

0 comments on commit a6f9850

Please sign in to comment.