diff --git a/composer.json b/composer.json index 3a8450814e3..b9abb362327 100644 --- a/composer.json +++ b/composer.json @@ -22,16 +22,17 @@ }, "require-dev": { "cweagans/composer-patches": "^1.7", - "php-parallel-lint/php-parallel-lint": "^1.3", - "phpstan/extension-installer": "^1.3", - "phpstan/phpstan": "^1.10", + "php-parallel-lint/php-parallel-lint": "^1.4", + "phpstan/extension-installer": "^1.4", + "phpstan/phpstan": "^1.12", "phpunit/phpunit": "^10.5", - "rector/rector": "^0.19", + "rector/rector": "^1.2", "shipmonk/composer-dependency-analyser": "^1.7", - "symplify/easy-coding-standard": "^12.1", + "symplify/easy-coding-standard": "^12.3", "symplify/phpstan-extensions": "^11.4", "symplify/vendor-patches": "^11.3", - "tomasvotruba/class-leak": "^0.2.6" + "tomasvotruba/class-leak": "^1.0", + "tomasvotruba/unused-public": "^1.0" }, "autoload": { "psr-4": { diff --git a/phpstan.neon b/phpstan.neon index ff40832de50..d69db5710df 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -11,6 +11,11 @@ parameters: - '*/Source/*' - '*/Fixture/*' + unused_public: + constants: true + properties: true + methods: true + ignoreErrors: - message: '#Parameter \#1 \$commandName of method Symfony\\Component\\Console\\Application\:\:setDefaultCommand\(\) expects string, string\|null given#' diff --git a/src/ConfigLoader.php b/src/ConfigLoader.php index adca633f1e2..7e25288353d 100644 --- a/src/ConfigLoader.php +++ b/src/ConfigLoader.php @@ -21,7 +21,6 @@ use Symplify\ConfigTransformer\DependencyInjection\Loader\SkippingPhpFileLoader; use Symplify\ConfigTransformer\Enum\Format; use Symplify\ConfigTransformer\Exception\NotImplementedYetException; -use Symplify\ConfigTransformer\ValueObject\ContainerBuilderAndFileContent; final class ConfigLoader { @@ -44,7 +43,7 @@ public function __construct( public function createAndLoadContainerBuilderFromFileInfo( SplFileInfo $fileInfo, - ): ContainerBuilderAndFileContent { + ): string { $containerBuilder = new ContainerBuilder(); $delegatingLoader = $this->createLoaderBySuffix($containerBuilder, $fileInfo->getExtension()); @@ -85,7 +84,7 @@ public function createAndLoadContainerBuilderFromFileInfo( // usefull in gradual upgrade of configs } - return new ContainerBuilderAndFileContent($containerBuilder, $content); + return $content; } private function createLoaderBySuffix(ContainerBuilder $containerBuilder, string $suffix): DelegatingLoader diff --git a/src/Converter/ConfigFormatConverter.php b/src/Converter/ConfigFormatConverter.php index 97baf432103..ab5c550a55a 100644 --- a/src/Converter/ConfigFormatConverter.php +++ b/src/Converter/ConfigFormatConverter.php @@ -23,13 +23,12 @@ public function convert(SplFileInfo $fileInfo): string { $this->currentFilePathProvider->setFilePath($fileInfo->getRealPath()); - $containerBuilderAndFileContent = $this->configLoader->createAndLoadContainerBuilderFromFileInfo( + $dumpedContainerContent = $this->configLoader->createAndLoadContainerBuilderFromFileInfo( $fileInfo ); if (in_array($fileInfo->getExtension(), [Format::YAML, Format::YML], true)) { - $dumpedYaml = $containerBuilderAndFileContent->getFileContent(); - return $this->yamlToPhpConverter->convert($dumpedYaml, $fileInfo->getRealPath()); + return $this->yamlToPhpConverter->convert($dumpedContainerContent, $fileInfo->getRealPath()); } $message = sprintf('Suffix "%s" is not support yet', $fileInfo->getExtension()); diff --git a/src/Reflection/PrivatesAccessor.php b/src/Reflection/PrivatesAccessor.php index 49a9287d904..6da44f7d945 100644 --- a/src/Reflection/PrivatesAccessor.php +++ b/src/Reflection/PrivatesAccessor.php @@ -8,15 +8,6 @@ final class PrivatesAccessor { - // read private property - public static function readPrivateProperty(object $object, string $propertyName): mixed - { - $reflectionProperty = new ReflectionProperty($object, $propertyName); - $reflectionProperty->setAccessible(true); - - return $reflectionProperty->getValue($object); - } - // write private property public static function writePrivateProperty(object $object, string $propertyName, mixed $value): void { diff --git a/src/ValueObject/ContainerBuilderAndFileContent.php b/src/ValueObject/ContainerBuilderAndFileContent.php deleted file mode 100644 index 6e90c5f2102..00000000000 --- a/src/ValueObject/ContainerBuilderAndFileContent.php +++ /dev/null @@ -1,26 +0,0 @@ -containerBuilder; - } - - public function getFileContent(): string - { - return $this->fileContent; - } -} diff --git a/tests/Helper/FixtureFinder.php b/tests/Helper/FixtureFinder.php index 172080a3f96..19d56a091a0 100644 --- a/tests/Helper/FixtureFinder.php +++ b/tests/Helper/FixtureFinder.php @@ -11,6 +11,7 @@ final class FixtureFinder { /** + * @api used in tests * @return Iterator> */ public static function yieldDirectory(string $directory, string $suffix = '*.php.inc'): Iterator diff --git a/tests/Helper/FixtureSplitter.php b/tests/Helper/FixtureSplitter.php index 00e22eb8658..a98be153d35 100644 --- a/tests/Helper/FixtureSplitter.php +++ b/tests/Helper/FixtureSplitter.php @@ -10,6 +10,9 @@ use Symplify\ConfigTransformer\Tests\Helper\ValueObject\InputAndExpected; use Symplify\ConfigTransformer\Tests\Helper\ValueObject\InputFileInfoAndExpectedFileInfo; +/** + * @api used in tests + */ final class FixtureSplitter { /** diff --git a/tests/Helper/FixtureUpdater.php b/tests/Helper/FixtureUpdater.php index c47a2c7580d..61853a329cc 100644 --- a/tests/Helper/FixtureUpdater.php +++ b/tests/Helper/FixtureUpdater.php @@ -7,6 +7,9 @@ use Nette\Utils\FileSystem; use Symfony\Component\Finder\SplFileInfo; +/** + * @api used in tests + */ final class FixtureUpdater { public static function updateFixtureContent( diff --git a/tests/Helper/ValueObject/InputFileInfoAndExpectedFileInfo.php b/tests/Helper/ValueObject/InputFileInfoAndExpectedFileInfo.php index 43d2e8ae007..8dee0ae270b 100644 --- a/tests/Helper/ValueObject/InputFileInfoAndExpectedFileInfo.php +++ b/tests/Helper/ValueObject/InputFileInfoAndExpectedFileInfo.php @@ -6,6 +6,9 @@ use Symfony\Component\Finder\SplFileInfo; +/** + * @api used in tests + */ final class InputFileInfoAndExpectedFileInfo { public function __construct( @@ -19,18 +22,8 @@ public function getInputFileInfo(): SplFileInfo return $this->inputFileInfo; } - public function getExpectedFileInfo(): SplFileInfo - { - return $this->expectedFileInfo; - } - public function getExpectedFileContent(): string { return $this->expectedFileInfo->getContents(); } - - public function getExpectedFileInfoRealPath(): string - { - return $this->expectedFileInfo->getRealPath(); - } }