Skip to content

[Config] Backport string|null api for node names #26297

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
merged 1 commit into from
Mar 19, 2018
Merged

[Config] Backport string|null api for node names #26297

merged 1 commit into from
Mar 19, 2018

Conversation

ro0NL
Copy link
Contributor

@ro0NL ro0NL commented Feb 24, 2018

Q A
Branch? 2.7
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #...
License MIT
Doc PR symfony/symfony-docs#...

@chalasr
Copy link
Member

chalasr commented Feb 24, 2018

For 2.7

@chalasr chalasr added this to the 2.7 milestone Feb 24, 2018
@ro0NL ro0NL changed the base branch from 3.4 to 2.7 February 24, 2018 20:34
@ro0NL
Copy link
Contributor Author

ro0NL commented Feb 25, 2018

Fixed ParentNodeDefinitionInterface api docs as well :)

@@ -143,8 +143,8 @@ public function end()
/**
* Creates a child node.
*
* @param string $name The name of the node
* @param string $type The type of the node
* @param string|null $name The name of the node
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Also what does a node without a name do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok my bad.. it's clarified only on 4.0: https://github.com/symfony/symfony/blob/4.0/src/Symfony/Component/Config/Definition/BaseNode.php#L39

Should be backported to 2.7 as string|null AFAIK, this being the first instance :)

In general it's used to create a prototyped node: https://github.com/symfony/symfony/blob/4.0/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php#L77

I think it makes sense to keep string API when using a named factory: scalarNode('string') vs node(null, 'scalar'). Which seems to be the case already; https://github.com/symfony/symfony/blob/4.0/src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php#L52

@ro0NL
Copy link
Contributor Author

ro0NL commented Feb 26, 2018

@Tobion im leaning to revert the last string|null fix on node names for now. It's a dirty road.

Still bugged on master:

public function __construct(?string $name, NodeInterface $parent = null, string $pathSeparator = self::DEFAULT_PATH_SEPARATOR)
{
if (false !== strpos($name, $pathSeparator)) {
throw new \InvalidArgumentException('The name must not contain "'.$pathSeparator.'".');

^ strpos on nullable

public function append(NodeDefinition $node)
{
$this->children[$node->name] = $node->setParent($this);

^ not sure.. maybe dragons, maybe not. (my guess is it only runs for named children).

Put different im not sure about fixing those on 2.7... but backporting string|null sounds reasonable.

@ro0NL
Copy link
Contributor Author

ro0NL commented Feb 27, 2018

Status: needs review

to go along with #26335, applies until 3.4

@ro0NL ro0NL changed the title [Config] Remove false @inheritdoc [Config] Backport string|null api for node names Feb 27, 2018
nicolas-grekas added a commit that referenced this pull request Mar 19, 2018
This PR was squashed before being merged into the 4.1-dev branch (closes #26308).

Discussion
----------

[Config] Introduce BuilderAwareInterface

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #...   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

Split `ParentNodeDefinitionInterface` into `BuilderAwareInterface`.

Use case is custom node definition  (extended from VariableNodeDef) with a corresponding prototyped array node.

To set the actual prototype i need the builder at definition level, provided by `ParentNodeDefinitionInterface`. However i don't implement `children()` + `append()`, i solely need the builder scope.

To go after #26297

Commits
-------

1353694 [Config] Introduce BuilderAwareInterface
@nicolas-grekas
Copy link
Member

@Tobion OK for you?

@nicolas-grekas
Copy link
Member

Thank you @ro0NL.

@nicolas-grekas nicolas-grekas merged commit fe586ac into symfony:2.7 Mar 19, 2018
nicolas-grekas added a commit that referenced this pull request Mar 19, 2018
This PR was merged into the 2.7 branch.

Discussion
----------

 [Config] Backport string|null api for node names

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #...   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

Commits
-------

fe586ac [Config] Backport string|null api for node names
@ro0NL ro0NL deleted the inheritdoc branch March 19, 2018 19:06
nicolas-grekas added a commit that referenced this pull request Mar 19, 2018
…0NL)

This PR was squashed before being merged into the 2.7 branch (closes #26335).

Discussion
----------

[Config] Handle nullable node name + fix inheritdocs

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no-ish
| Deprecations? | no
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #...   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

Small split from #26297 that can be merged until master/4.1. Whereas the doc fixes only apply until 3.4, hence the split.

Small change regarding `getName/Path()` for not returning a `null` value anymore which violates `NodeInterface::getName/Path()`

Remainng issue left at

https://github.com/symfony/symfony/blob/cd5f4105a43208632c8b62fd75b4dad53dcd8a41/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php#L381-L383

which i tend to leave untouched across all branches for now.

Commits
-------

5c3e6a9 [Config] Handle nullable node name + fix inheritdocs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants