Skip to content

Commit

Permalink
cleanup unused elements
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Oct 18, 2024
1 parent 1bad89e commit dac17ff
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 57 deletions.
13 changes: 7 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
5 changes: 5 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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#'
Expand Down
5 changes: 2 additions & 3 deletions src/ConfigLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -44,7 +43,7 @@ public function __construct(

public function createAndLoadContainerBuilderFromFileInfo(
SplFileInfo $fileInfo,
): ContainerBuilderAndFileContent {
): string {
$containerBuilder = new ContainerBuilder();

$delegatingLoader = $this->createLoaderBySuffix($containerBuilder, $fileInfo->getExtension());
Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions src/Converter/ConfigFormatConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
9 changes: 0 additions & 9 deletions src/Reflection/PrivatesAccessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
26 changes: 0 additions & 26 deletions src/ValueObject/ContainerBuilderAndFileContent.php

This file was deleted.

1 change: 1 addition & 0 deletions tests/Helper/FixtureFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
final class FixtureFinder
{
/**
* @api used in tests
* @return Iterator<array<int, SplFileInfo>>
*/
public static function yieldDirectory(string $directory, string $suffix = '*.php.inc'): Iterator
Expand Down
3 changes: 3 additions & 0 deletions tests/Helper/FixtureSplitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
/**
Expand Down
3 changes: 3 additions & 0 deletions tests/Helper/FixtureUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
use Nette\Utils\FileSystem;
use Symfony\Component\Finder\SplFileInfo;

/**
* @api used in tests
*/
final class FixtureUpdater
{
public static function updateFixtureContent(
Expand Down
13 changes: 3 additions & 10 deletions tests/Helper/ValueObject/InputFileInfoAndExpectedFileInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

use Symfony\Component\Finder\SplFileInfo;

/**
* @api used in tests
*/
final class InputFileInfoAndExpectedFileInfo
{
public function __construct(
Expand All @@ -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();
}
}

0 comments on commit dac17ff

Please sign in to comment.