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] Added support for deprecating aliases#29968

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

Merged
nicolas-grekas merged 2 commits intosymfony:masterfromrenanbr:deprecate-aliases
Jan 25, 2019
Merged

[DI] Added support for deprecating aliases#29968

nicolas-grekas merged 2 commits intosymfony:masterfromrenanbr:deprecate-aliases
Jan 25, 2019

Conversation

@renanbr
Copy link

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#24507
LicenseMIT
Doc PRTBD

This PR is a continuity of#24707

@nicolas-grekasnicolas-grekas added this to thenext milestoneJan 23, 2019
Copy link
Member

@stofstof left a comment

Choose a reason for hiding this comment

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

This also seems to miss warning (at compile-time) when a service is referencing a deprecated alias (before resolving them, otherwise we won't have any such reference)

if (!\in_array($key, ['alias','public'])) {
if (!\in_array($key, ['alias','public','deprecated'])) {
thrownewInvalidArgumentException(sprintf('The configuration key "%s" is unsupported for the service "%s" which is defined as an alias in "%s". Allowed configuration keys for service aliases are "alias" and "public".',$key,$id,$file));
continue;
Copy link
Member

Choose a reason for hiding this comment

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

thiscontinue is dead code

* Whether this alias is deprecated, that means it should not be called
* anymore.
*
* @param bool $status Defaults to true
Copy link
Contributor

Choose a reason for hiding this comment

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

the description should describe what it does

Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

I think we're good thank you!
Here are some minor comments.
Please squash all your commits also keep only two.

}

/**
* Whether this alias is deprecated, that means it should not be called

Choose a reason for hiding this comment

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

s/called/referenced

/**
* Returns whether this alias is deprecated.
*
* @return bool

Choose a reason for hiding this comment

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

the whole docblock can be removed and replaced by a real return type

*
* @return string
*/
publicfunctiongetDeprecationMessage($id)

Choose a reason for hiding this comment

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

should use real argument+return type + remove docblock

}
}

$allowedTags = ['deprecated'];

Choose a reason for hiding this comment

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

no need for the temporary variable, isn't it? better remove it.

{
$container =newContainerBuilder();

$container->register('foo','\stdClass');

Choose a reason for hiding this comment

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

no need for the\ (same below)


$aliasDeprecated =newAlias('foo');
$aliasDeprecated->setDeprecated(true);
$container->setAlias('foo_aliased',$aliasDeprecated);

Choose a reason for hiding this comment

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

maybe name it deprecated_foo_alias instead of foo_aliased?


$dumper =newPhpDumper($container);
$this->assertStringEqualsFile(self::$fixturesPath.'/php/container_alias_deprecation.php',$dumper->dump());
eval('?>'.$dumper->dump(['class' =>'Symfony_DI_PhpDumper_Test_Aliases_Deprecation']));

Choose a reason for hiding this comment

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

better dump only once (see previous line)

/**
* Gets the public 'alias_for_foo_deprecated' alias.
*
* @return object An instance returned by "getFooService()"

Choose a reason for hiding this comment

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

Maybe this message should beThe "foo" service.?

@nicolas-grekasnicolas-grekas changed the titleAdded support for deprecating aliases[DI] Added support for deprecating aliasesJan 24, 2019
@renanbr
Copy link
Author

changes applied, commits squashed
@stof,@OskarStark,@nicolas-grekas

@nicolas-grekas
Copy link
Member

Fabbot complains :)

@nicolas-grekas
Copy link
Member

Thank you@renanbr.

@nicolas-grekasnicolas-grekas merged commit6c571ad intosymfony:masterJan 25, 2019
nicolas-grekas added a commit that referenced this pull requestJan 25, 2019
This PR was merged into the 4.3-dev branch.Discussion----------[DI] Added support for deprecating aliases| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? |no| Tests pass?   | yes| Fixed tickets |#24507| License       | MIT| Doc PR        | TBDThis PR is a continuity of#24707Commits-------6c571ad Added support for deprecating aliases (runtime+dumper)0eb071b Added support for deprecating an alias
@nicolas-grekas
Copy link
Member

And thank you@j92 !

j92 reacted with hooray emojiOskarStark reacted with rocket emoji

private$deprecated;
private$deprecationTemplate;

privatestatic$defaultDeprecationTemplate ='The "%service_id%" service alias is deprecated. You should stop using it, as it will soon be removed.';

Choose a reason for hiding this comment

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

I know this PR is merged, but I've just reviewed its code and I wondered if the%service_id% placeholder name is confusing to other people too. To me, this placeholder would be easier to understand if it was called%alias_id%.

Also, this ->... as it will soon be removed. could be ->... as it will be removed in the future.

Thanks.

Choose a reason for hiding this comment

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

updated in#29995, please review

nicolas-grekas added a commit that referenced this pull requestJan 28, 2019
… is found (nicolas-grekas)This PR was merged into the 4.3-dev branch.Discussion----------[DI] add id of referencing service when a deprecated alias is found| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | -| License       | MIT| Doc PR        | -Improves#29968 a bit for DX.Commits-------b124fb7 [DI] add id of referencing service when a deprecated alias is found
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull requestJan 29, 2019
…iluz)This PR was squashed before being merged into the master branch (closes#10937).Discussion----------Documented the deprecation of service aliasesIt documentssymfony/symfony#29968 but it contains the changes of the pending PRsymfony/symfony#29995Commits-------d5d87e6 Documented the deprecation of service aliases
XuruDragon pushed a commit to XuruDragon/symfony that referenced this pull requestFeb 4, 2019
…ebug:autowiring| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | none| License       | MIT| Doc PR        | n/aFix and improves a bit PRsymfony#29968 andsymfony#29995
XuruDragon pushed a commit to XuruDragon/symfony that referenced this pull requestFeb 4, 2019
…ebug:autowiring| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | none| License       | MIT| Doc PR        | n/aFix and improves a bit PRsymfony#29968 andsymfony#29995
XuruDragon pushed a commit to XuruDragon/symfony that referenced this pull requestFeb 4, 2019
…ebug:autowiring| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | none| License       | MIT| Doc PR        | n/aFix and improves a bit PRsymfony#29968 andsymfony#29995
XuruDragon pushed a commit to XuruDragon/symfony that referenced this pull requestFeb 4, 2019
…ebug:autowiring| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | none| License       | MIT| Doc PR        | n/aFix and improves a bit PRsymfony#29968 andsymfony#29995
XuruDragon pushed a commit to XuruDragon/symfony that referenced this pull requestFeb 5, 2019
…ebug:autowiring| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | none| License       | MIT| Doc PR        | n/aFix and improves a bit PRsymfony#29968 andsymfony#29995
XuruDragon pushed a commit to XuruDragon/symfony that referenced this pull requestFeb 6, 2019
…ebug:autowiring| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | none| License       | MIT| Doc PR        | n/aFix and improves a bit PRsymfony#29968 andsymfony#29995
XuruDragon pushed a commit to XuruDragon/symfony that referenced this pull requestFeb 6, 2019
…ebug:autowiring| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | none| License       | MIT| Doc PR        | n/aFix and improves a bit PRsymfony#29968 andsymfony#29995
XuruDragon pushed a commit to XuruDragon/symfony that referenced this pull requestFeb 6, 2019
…ebug:autowiring| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | none| License       | MIT| Doc PR        | n/aFix and improves a bit PRsymfony#29968 andsymfony#29995
XuruDragon pushed a commit to XuruDragon/symfony that referenced this pull requestFeb 6, 2019
…ebug:autowiring| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | none| License       | MIT| Doc PR        | n/aFix and improves a bit PRsymfony#29968 andsymfony#29995
XuruDragon pushed a commit to XuruDragon/symfony that referenced this pull requestFeb 7, 2019
…ebug:autowiring| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | none| License       | MIT| Doc PR        | n/aFix and improves a bit PRsymfony#29968 andsymfony#29995
nicolas-grekas added a commit that referenced this pull requestFeb 8, 2019
…ed aliases in debug:autowiring (XuruDragon)This PR was merged into the 4.3-dev branch.Discussion----------[DependencyInjection] Added information about deprecated aliases in debug:autowiring| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | none| License       | MIT| Doc PR        | n/aFix and improves a bit PR#29968 and#29995![Screenshot](https://i.imgur.com/GDj2NIY.png)Commits-------3d2378d [DependencyInjection] Added information about deprecated aliases in debug:autowiring
@nicolas-grekasnicolas-grekas modified the milestones:next,4.3Apr 30, 2019
@fabpotfabpot mentioned this pull requestMay 9, 2019
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@javiereguiluzjaviereguiluzjaviereguiluz left review comments

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@stofstofstof requested changes

@OskarStarkOskarStarkOskarStark requested changes

Assignees

No one assigned

Projects

None yet

Milestone

4.3

Development

Successfully merging this pull request may close these issues.

7 participants

@renanbr@nicolas-grekas@javiereguiluz@stof@OskarStark@carsonbot@j92

[8]ページ先頭

©2009-2025 Movatter.jp