Skip to content

Commit

Permalink
fix phpstan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
janedbal committed May 27, 2022
1 parent dd04ea3 commit daf8927
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 70 deletions.
31 changes: 31 additions & 0 deletions tests/PHPStan/Node/AttributeArgRule.php
@@ -0,0 +1,31 @@
<?php declare(strict_types = 1);

namespace PHPStan\Node;

use PhpParser\Node;
use PHPStan\Analyser\Scope;
use PHPStan\Rules\Rule;

/**
* @implements Rule<Node\Arg>
*/
class AttributeArgRule implements Rule
{

public const ERROR_MESSAGE = 'Found Arg';

public function getNodeType(): string
{
return Node\Arg::class;
}

/**
* @param Node\Arg $node
* @return string[]
*/
public function processNode(Node $node, Scope $scope): array
{
return [self::ERROR_MESSAGE];
}

}
32 changes: 9 additions & 23 deletions tests/PHPStan/Node/AttributeArgRuleTest.php
Expand Up @@ -3,43 +3,29 @@
namespace PHPStan\Node;

use PhpParser\Node;
use PHPStan\Analyser\Scope;
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleError;
use PHPStan\Testing\RuleTestCase;

/**
* @extends RuleTestCase<Rule>
*/
class AttributeArgRuleTest extends RuleTestCase
{

public const ERROR_MESSAGE = 'Found Arg';

/**
* @return Rule<Node\Arg>
*/
protected function getRule(): Rule
{
return new class() implements Rule {

public function getNodeType(): string
{
return Node\Arg::class;
}

/**
* @param Node\Arg $node
* @return RuleError[]
*/
public function processNode(Node $node, Scope $scope): array
{
return [AttributeArgRuleTest::ERROR_MESSAGE];
}

};
return new AttributeArgRule();
}

public function dataRule(): iterable
{
yield [
__DIR__ . '/data/attributes.php',
self::ERROR_MESSAGE,
[8, 16, 20, 23, 26, 27, 34, 40],
AttributeArgRule::ERROR_MESSAGE,
[8, 16, 20, 23, 26, 27, 34, 40],
];
}

Expand Down
31 changes: 31 additions & 0 deletions tests/PHPStan/Node/AttributeGroupRule.php
@@ -0,0 +1,31 @@
<?php declare(strict_types = 1);

namespace PHPStan\Node;

use PhpParser\Node;
use PHPStan\Analyser\Scope;
use PHPStan\Rules\Rule;

/**
* @implements Rule<Node\AttributeGroup>
*/
class AttributeGroupRule implements Rule
{

public const ERROR_MESSAGE = 'Found AttributeGroup';

public function getNodeType(): string
{
return Node\AttributeGroup::class;
}

/**
* @param Node\AttributeGroup $node
* @return string[]
*/
public function processNode(Node $node, Scope $scope): array
{
return [self::ERROR_MESSAGE];
}

}
32 changes: 9 additions & 23 deletions tests/PHPStan/Node/AttributeGroupRuleTest.php
Expand Up @@ -3,43 +3,29 @@
namespace PHPStan\Node;

use PhpParser\Node;
use PHPStan\Analyser\Scope;
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleError;
use PHPStan\Testing\RuleTestCase;

/**
* @extends RuleTestCase<Rule>
*/
class AttributeGroupRuleTest extends RuleTestCase
{

public const ERROR_MESSAGE = 'Found AttributeGroup';

/**
* @return Rule<Node\AttributeGroup>
*/
protected function getRule(): Rule
{
return new class() implements Rule {

public function getNodeType(): string
{
return Node\AttributeGroup::class;
}

/**
* @param Node\AttributeGroup $node
* @return RuleError[]
*/
public function processNode(Node $node, Scope $scope): array
{
return [AttributeGroupRuleTest::ERROR_MESSAGE];
}

};
return new AttributeGroupRule();
}

public function dataRule(): iterable
{
yield [
__DIR__ . '/data/attributes.php',
self::ERROR_MESSAGE,
[8, 16, 20, 23, 26, 27, 34, 40],
AttributeGroupRule::ERROR_MESSAGE,
[8, 16, 20, 23, 26, 27, 34, 40],
];
}

Expand Down
31 changes: 31 additions & 0 deletions tests/PHPStan/Node/AttributeRule.php
@@ -0,0 +1,31 @@
<?php declare(strict_types = 1);

namespace PHPStan\Node;

use PhpParser\Node;
use PHPStan\Analyser\Scope;
use PHPStan\Rules\Rule;

/**
* @implements Rule<Node\Attribute>
*/
class AttributeRule implements Rule
{

public const ERROR_MESSAGE = 'Found Attribute';

public function getNodeType(): string
{
return Node\Attribute::class;
}

/**
* @param Node\Attribute $node
* @return string[]
*/
public function processNode(Node $node, Scope $scope): array
{
return [self::ERROR_MESSAGE];
}

}
33 changes: 10 additions & 23 deletions tests/PHPStan/Node/AttributeRuleTest.php
Expand Up @@ -3,43 +3,30 @@
namespace PHPStan\Node;

use PhpParser\Node;
use PHPStan\Analyser\Scope;
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleError;
use PHPStan\Testing\RuleTestCase;
use const PHP_VERSION_ID;

/**
* @extends RuleTestCase<Rule>
*/
class AttributeRuleTest extends RuleTestCase
{

public const ERROR_MESSAGE = 'Found Attribute';

/**
* @return Rule<Node\Attribute>
*/
protected function getRule(): Rule
{
return new class() implements Rule {

public function getNodeType(): string
{
return Node\Attribute::class;
}

/**
* @param Node\Attribute $node
* @return RuleError[]
*/
public function processNode(Node $node, Scope $scope): array
{
return [AttributeRuleTest::ERROR_MESSAGE];
}

};
return new AttributeRule();
}

public function dataRule(): iterable
{
yield [
__DIR__ . '/data/attributes.php',
self::ERROR_MESSAGE,
[8, 16, 20, 23, 26, 27, 34, 40],
AttributeRule::ERROR_MESSAGE,
[8, 16, 20, 23, 26, 27, 34, 40],
];
}

Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Node/data/attributes.php
@@ -1,4 +1,4 @@
<?php
<?php // lint >= 8.0

namespace NodeCallbackCalled;

Expand Down

0 comments on commit daf8927

Please sign in to comment.