Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Add property type declarations #541

Merged
merged 1 commit into from Jan 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 21 additions & 1 deletion psalm-baseline.xml
@@ -1,5 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.9.2@00c062267d6e3229d91a1939992987e2d46f2393">
<files psalm-version="4.18.1@dda05fa913f4dc6eb3386f2f7ce5a45d37a71bcb">
<file src="src/RuleSet/Php73.php">
<NonInvariantDocblockPropertyType occurrences="1">
<code>$rules</code>
</NonInvariantDocblockPropertyType>
</file>
<file src="src/RuleSet/Php74.php">
<NonInvariantDocblockPropertyType occurrences="1">
<code>$rules</code>
</NonInvariantDocblockPropertyType>
</file>
<file src="src/RuleSet/Php80.php">
<NonInvariantDocblockPropertyType occurrences="1">
<code>$rules</code>
</NonInvariantDocblockPropertyType>
</file>
<file src="src/RuleSet/Php81.php">
<NonInvariantDocblockPropertyType occurrences="1">
<code>$rules</code>
</NonInvariantDocblockPropertyType>
</file>
<file src="test/Unit/RuleSet/AbstractRuleSetTestCase.php">
<InternalClass occurrences="1">
<code>new FixerFactory()</code>
Expand Down
12 changes: 3 additions & 9 deletions src/RuleSet/AbstractRuleSet.php
Expand Up @@ -120,20 +120,14 @@ abstract class AbstractRuleSet implements RuleSet
'version',
];

/**
* @var string
*/
protected $name = '';
protected string $name = '';

/**
* @var array<string, array|bool>
*/
protected $rules = [];
protected array $rules = [];

/**
* @var int
*/
protected $targetPhpVersion = 0;
protected int $targetPhpVersion = 0;

