Skip to content

[DI] Fixes aliases visibility with and without defaults #21219

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
Jan 9, 2017
Merged

[DI] Fixes aliases visibility with and without defaults #21219

merged 1 commit into from
Jan 9, 2017

Conversation

ogizanagi
Copy link
Contributor

Q A
Branch? master
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #21071 (comment)
License MIT
Doc PR N/A

@@ -148,9 +148,13 @@ public function testLoadServices()
$this->assertTrue(isset($aliases['alias_for_foo']), '->load() parses aliases');
$this->assertEquals('foo', (string) $aliases['alias_for_foo'], '->load() parses aliases');
$this->assertTrue($aliases['alias_for_foo']->isPublic());
$this->assertTrue($aliases['another_third_alias_for_foo']->isPublic());
Copy link
Member

Choose a reason for hiding this comment

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

Duplicate below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops. Thanks.

@@ -194,7 +194,7 @@ private function parseDefinitions($content, $file)
}
}
} else {
$defaults = array();
$defaults = array('public' => true);
Copy link
Member

Choose a reason for hiding this comment

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

Case above that triggers a deprecation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Contributor Author

@ogizanagi ogizanagi Jan 9, 2017

Choose a reason for hiding this comment

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

Actually, would you prefer using the same way as you did for classic definitions, i.e:

$public = isset($service['public']) ? $service['public'] : (isset($defaults['public']) ? $defaults['public'] : true);

rather than adding this in defaults?

To me it makes sense to define canonical defaults, but then I should probably update https://github.com/symfony/symfony/blob/master/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php#L274 too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previous fix was not enough in case _defaults: { public: true } was set anyway... So updated.

@@ -34,3 +34,8 @@ services:
inherit_tags: true
tags:
- name: baz

with_defaults_aliased:
alias: 'with_defaults'
Copy link
Contributor

Choose a reason for hiding this comment

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

I would remove single quotes here, in order to harmonize it with the documentation. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

ah it actually doesn't matter :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's only fixtures, so we don't care much IMHO. But ok. :)

@@ -18,6 +18,8 @@ services:
calls:
- [ setBar, [ foo, '@foo', [true, false] ] ]
alias_for_foo: '@foo'
another_third_alias_for_foo:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This alias is before another_alias_for_foo because of an issue with the YamlDumper. See #21220

fabpot added a commit that referenced this pull request Jan 9, 2017
This PR was merged into the 2.7 branch.

Discussion
----------

[DI] Fix missing new line after private alias

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #21219 (comment)
| License       | MIT
| Doc PR        | N/A

Without this change, the output is:

```yml
# [...]
alias_for_foo: '@foo'
another_alias_for_foo:
    alias: foo
    public: false    another_third_alias_for_foo: '@foo' # <--- missing new line after `public: false`
```

(this is tested by the `CrossCheckTest` but there is no fixture file to update (automatically dumped and removed by the test case))

Commits
-------

101a165 [DI] Fix missing new line after private alias
@fabpot
Copy link
Member

fabpot commented Jan 9, 2017

Thank you @ogizanagi.

@fabpot fabpot merged commit f1cc090 into symfony:master Jan 9, 2017
fabpot added a commit that referenced this pull request Jan 9, 2017
…gizanagi)

This PR was merged into the 3.3-dev branch.

Discussion
----------

[DI] Fixes aliases visibility with and without defaults

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #21071 (comment)
| License       | MIT
| Doc PR        | N/A

Commits
-------

f1cc090 [DI] Fixes aliases visibility with and without defaults
@ogizanagi ogizanagi deleted the fix/3.3/di/aliases_defaults branch January 9, 2017 20:27
takeit added a commit to takeit/web-publisher that referenced this pull request Jan 9, 2017
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.

5 participants