Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

[SymfonyPHPConfig] Deprecate, as just 1 helper class #3941

Merged
merged 1 commit into from
Feb 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/code_analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ jobs:
packages/easy-ci/bin/easy-ci check-active-class packages/simple-php-doc-parser --ansi
packages/easy-ci/bin/easy-ci check-active-class packages/skipper --ansi
packages/easy-ci/bin/easy-ci check-active-class packages/smart-file-system --ansi
packages/easy-ci/bin/easy-ci check-active-class packages/symfony-php-config --ansi
packages/easy-ci/bin/easy-ci check-active-class packages/symfony-static-dumper --ansi
packages/easy-ci/bin/easy-ci check-active-class packages/symplify-kernel --ansi
packages/easy-ci/bin/easy-ci check-active-class packages/template-phpstan-compiler --ansi
Expand Down
3 changes: 0 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@
"Symplify\\SimplePhpDocParser\\": "packages/simple-php-doc-parser/src",
"Symplify\\Skipper\\": "packages/skipper/src",
"Symplify\\SmartFileSystem\\": "packages/smart-file-system/src",
"Symplify\\SymfonyPhpConfig\\": "packages/symfony-php-config/src",
"Symplify\\SymfonyStaticDumper\\": "packages/symfony-static-dumper/src",
"Symplify\\SymplifyKernel\\": "packages/symplify-kernel/src",
"Symplify\\TemplatePHPStanCompiler\\": "packages/template-phpstan-compiler/src",
Expand Down Expand Up @@ -168,7 +167,6 @@
"Symplify\\SimplePhpDocParser\\Tests\\": "packages/simple-php-doc-parser/tests",
"Symplify\\Skipper\\Tests\\": "packages/skipper/tests",
"Symplify\\SmartFileSystem\\Tests\\": "packages/smart-file-system/tests",
"Symplify\\SymfonyPhpConfig\\Tests\\": "packages/symfony-php-config/tests",
"Symplify\\SymfonyStaticDumper\\Tests\\": "packages/symfony-static-dumper/tests",
"Symplify\\SymfonyStaticDumper\\Tests\\TestProject\\": "packages/symfony-static-dumper/tests/test_project/src",
"Symplify\\SymplifyKernel\\Tests\\": "packages/symplify-kernel/tests",
Expand Down Expand Up @@ -202,7 +200,6 @@
"symplify/simple-php-doc-parser": "10.0.24",
"symplify/skipper": "10.0.24",
"symplify/smart-file-system": "10.0.24",
"symplify/symfony-php-config": "10.0.24",
"symplify/symfony-static-dumper": "10.0.24",
"symplify/symplify-kernel": "10.0.24",
"symplify/template-phpstan-compiler": "10.0.24",
Expand Down
1 change: 0 additions & 1 deletion packages/amnesia/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"symplify/phpstan-rules": "<10.0.24",
"symplify/easy-testing": "<10.0.24",
"symplify/rule-doc-generator-contracts": "<10.0.24",
"symplify/symfony-php-config": "<10.0.24",
"symplify/simple-php-doc-parser": "<10.0.24",
"symplify/php-config-printer": "<10.0.24",
"symplify/autowire-array-parameter": "<10.0.24",
Expand Down
1 change: 0 additions & 1 deletion packages/astral/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"symplify/phpstan-rules": "<10.0.24",
"symplify/easy-testing": "<10.0.24",
"symplify/rule-doc-generator-contracts": "<10.0.24",
"symplify/symfony-php-config": "<10.0.24",
"symplify/simple-php-doc-parser": "<10.0.24",
"symplify/php-config-printer": "<10.0.24",
"symplify/markdown-diff": "<10.0.24",
Expand Down
1 change: 0 additions & 1 deletion packages/autowire-array-parameter/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"symplify/phpstan-rules": "<10.0.24",
"symplify/easy-testing": "<10.0.24",
"symplify/rule-doc-generator-contracts": "<10.0.24",
"symplify/symfony-php-config": "<10.0.24",
"symplify/simple-php-doc-parser": "<10.0.24",
"symplify/php-config-printer": "<10.0.24",
"symplify/markdown-diff": "<10.0.24",
Expand Down
1 change: 0 additions & 1 deletion packages/coding-standard/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"symplify/easy-coding-standard": "<10.0.24",
"symplify/phpstan-rules": "<10.0.24",
"symplify/easy-testing": "<10.0.24",
"symplify/symfony-php-config": "<10.0.24",
"symplify/simple-php-doc-parser": "<10.0.24",
"symplify/php-config-printer": "<10.0.24",
"symplify/markdown-diff": "<10.0.24",
Expand Down
1 change: 0 additions & 1 deletion packages/composer-json-manipulator/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"symplify/phpstan-rules": "<10.0.24",
"symplify/easy-testing": "<10.0.24",
"symplify/rule-doc-generator-contracts": "<10.0.24",
"symplify/symfony-php-config": "<10.0.24",
"symplify/simple-php-doc-parser": "<10.0.24",
"symplify/php-config-printer": "<10.0.24",
"symplify/autowire-array-parameter": "<10.0.24",
Expand Down
1 change: 0 additions & 1 deletion packages/config-transformer/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"symplify/phpstan-rules": "<10.0.24",
"symplify/easy-testing": "<10.0.24",
"symplify/rule-doc-generator-contracts": "<10.0.24",
"symplify/symfony-php-config": "<10.0.24",
"symplify/simple-php-doc-parser": "<10.0.24",
"symplify/autowire-array-parameter": "<10.0.24",
"symplify/markdown-diff": "<10.0.24",
Expand Down
1 change: 0 additions & 1 deletion packages/easy-ci/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
"symplify/phpstan-rules": "<10.0.24",
"symplify/easy-testing": "<10.0.24",
"symplify/rule-doc-generator-contracts": "<10.0.24",
"symplify/symfony-php-config": "<10.0.24",
"symplify/simple-php-doc-parser": "<10.0.24",
"symplify/php-config-printer": "<10.0.24",
"symplify/autowire-array-parameter": "<10.0.24",
Expand Down
2 changes: 1 addition & 1 deletion packages/easy-coding-standard/build/downgrade-ecs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ BUILD_DIRECTORY=$1
note "Running downgrade in '$BUILD_DIRECTORY' directory\n"