final public function __construct(?string $header = null)
{
Expand Down
6 changes: 3 additions & 3 deletions src/RuleSet/Php73.php
Expand Up @@ -15,8 +15,8 @@

final class Php73 extends AbstractRuleSet implements ExplicitRuleSet
{
protected $name = 'ergebnis (PHP 7.3)';
protected $rules = [
protected string $name = 'ergebnis (PHP 7.3)';
protected array $rules = [
'align_multiline_comment' => [
'comment_type' => 'all_multiline',
],
Expand Down Expand Up @@ -717,5 +717,5 @@ final class Php73 extends AbstractRuleSet implements ExplicitRuleSet
'less_and_greater' => true,
],
];
protected $targetPhpVersion = 70300;
protected int $targetPhpVersion = 70300;
}
6 changes: 3 additions & 3 deletions src/RuleSet/Php74.php
Expand Up @@ -15,8 +15,8 @@

final class Php74 extends AbstractRuleSet implements ExplicitRuleSet
{
protected $name = 'ergebnis (PHP 7.4)';
protected $rules = [
protected string $name = 'ergebnis (PHP 7.4)';
protected array $rules = [
'align_multiline_comment' => [
'comment_type' => 'all_multiline',
],
Expand Down Expand Up @@ -719,5 +719,5 @@ final class Php74 extends AbstractRuleSet implements ExplicitRuleSet
'less_and_greater' => true,
],
];
protected $targetPhpVersion = 70400;
protected int $targetPhpVersion = 70400;
}
6 changes: 3 additions & 3 deletions src/RuleSet/Php80.php
Expand Up @@ -15,8 +15,8 @@

final class Php80 extends AbstractRuleSet implements ExplicitRuleSet
{
protected $name = 'ergebnis (PHP 8.0)';
protected $rules = [
protected string $name = 'ergebnis (PHP 8.0)';
protected array $rules = [
'align_multiline_comment' => [
'comment_type' => 'all_multiline',
],
Expand Down Expand Up @@ -720,5 +720,5 @@ final class Php80 extends AbstractRuleSet implements ExplicitRuleSet
'less_and_greater' => true,
],
];
protected $targetPhpVersion = 80000;
protected int $targetPhpVersion = 80000;
}
6 changes: 3 additions & 3 deletions src/RuleSet/Php81.php
Expand Up @@ -15,8 +15,8 @@

final class Php81 extends AbstractRuleSet implements ExplicitRuleSet
{
protected $name = 'ergebnis (PHP 8.1)';
protected $rules = [
protected string $name = 'ergebnis (PHP 8.1)';
protected array $rules = [
'align_multiline_comment' => [
'comment_type' => 'all_multiline',
],
Expand Down Expand Up @@ -720,5 +720,5 @@ final class Php81 extends AbstractRuleSet implements ExplicitRuleSet
'less_and_greater' => true,
],
];
protected $targetPhpVersion = 80100;
protected int $targetPhpVersion = 80100;
}
12 changes: 3 additions & 9 deletions test/Double/Config/RuleSet/DummyRuleSet.php
Expand Up @@ -17,20 +17,14 @@

final class DummyRuleSet implements Config\RuleSet
{
/**
* @var string
*/
private $name;
private string $name;

/**
* @var array<string, array|bool>
*/
private $rules;
private array $rules;

/**
* @var int
*/
private $phpVersion;
private int $phpVersion;

/**
* @param array<string, array|bool> $rules
Expand Down
15 changes: 3 additions & 12 deletions test/Unit/RuleSet/AbstractRuleSetTestCase.php
Expand Up @@ -124,20 +124,11 @@ abstract class AbstractRuleSetTestCase extends Framework\TestCase
'version',
];

/**
* @var string
*/
protected $name;
protected string $name;

/**
* @var array
*/
protected $rules;
protected array $rules;

/**
* @var int
*/
protected $targetPhpVersion;
protected int $targetPhpVersion;

final public function testDefaults(): void
{
Expand Down
6 changes: 3 additions & 3 deletions test/Unit/RuleSet/Php73Test.php
Expand Up @@ -21,8 +21,8 @@
*/
final class Php73Test extends ExplicitRuleSetTestCase
{
protected $name = 'ergebnis (PHP 7.3)';
protected $rules = [
protected string $name = 'ergebnis (PHP 7.3)';
protected array $rules = [
'align_multiline_comment' => [
'comment_type' => 'all_multiline',
],
Expand Down Expand Up @@ -723,5 +723,5 @@ final class Php73Test extends ExplicitRuleSetTestCase
'less_and_greater' => true,
],
];
protected $targetPhpVersion = 70300;
protected int $targetPhpVersion = 70300;
}
6 changes: 3 additions & 3 deletions test/Unit/RuleSet/Php74Test.php
Expand Up @@ -21,8 +21,8 @@
*/
final class Php74Test extends ExplicitRuleSetTestCase
{
protected $name = 'ergebnis (PHP 7.4)';
protected $rules = [
protected string $name = 'ergebnis (PHP 7.4)';
protected array $rules = [
'align_multiline_comment' => [
'comment_type' => 'all_multiline',
],
Expand Down Expand Up @@ -725,5 +725,5 @@ final class Php74Test extends ExplicitRuleSetTestCase
'less_and_greater' => true,
],
];
protected $targetPhpVersion = 70400;
protected int $targetPhpVersion = 70400;
}
6 changes: 3 additions & 3 deletions test/Unit/RuleSet/Php80Test.php
Expand Up @@ -21,8 +21,8 @@
*/
final class Php80Test extends ExplicitRuleSetTestCase
{
protected $name = 'ergebnis (PHP 8.0)';
protected $rules = [
protected string $name = 'ergebnis (PHP 8.0)';
protected array $rules = [
'align_multiline_comment' => [
'comment_type' => 'all_multiline',
],
Expand Down Expand Up @@ -726,5 +726,5 @@ final class Php80Test extends ExplicitRuleSetTestCase
'less_and_greater' => true,
],
];
protected $targetPhpVersion = 80000;
protected int $targetPhpVersion = 80000;
}
6 changes: 3 additions & 3 deletions test/Unit/RuleSet/Php81Test.php
Expand Up @@ -21,8 +21,8 @@
*/
final class Php81Test extends ExplicitRuleSetTestCase
{
protected $name = 'ergebnis (PHP 8.1)';
protected $rules = [
protected string $name = 'ergebnis (PHP 8.1)';
protected array $rules = [
'align_multiline_comment' => [
'comment_type' => 'all_multiline',
],
Expand Down Expand Up @@ -726,5 +726,5 @@ final class Php81Test extends ExplicitRuleSetTestCase
'less_and_greater' => true,
],
];
protected $targetPhpVersion = 80100;
protected int $targetPhpVersion = 80100;
}