Skip to content

Commit 77fd23a

Browse files
authored
remove nette/utils, if not needed (#149)
* remove nette/utils, if not needed * misc * fix rector rule test
1 parent e92c03f commit 77fd23a

File tree

45 files changed

+244
-189
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+244
-189
lines changed

build/target-repository/.github/workflows/standalone_install.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
php_version: ['7.4', '8.0']
12+
php_version: ['7.4', '8.0', '8.3']
1313

1414
steps:
1515
# prepare empty composer.json that allows the phpstan extension plugin

build/target-repository/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"license": "MIT",
66
"require": {
77
"php": "^7.4|^8.0",
8-
"nette/utils": "^3.2.9 || ^4.0",
98
"phpstan/phpstan": "^2.0",
9+
"nette/utils": "^3.2|^4.0",
1010
"webmozart/assert": "^1.11"
1111
},
1212
"autoload": {

composer-dependency-analyser.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
->addPathToExclude(__DIR__ . '/tests/Rules/Rector/NoInstanceOfStaticReflectionRule/Fixture')
10+
->addPathToExclude(__DIR__ . '/tests/Rules/Enum/RequireUniqueEnumConstantRule/Fixture')
11+
->addPathToExclude(__DIR__ . '/tests/Rules/NoReturnArrayVariableListRule/Fixture')
12+
->addPathToExclude(__DIR__ . '/tests/Rules/ForbiddenExtendOfNonAbstractClassRule/Fixture')
13+
->addPathToExclude(__DIR__ . '/tests/Rules/PHPUnit/NoTestMocksRule/Fixture')
14+
15+
// already in phpstan/phpstan
16+
->ignoreErrorsOnPackage('nikic/php-parser', [ErrorType::DEV_DEPENDENCY_IN_PROD])
17+
18+
// rule that runs on Rector rule only
19+
->ignoreErrorsOnPackage('rector/rector', [ErrorType::DEV_DEPENDENCY_IN_PROD])
20+
21+
->ignoreErrorsOnExtension('ext-ctype', [ErrorType::SHADOW_DEPENDENCY])
22+
->ignoreErrorsOnExtension('ext-simplexml', [ErrorType::SHADOW_DEPENDENCY]);
23+
24+
// ->ignoreErrorsOnPath('/Fixture/', [\ShipMonk\ComposerDependencyAnalyser\Config\ErrorType::UNKNOWN_CLASS]);

composer.json

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,23 @@
55
"license": "MIT",
66
"require": {
77
"php": ">=8.2",
8-
"nette/utils": "^4.0",
98
"webmozart/assert": "^1.11",
10-
"phpstan/phpstan": "^2.0"
9+
"phpstan/phpstan": "^2.0",
10+
"nette/utils": "^3.2|^4.0",
11+
"phpstan/phpdoc-parser": "^2.0"
1112
},
1213
"require-dev": {
1314
"nikic/php-parser": "^5.3",
1415
"phpunit/phpunit": "^11.5",
1516
"symfony/framework-bundle": "6.1.*",
1617
"symplify/easy-coding-standard": "^12.5",
17-
"tomasvotruba/class-leak": "^1.2",
18+
"tomasvotruba/class-leak": "^2.0",
1819
"rector/rector": "^2.0",
1920
"phpstan/extension-installer": "^1.4",
20-
"symplify/phpstan-extensions": "^12.0"
21+
"symplify/phpstan-extensions": "^12.0",
22+
"tomasvotruba/unused-public": "^2.0",
23+
"tomasvotruba/type-coverage": "^2.0",
24+
"shipmonk/composer-dependency-analyser": "^1.8"
2125
},
2226
"autoload": {
2327
"psr-4": {
@@ -30,17 +34,8 @@
3034
},
3135
"classmap": [
3236
"stubs"
33-
],
34-
"files": [
3537
]
3638
},
37-
"extra": {
38-
"phpstan": {
39-
"includes": [
40-
"config/services/services.neon"
41-
]
42-
}
43-
},
4439
"config": {
4540
"platform-check": false,
4641
"allow-plugins": {
@@ -52,5 +47,12 @@
5247
"fix-cs": "vendor/bin/ecs check --fix --ansi",
5348
"phpstan": "vendor/bin/phpstan analyse --ansi",
5449
"rector": "vendor/bin/rector process --dry-run --ansi"
50+
},
51+
"extra": {
52+
"phpstan": {
53+
"includes": [
54+
"config/services/services.neon"
55+
]
56+
}
5557
}
5658
}

phpstan.neon

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,20 @@ parameters:
2323
- */Fixture/*
2424

2525
# https://github.com/TomasVotruba/unused-public
26-
# unused_public:
27-
# methods: true
28-
# properties: true
29-
# constants: true
26+
unused_public:
27+
methods: true
28+
properties: true
29+
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
@@ -54,10 +52,6 @@ parameters:
5452
# useful to have IDE know the types
5553
- identifier: phpstanApi.instanceofType
5654

57-
-
58-
identifier: class.notFound
59-
path: tests/Rules/Rector/PhpUpgradeImplementsMinPhpVersionInterfaceRule/PhpUpgradeImplementsMinPhpVersionInterfaceRuleTest.php
60-
6155
# overly detailed
6256
-
6357
message: '#Parameter \#2 \$expectedErrors of method PHPStan\\Testing\\RuleTestCase<(.*?)>::analyse\(\) expects list<array\{0: string, 1: int, 2\?: string\|null\}>, (.*?) given#'
@@ -70,3 +64,6 @@ parameters:
7064

7165
# handle next
7266
- '#Method Symplify\\PHPStanRules\\Rules\\AbstractSymplifyRule\:\:processNode\(\) should return list<PHPStan\\Rules\\IdentifierRuleError> but returns array<PHPStan\\Rules\\RuleError\|string>#'
67+
68+
# used in tests
69+
- '#Public constant "Symplify\\PHPStanRules\\(.*?)Rule\:\:ERROR_MESSAGE" is never used#'

phpunit.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
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="tests/autoload.php"
5+
colors="true"
6+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
7+
displayDetailsOnIncompleteTests="true"
8+
cacheDirectory=".phpunit.cache"
9+
>
310
<testsuite name="all">
411
<directory>tests</directory>
512
<exclude>tests/Rules/ClassNameRespectsParentSuffixRule/Fixture/</exclude>

phpunit.xml.bak

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

rector.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
$rectorConfig->skip([
3333
'*/Source/*',
3434
'*/Fixture/*',
35+
36+
\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class => [
37+
__DIR__ . '/tests/Naming/ClassToSuffixResolverTest.php',
38+
__DIR__ . '/tests/Rules/Rector/PhpUpgradeImplementsMinPhpVersionInterfaceRule/PhpUpgradeImplementsMinPhpVersionInterfaceRuleTest.php',
39+
],
3540
]);
3641

3742
$rectorConfig->ruleWithConfiguration(\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class, [

src/Composer/ComposerAutoloadResolver.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
namespace Symplify\PHPStanRules\Composer;
66

7-
use Nette\Utils\FileSystem;
8-
use Nette\Utils\Json;
7+
use Symplify\PHPStanRules\FileSystem\FileSystem;
98

109
final class ComposerAutoloadResolver
1110
{
@@ -24,7 +23,7 @@ public function getPsr4Autoload(): array
2423
}
2524

2625
$fileContent = FileSystem::read(self::COMPOSER_JSON_FILE);
27-
$composerJsonContent = Json::decode($fileContent, Json::FORCE_ARRAY);
26+
$composerJsonContent = json_decode($fileContent, true, 512, JSON_THROW_ON_ERROR);
2827

2928
$autoloadPsr4 = $composerJsonContent['autoload']['psr-4'] ?? [];
3029
$autoloadDevPsr4 = $composerJsonContent['autoload-dev']['psr-4'] ?? [];

src/Composer/Psr4PathValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function isClassNamespaceCorrect(
3030

3131
// @todo put into value object
3232
$namespaceSuffixByNamespaceBeforeClass = rtrim(
33-
Strings::substring(
33+
substr(
3434
$classNamespaceAndDirectory->getNamespaceBeforeClass(),
3535
strlen($classNamespaceAndDirectory->getNamespace())
3636
),

0 commit comments

Comments
 (0)