# 2. provide directories to downgrade, joined by spaces to run at once
directories="vendor/symfony vendor/psr;vendor/symplify config bin src packages;vendor/composer;vendor/doctrine vendor/friendsofphp vendor/nette;vendor/php-cs-fixer vendor/sebastian vendor/squizlabs vendor/react vendor/clue"
directories="vendor/symfony vendor/psr;vendor/symplify config bin src packages;vendor/composer;vendor/doctrine vendor/friendsofphp vendor/nette;vendor/php-cs-fixer vendor/squizlabs vendor/react vendor/clue"

# split array see https://stackoverflow.com/a/1407098/1348344
export IFS=";"
Expand Down
1 change: 0 additions & 1 deletion packages/easy-coding-standard/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"symplify/composer-json-manipulator": "<10.0.24",
"symplify/phpstan-rules": "<10.0.24",
"symplify/rule-doc-generator-contracts": "<10.0.24",
"symplify/symfony-php-config": "<10.0.24",
"symplify/simple-php-doc-parser": "<10.0.24",
"symplify/php-config-printer": "<10.0.24",
"symplify/markdown-diff": "<10.0.24",
Expand Down
1 change: 0 additions & 1 deletion packages/easy-parallel/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"symplify/phpstan-rules": "<10.0.24",
"symplify/easy-testing": "<10.0.24",
"symplify/rule-doc-generator-contracts": "<10.0.24",
"symplify/symfony-php-config": "<10.0.24",
"symplify/simple-php-doc-parser": "<10.0.24",
"symplify/php-config-printer": "<10.0.24",
"symplify/autowire-array-parameter": "<10.0.24",
Expand Down
1 change: 0 additions & 1 deletion packages/easy-testing/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"symplify/easy-coding-standard": "<10.0.24",
"symplify/phpstan-rules": "<10.0.24",
"symplify/rule-doc-generator-contracts": "<10.0.24",
"symplify/symfony-php-config": "<10.0.24",
"symplify/simple-php-doc-parser": "<10.0.24",
"symplify/php-config-printer": "<10.0.24",
"symplify/autowire-array-parameter": "<10.0.24",
Expand Down
1 change: 0 additions & 1 deletion packages/git-wrapper/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"symplify/phpstan-rules": "<10.0.24",
"symplify/easy-testing": "<10.0.24",
"symplify/rule-doc-generator-contracts": "<10.0.24",
"symplify/symfony-php-config": "<10.0.24",
"symplify/simple-php-doc-parser": "<10.0.24",
"symplify/php-config-printer": "<10.0.24",
"symplify/autowire-array-parameter": "<10.0.24",
Expand Down
1 change: 0 additions & 1 deletion packages/latte-phpstan-compiler/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"symplify/phpstan-rules": "<10.0.24",
"symplify/easy-testing": "<10.0.24",
"symplify/rule-doc-generator-contracts": "<10.0.24",
"symplify/symfony-php-config": "<10.0.24",
"symplify/simple-php-doc-parser": "<10.0.24",
"symplify/php-config-printer": "<10.0.24",
"symplify/autowire-array-parameter": "<10.0.24",
Expand Down
1 change: 0 additions & 1 deletion packages/markdown-diff/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"symplify/phpstan-rules": "<10.0.24",
"symplify/easy-testing": "<10.0.24",
"symplify/rule-doc-generator-contracts": "<10.0.24",
"symplify/symfony-php-config": "<10.0.24",
"symplify/simple-php-doc-parser": "<10.0.24",
"symplify/php-config-printer": "<10.0.24",
"symplify/autowire-array-parameter": "<10.0.24",
Expand Down
1 change: 0 additions & 1 deletion packages/monorepo-builder/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"symplify/phpstan-rules": "<10.0.24",
"symplify/easy-testing": "<10.0.24",
"symplify/rule-doc-generator-contracts": "<10.0.24",
"symplify/symfony-php-config": "<10.0.24",
"symplify/simple-php-doc-parser": "<10.0.24",
"symplify/php-config-printer": "<10.0.24",
"symplify/autowire-array-parameter": "<10.0.24",
Expand Down
1 change: 0 additions & 1 deletion packages/neon-config-dumper/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"symplify/easy-coding-standard": "<10.0.24",
"symplify/phpstan-rules": "<10.0.24",
"symplify/rule-doc-generator-contracts": "<10.0.24",
"symplify/symfony-php-config": "<10.0.24",
"symplify/simple-php-doc-parser": "<10.0.24",
"symplify/php-config-printer": "<10.0.24",
"symplify/autowire-array-parameter": "<10.0.24",
Expand Down
2 changes: 1 addition & 1 deletion packages/package-builder/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"require": {
"php": ">=8.0",
"nette/utils": "^3.2",
"sebastian/diff": "^4.0",
"symfony/config": "^5.4|^6.0",
"symfony/console": "^5.4|^6.0",
"symfony/dependency-injection": "^5.4|^6.0",
Expand Down Expand Up @@ -37,7 +38,6 @@
"symplify/easy-coding-standard": "<10.0.24",
"symplify/phpstan-rules": "<10.0.24",
"symplify/rule-doc-generator-contracts": "<10.0.24",
"symplify/symfony-php-config": "<10.0.24",
"symplify/simple-php-doc-parser": "<10.0.24",
"symplify/php-config-printer": "<10.0.24",
"symplify/autowire-array-parameter": "<10.0.24",
Expand Down
1 change: 0 additions & 1 deletion packages/php-config-printer/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"symplify/phpstan-rules": "<10.0.24",
"symplify/easy-testing": "<10.0.24",
"symplify/rule-doc-generator-contracts": "<10.0.24",
"symplify/symfony-php-config": "<10.0.24",
"symplify/simple-php-doc-parser": "<10.0.24",
"symplify/autowire-array-parameter": "<10.0.24",
"symplify/markdown-diff": "<10.0.24",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ final class ArgsNodeFactory
public function __construct(
private StringExprResolver $stringExprResolver,
private TaggedReturnsCloneResolver $taggedReturnsCloneResolver,
private TaggedServiceResolver $taggedServiceResolver
private TaggedServiceResolver $taggedServiceResolver,
private NewValueObjectFactory $newValueObjectFactory,
) {
$this->isPhpNamedArguments = PHP_VERSION_ID >= 80000;
}
Expand Down Expand Up @@ -129,6 +130,10 @@ public function resolveExpr(
return new Array_($arrayItems);
}

if (is_object($value)) {
return $this->newValueObjectFactory->create($value);
}

return BuilderHelpers::normalizeValue($value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,12 @@

namespace Symplify\PhpConfigPrinter\Printer\ArrayDecorator;

use PhpParser\Node\Arg;
use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Expr\ArrayItem;
use PhpParser\Node\Expr\New_;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Name\FullyQualified;
use Symplify\PhpConfigPrinter\NodeFactory\NewValueObjectFactory;
use Symplify\PhpConfigPrinter\Reflection\ConstantNameFromValueResolver;
use Symplify\SymfonyPhpConfig\ValueObjectInliner;

final class ServiceConfigurationDecorator
{
public function __construct(
private ConstantNameFromValueResolver $constantNameFromValueResolver,
private NewValueObjectFactory $newValueObjectFactory
) {
}

Expand All @@ -32,47 +23,7 @@ public function decorate($configuration, string $class, bool $shouldUseConfigure
return $configuration;
}

$configuration = $this->decorateClassConstantKeys($configuration, $class);

foreach ($configuration as $key => $value) {
if ($this->isArrayOfObjects($value)) {
$configuration = $this->configureArrayOfObjects(
$configuration,
$value,
$key,
$shouldUseConfigureMethod
);
} elseif (is_object($value)) {
$configuration[$key] = $this->decorateValueObject($value, $shouldUseConfigureMethod);
}
}

return $configuration;
}

/**
* @param mixed[] $value
* @return mixed[]
*/
private function configureArrayOfObjects(
array $configuration,
array $value,
int|string $key,
bool $shouldUseConfigureMethod
): array {
foreach ($value as $keyValue => $singleValue) {
if (is_string($keyValue)) {
$configuration[$key] = array_merge($configuration[$key], [
$keyValue => $this->decorateValueObject($singleValue, $shouldUseConfigureMethod),
]);
}

if (is_numeric($keyValue)) {
$configuration[$key] = $this->decorateValueObjects([$singleValue], $shouldUseConfigureMethod);
}
}

return $configuration;
return $this->decorateClassConstantKeys($configuration, $class);
}

/**
Expand All @@ -95,68 +46,4 @@ private function decorateClassConstantKeys(array $configuration, string $class):

return $configuration;
}

private function decorateValueObject(object $value, bool $shouldUseConfigureMethod): StaticCall|New_
{
$new = $this->newValueObjectFactory->create($value);
if ($shouldUseConfigureMethod) {
return $new;
}

$args = [new Arg($new)];
return $this->createInlineStaticCall($args);
}

/**
* @param mixed[] $values
*/
private function decorateValueObjects(array $values, bool $shouldUseConfigureMethod): StaticCall|Array_
{
$arrayItems = [];

foreach ($values as $value) {
$new = $this->newValueObjectFactory->create($value);
$arrayItems[] = new ArrayItem($new);
}

$array = new Array_($arrayItems);
if ($shouldUseConfigureMethod) {
return $array;
}

$args = [new Arg($array)];

return $this->createInlineStaticCall($args);
}

private function isArrayOfObjects(mixed $values): bool
{
if (! is_array($values)) {
return false;
}

if ($values === []) {
return false;
}

foreach ($values as $value) {
if (! is_object($value)) {
return false;
}
}

return true;
}

/**
* Depends on symplify/symfony-php-config
*
* @param Arg[] $args
*/
private function createInlineStaticCall(array $args): StaticCall
{
$fullyQualified = new FullyQualified(ValueObjectInliner::class);

return new StaticCall($fullyQualified, 'inline', $args);
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Loading