Skip to content

Commit a954fcd

Browse files
committed
remove nette/utils, if not needed
1 parent e92c03f commit a954fcd

15 files changed

+30
-63
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.1|^4.0",
1010
"webmozart/assert": "^1.11"
1111
},
1212
"autoload": {

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
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.1|^4.0"
1111
},
1212
"require-dev": {
1313
"nikic/php-parser": "^5.3",
1414
"phpunit/phpunit": "^11.5",
1515
"symfony/framework-bundle": "6.1.*",
1616
"symplify/easy-coding-standard": "^12.5",
17-
"tomasvotruba/class-leak": "^1.2",
17+
"tomasvotruba/class-leak": "^2.0",
1818
"rector/rector": "^2.0",
1919
"phpstan/extension-installer": "^1.4",
2020
"symplify/phpstan-extensions": "^12.0"

src/Composer/ComposerAutoloadResolver.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
namespace Symplify\PHPStanRules\Composer;
66

7-
use Nette\Utils\FileSystem;
8-
use Nette\Utils\Json;
9-
107
final class ComposerAutoloadResolver
118
{
129
/**
@@ -23,8 +20,8 @@ public function getPsr4Autoload(): array
2320
return [];
2421
}
2522

26-
$fileContent = FileSystem::read(self::COMPOSER_JSON_FILE);
27-
$composerJsonContent = Json::decode($fileContent, Json::FORCE_ARRAY);
23+
$fileContent = \Symplify\PHPStanRules\FileSystem\FileSystem::read(self::COMPOSER_JSON_FILE);
24+
$composerJsonContent = json_decode($fileContent, true, 512, JSON_THROW_ON_ERROR);
2825

2926
$autoloadPsr4 = $composerJsonContent['autoload']['psr-4'] ?? [];
3027
$autoloadDevPsr4 = $composerJsonContent['autoload-dev']['psr-4'] ?? [];

src/Enum/AttributeKey.php

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

src/FileSystem/FileSystem.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Symplify\PHPStanRules\FileSystem;
6+
7+
use Symplify\PHPStanRules\Exception\ShouldNotHappenException;
8+
9+
final class FileSystem
10+
{
11+
public static function read(string $file): string
12+
{
13+
$fileContents = file_get_contents($file);
14+
if ($fileContents === false) {
15+
throw new ShouldNotHappenException(sprintf('File "%s" was not found.', $file));
16+
}
17+
18+
return $fileContents;
19+
}
20+
}

src/Reflection/ReflectionParser.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Symplify\PHPStanRules\Reflection;
66

7-
use Nette\Utils\FileSystem;
87
use PhpParser\Node\Stmt\ClassLike;
98
use PhpParser\Node\Stmt\ClassMethod;
109
use PhpParser\NodeTraverser;
@@ -78,7 +77,7 @@ private function parseFilenameToClass(string $fileName): ClassLike|null
7877
}
7978

8079
try {
81-
$stmts = $this->parser->parse(FileSystem::read($fileName));
80+
$stmts = $this->parser->parse(\Symplify\PHPStanRules\FileSystem\FileSystem::read($fileName));
8281
if (! is_array($stmts)) {
8382
return null;
8483
}

src/Rules/AnnotateRegexClassConstWithRegexLinkRule.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
use PHPStan\Rules\Rule;
1414
use PHPStan\Rules\RuleErrorBuilder;
1515
use Symplify\PHPStanRules\Enum\RuleIdentifier;
16-
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
17-
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
1816

1917
/**
2018
* @implements Rule<ClassConst>

src/Rules/ClassNameRespectsParentSuffixRule.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use PHPStan\Reflection\ClassReflection;
1414
use PHPStan\Rules\IdentifierRuleError;
1515
use PHPStan\Rules\Rule;
16-
use PHPStan\Rules\RuleError;
1716
use PHPStan\Rules\RuleErrorBuilder;
1817
use PHPUnit\Framework\TestCase;
1918
use Rector\Rector\AbstractRector;

src/Rules/Domain/RequireExceptionNamespaceRule.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use PHPStan\Analyser\Scope;
99
use PHPStan\Node\InClassNode;
1010
use PHPStan\Rules\Rule;
11-
use PHPStan\Rules\RuleError;
1211
use PHPStan\Rules\RuleErrorBuilder;
1312
use Symplify\PHPStanRules\Enum\RuleIdentifier;
1413

0 commit comments

Comments
 (0)