-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename attribute tests and drop
ClassWithAttributesAllow
(#230)
... which was a copy of `ClassWithAttributes` but with wrong comments. Instead of making the comments right, I've dropped it and had to split and rename some tests.
- Loading branch information
Showing
6 changed files
with
107 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace Spaze\PHPStan\Rules\Disallowed\Usages; | ||
|
||
use Attributes\AttributeEntity; | ||
use PHPStan\Rules\Rule; | ||
use PHPStan\Testing\RuleTestCase; | ||
use Spaze\PHPStan\Rules\Disallowed\DisallowedAttributeFactory; | ||
use Spaze\PHPStan\Rules\Disallowed\RuleErrors\DisallowedAttributeRuleErrors; | ||
|
||
class AttributeUsagesAllowInPathTest extends RuleTestCase | ||
{ | ||
|
||
protected function getRule(): Rule | ||
{ | ||
$container = self::getContainer(); | ||
return new AttributeUsages( | ||
$container->getByType(DisallowedAttributeRuleErrors::class), | ||
$container->getByType(DisallowedAttributeFactory::class), | ||
[ | ||
[ | ||
'attribute' => [ | ||
AttributeEntity::class, | ||
], | ||
'allowIn' => [ | ||
__DIR__ . '/../src/ClassWithAttributes.php', | ||
], | ||
], | ||
[ | ||
'attribute' => '#[\Attributes\AttributeClass()]', | ||
'allowIn' => [ | ||
__DIR__ . '/../src/ClassWithAttributes.php', | ||
], | ||
], | ||
] | ||
); | ||
} | ||
|
||
|
||
public function testRule(): void | ||
{ | ||
// Based on the configuration above, no errors in this file: | ||
$this->analyse([__DIR__ . '/../src/ClassWithAttributes.php'], []); | ||
} | ||
|
||
|
||
public static function getAdditionalConfigFiles(): array | ||
{ | ||
return [ | ||
__DIR__ . '/../../extension.neon', | ||
]; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace Attributes; | ||
|
||
use Waldo\Quux\Blade; | ||
|
||
#[AttributeEntity] | ||
class ClassWithAttributes | ||
{ | ||
|
||
#[AttributeEntity] | ||
private const MAYO = true; | ||
|
||
#[AttributeEntity] | ||
public $cheddar = 'plz'; | ||
|
||
#[AttributeEntity] | ||
public static $pepper = 'ofc'; | ||
|
||
|
||
#[AttributeEntity(repositoryClass: UserRepository::class, readOnly: false)] | ||
public function hasAvocado(): bool | ||
{ | ||
} | ||
|
||
|
||
#[AttributeEntity(UserRepository::class)] | ||
public function hasTuna(): bool | ||
{ | ||
} | ||
|
||
|
||
#[AttributeEntity(Blade::class)] | ||
public function hasKetchup(): bool | ||
{ | ||
} | ||
|
||
|
||
#[AttributeClass()] | ||
public function hasPineapple( | ||
#[AttributeEntity] | ||
bool $really | ||
): bool { | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.