Movatterモバイル変換


[0]ホーム

URL:


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

[DI] Exclude private services from alternatives#19679

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
ro0NL wants to merge4 commits intosymfony:masterfromro0NL:di/alternative-services
Closed

[DI] Exclude private services from alternatives#19679

ro0NL wants to merge4 commits intosymfony:masterfromro0NL:di/alternative-services

Conversation

@ro0NL
Copy link
Contributor

@ro0NLro0NL commentedAug 20, 2016
edited
Loading

QA
Branch?"master"
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?yes
Tests pass?yes
Fixed ticketscomma-separated list of tickets fixed by the PR, if any
LicenseMIT
Doc PRreference to the documentation PR, if any

After#19685 &#19690

@ogizanagi
Copy link
Contributor

This should go into2.7, notmaster.

However, you won't be able to exclude privates asContainer::privates is only available since 3.2.

try {
$sc->get('int');
$this->fail('->get() throws an Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException if the key does not exist');
}catch (\Exception$e) {
Copy link
Contributor

@ogizanagiogizanagiAug 20, 2016
edited
Loading

Choose a reason for hiding this comment

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

Why not using@expectedException &@expectedExceptionMessage annotations ?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Copy paste :)

Copy link
Contributor

@ogizanagiogizanagiAug 20, 2016
edited
Loading

Choose a reason for hiding this comment

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

IMHO, unless there is a good reason, new tests should use the annotations.
When oldest tests where introduced, I guess those annotations (as well asTestCase::setExpectedException()) were not available with the PHPUnit version in use :)

Copy link
Member

Choose a reason for hiding this comment

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

Indeed, new tests should use the annotations.

@ro0NL
Copy link
ContributorAuthor

@ogizanagi could be done :) i dont mind.

@ogizanagi
Copy link
Contributor

ogizanagi commentedAug 20, 2016
edited
Loading

@ro0NL: I'd suggest you to create another PR for 2.7 and up, and keep this one to not loose track of the private services handling in 3.2.


$alternatives =array();
foreach ($this->servicesas$key =>$associatedService) {
if (isset($this->privates[$key])) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What about moving this check intogetServiceIds() and add an optional$private = true argument (which will be deprecated later, in order to thegetServiceIds() to only return public services ids ?

Copy link
ContributorAuthor

@ro0NLro0NLAug 20, 2016
edited
Loading

Choose a reason for hiding this comment

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

Makes sense for havinggetServiceIds only expose public id's.

Not sure why we want$private = true. Opposed to refactoring stuff relying on the fact it returns private ids.

We should assume the foreach usesgetServiceIds now.

Copy link
Contributor

@ogizanagiogizanagiAug 20, 2016
edited
Loading

Choose a reason for hiding this comment

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

Not sure why we want $private = true. Opposed to refactoring stuff relying on the fact it returns private ids.

That's only in order to ensure BC. Having this argument set to true should trigger a deprecation. Internally, we'll only usefalse. (if any internal call needs privates services, we'll have to add another$triggerDeprecation = true argument and set it tofalse, but I doubt there is.)

We should assume the foreach uses getServiceIds now.

Yes. Why did you change ?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Yes. Why did you changed ?

Waiting for upstream to change 😛, but ill add it. Makes sense.

Got your point aboutgetServiceIds. It's public API.. which should keep returning privates till 4.0. Ill have a look at it.

if (func_num_args() ===1) {
$includePrivates = !!func_get_arg(0);
if ($includePrivates) {
@trigger_error(sprintf('Including private services in the list of service id\'s is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0.',$id),E_USER_DEPRECATED);
Copy link
ContributorAuthor

@ro0NLro0NLAug 20, 2016
edited
Loading

Choose a reason for hiding this comment

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

@ogizanagi something like this?

edit: it makes no real sense though.. we can just deprecate privates ingetServiceIds on master, right? ie. new/update PR. as it would fix this issue automatically.

Copy link
Contributor

@ogizanagiogizanagiAug 20, 2016
edited
Loading

Choose a reason for hiding this comment

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

Sorry, I don't understand your concerns 😕 ?

You can't just deprecate privates ingetServiceIds if you have no idea the privates were asked. And simply not returning them will be a BC break. Thus, the new argument to explicit the intention, and trigger the deprecation.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Got it.master != 4.x this keeps confusing me 😅

ogizanagi reacted with laugh emoji
publicfunctiongetServiceIds(/*$includePrivates = true*/)
{
$includePrivates =true;
if (func_num_args() ===1) {

Choose a reason for hiding this comment

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

Nobody calls this with an argument, which means nobody will see the deprecation notice.
Yet, I think we should only add a note to remind about not returning private services in 4.0. No need for any deprecations: if people use the private services returned today from this method, they will get a deprecation because fetching them is deprecated.

@ro0NL
Copy link
ContributorAuthor

Superseded by#19707 +#19685

@ro0NLro0NL closed thisAug 22, 2016
@ro0NLro0NL deleted the di/alternative-services branchAugust 22, 2016 16:26
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@ro0NL@ogizanagi@fabpot@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp