Skip to content

Commit a350e62

Browse files
committed
fix rector rule test
1 parent d340464 commit a350e62

23 files changed

+110
-89
lines changed

build/target-repository/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"require": {
77
"php": "^7.4|^8.0",
88
"phpstan/phpstan": "^2.0",
9-
"nette/utils": "^3.1|^4.0",
9+
"nette/utils": "^3.2|^4.0",
1010
"webmozart/assert": "^1.11"
1111
},
1212
"autoload": {

composer-dependency-analyser.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use ShipMonk\ComposerDependencyAnalyser\Config\Configuration;
6+
use ShipMonk\ComposerDependencyAnalyser\Config\ErrorType;
7+
8+
return (new Configuration())->addPathToScan(__DIR__ . '/src', false)
9+
// already in phpstan/phpstan
10+
->ignoreErrorsOnPackage('nikic/php-parser', [ErrorType::DEV_DEPENDENCY_IN_PROD]);
11+
// ->ignoreErrorsOnPath('/Fixture/', [\ShipMonk\ComposerDependencyAnalyser\Config\ErrorType::UNKNOWN_CLASS]);

composer.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"php": ">=8.2",
88
"webmozart/assert": "^1.11",
99
"phpstan/phpstan": "^2.0",
10-
"nette/utils": "^3.1|^4.0"
10+
"nette/utils": "^3.2|^4.0",
11+
"phpstan/phpdoc-parser": "^2.0"
1112
},
1213
"require-dev": {
1314
"nikic/php-parser": "^5.3",
@@ -18,7 +19,9 @@
1819
"rector/rector": "^2.0",
1920
"phpstan/extension-installer": "^1.4",
2021
"symplify/phpstan-extensions": "^12.0",
21-
"tomasvotruba/unused-public": "^2.0"
22+
"tomasvotruba/unused-public": "^2.0",
23+
"tomasvotruba/type-coverage": "^2.0",
24+
"shipmonk/composer-dependency-analyser": "^1.8"
2225
},
2326
"autoload": {
2427
"psr-4": {

phpstan.neon

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,15 @@ parameters:
2828
properties: true
2929
constants: true
3030

31-
# type_coverage:
32-
# return: 99
33-
# param: 99
34-
# property: 99
31+
type_coverage:
32+
return: 99
33+
param: 99
34+
property: 99
3535

3636
ignoreErrors:
3737
# needless generics
3838
- '#Class Symplify\\PHPStanRules\\(.*?)Rule implements generic interface PHPStan\\Rules\\Rule but does not specify its types\: TNodeType#'
3939

40-
- '#Class PHP_CodeSniffer\\Sniffs\\Sniff not found#'
41-
4240
- '#Method Symplify\\PHPStanRules\\Reflection\\ReflectionParser\:\:parseNativeClassReflection\(\) has parameter \$reflectionClass with generic class ReflectionClass but does not specify its types\: T#'
4341

4442
# overly detailed

phpunit.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
<?xml version="1.0"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" cacheDirectory=".phpunit.cache">
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
7+
displayDetailsOnIncompleteTests="true"
8+
cacheDirectory=".phpunit.cache">
39
<testsuite name="all">
410
<directory>tests</directory>
511
<exclude>tests/Rules/ClassNameRespectsParentSuffixRule/Fixture/</exclude>

phpunit.xml.bak

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/Composer/ComposerAutoloadResolver.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Symplify\PHPStanRules\Composer;
66

7+
use Symplify\PHPStanRules\FileSystem\FileSystem;
8+
79
final class ComposerAutoloadResolver
810
{
911
/**
@@ -20,7 +22,7 @@ public function getPsr4Autoload(): array
2022
return [];
2123
}
2224

23-
$fileContent = \Symplify\PHPStanRules\FileSystem\FileSystem::read(self::COMPOSER_JSON_FILE);
25+
$fileContent = FileSystem::read(self::COMPOSER_JSON_FILE);
2426
$composerJsonContent = json_decode($fileContent, true, 512, JSON_THROW_ON_ERROR);
2527

2628
$autoloadPsr4 = $composerJsonContent['autoload']['psr-4'] ?? [];

src/Enum/ClassName.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,39 @@ final class ClassName
1515
* @var string
1616
*/
1717
public const NETTE_STRINGS = 'Nette\Utils\Strings';
18+
19+
/**
20+
* @var string
21+
*/
22+
public const SYMFONY_ABSTRACT_CONTROLLER = 'Symfony\Bundle\FrameworkBundle\Controller\AbstractController';
23+
24+
/**
25+
* @var string
26+
*/
27+
public const PHPUNIT_TEST_CASE = 'PHPUnit\Framework\TestCase';
28+
29+
/**
30+
* @var string
31+
*/
32+
public const EVENT_DISPATCHER_INTERFACE = 'Symfony\Component\EventDispatcher\EventSubscriberInterface';
33+
34+
/**
35+
* @var string
36+
*/
37+
public const SNIFF = 'PHP_CodeSniffer\Sniffs\Sniff';
38+
39+
/**
40+
* @var string
41+
*/
42+
public const RECTOR = 'Rector\Contract\Rector\RectorInterface';
43+
44+
/**
45+
* @var string
46+
*/
47+
public const ABSTRACT_RECTOR = 'Rector\Rector\AbstractRector';
48+
49+
/**
50+
* @var string
51+
*/
52+
public const CONFIGURABLE_RECTOR = 'Rector\Contract\Rector\ConfigurableRectorInterface';
1853
}

src/Naming/ClassToSuffixResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private function removeAbstractInterfacePrefixSuffix(string $parentType): string
4040
}
4141

4242
if (\str_starts_with($parentType, 'Abstract')) {
43-
return substr($parentType, (int) strlen('Abstract'));
43+
return substr($parentType, strlen('Abstract'));
4444
}
4545

4646
return $parentType;

src/Reflection/Nested/Some.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Symplify\PHPStanRules\Reflection;
4+
5+
class Some
6+
{
7+
}

0 commit comments

Comments
 (0)