Skip to content

Commit

Permalink
Merge pull request #41 from symplify/tv-bump
Browse files Browse the repository at this point in the history
update composer dependnecy analyser
  • Loading branch information
TomasVotruba authored Oct 18, 2024
2 parents be9c091 + dac17ff commit 6084ae2
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 59 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/code_analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ jobs:
name: 'Check Active Classes'
run: vendor/bin/class-leak check bin src --ansi --skip-type="\Symplify\PhpConfigPrinter\Contract\NodeVisitor\PrePrintNodeVisitorInterface"

-
name: "Composer Dependency Analyser"
run: vendor/bin/composer-dependency-analyser

name: ${{ matrix.actions.name }}
runs-on: ubuntu-latest
Expand Down
15 changes: 15 additions & 0 deletions composer-dependency-analyser.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

use ShipMonk\ComposerDependencyAnalyser\Config\Configuration;
use ShipMonk\ComposerDependencyAnalyser\Config\ErrorType;

$config = new Configuration();

return $config
// required for project config parsing
->ignoreErrorsOnPackage('symfony/expression-language', [ErrorType::UNUSED_DEPENDENCY])

// test fixtures
->addPathToExclude(__DIR__ . '/tests/Converter/ConfigFormatConverter/YamlToPhp/Source');
16 changes: 9 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"require": {
"php": ">=8.2",
"nette/utils": "^3.2",
"nikic/php-parser": "^4.19",
"sebastian/diff": "^5.0",
"symfony/config": "^6.4",
"symfony/console": "^6.4",
Expand All @@ -21,16 +22,17 @@
},
"require-dev": {
"cweagans/composer-patches": "^1.7",
"icanhazstring/composer-unused": "0.8.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",
"symplify/easy-coding-standard": "^12.1",
"rector/rector": "^1.2",
"shipmonk/composer-dependency-analyser": "^1.7",
"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.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

use Prefixed\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
Expand Down
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 6084ae2

Please sign in to comment.