Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix beforeNormalization #132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
ondrejmirtes merged 5 commits into phpstan:master from VincentLanglet:beforeNormalization
Feb 15, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion extension.neon
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ services:
tags: [phpstan.broker.dynamicMethodReturnTypeExtension]
arguments:
className: Symfony\Component\Config\Definition\Builder\NodeDefinition
methods: [children, validate]
methods: [children, validate, beforeNormalization]

# NodeDefinition::end() return type
-
Expand Down
32 changes: 16 additions & 16 deletions tests/Type/Symfony/Config/TreeBuilderTest.php
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Iterator;
use PHPStan\Type\Symfony\ExtensionTestCase;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;

final class TreeBuilderTest extends ExtensionTestCase
{
Expand All @@ -14,20 +13,6 @@ final class TreeBuilderTest extends ExtensionTestCase
*/
public function testGet(string $expression, string $type): void
{
$arrayTreeBuilder = new TreeBuilder('my_tree', 'array');
$arrayRootNode = $arrayTreeBuilder->getRootNode();
$r = $arrayRootNode
->children()
->arrayNode('methods')
->prototype('scalar')
->validate()
->ifNotInArray(['one', 'two'])
->thenInvalid('%s is not a valid method.')
->end()
->end()
->end()
->end();

$this->processFile(
__DIR__ . '/tree_builder.php',
$expression,
Expand All @@ -38,7 +23,7 @@ public function testGet(string $expression, string $type): void
new ReturnParentDynamicReturnTypeExtension('Symfony\Component\Config\Definition\Builder\NodeBuilder', ['end']),
new ReturnParentDynamicReturnTypeExtension('Symfony\Component\Config\Definition\Builder\NodeDefinition', ['end']),
new PassParentObjectDynamicReturnTypeExtension('Symfony\Component\Config\Definition\Builder\NodeBuilder', ['arrayNode', 'scalarNode', 'booleanNode', 'integerNode', 'floatNode', 'enumNode', 'variableNode']),
new PassParentObjectDynamicReturnTypeExtension('Symfony\Component\Config\Definition\Builder\NodeDefinition', ['children', 'validate']),
new PassParentObjectDynamicReturnTypeExtension('Symfony\Component\Config\Definition\Builder\NodeDefinition', ['children', 'validate', 'beforeNormalization']),
new TreeBuilderGetRootNodeDynamicReturnTypeExtension(),
],
[new TreeBuilderDynamicReturnTypeExtension()]
Expand Down Expand Up @@ -183,6 +168,21 @@ public function getProvider(): Iterator
->end()
->end()
', 'Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition'];
yield ['
$arrayRootNode
->children()
->arrayNode("methods")
->prototype("array")
->beforeNormalization()
->ifString()
->then(static function ($v) {
return [$v];
})
->end()
->end()
->end()
->end()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you're at it, could you please fix the indentation of this test case (plus the ones above that I forgot too)? 🙏 Would make it easier to understand.

Copy link
Contributor Author

@VincentLanglet VincentLanglet Feb 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

', 'Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition'];

yield ['$variableRootNode', 'Symfony\Component\Config\Definition\Builder\VariableNodeDefinition'];
yield ['$variableRootNode->end()', 'Symfony\Component\Config\Definition\Builder\TreeBuilder'];
Expand Down

AltStyle によって変換されたページ (->オリジナル) /