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

[Debug] Detect internal and deprecated methods#23816

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
GuilhemN wants to merge3 commits intosymfony:3.4fromGuilhemN:deprecated

Conversation

GuilhemN
Copy link
Contributor

QA
Branch?3.4
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets
LicenseMIT
Doc PR

I just realized we do not detect@deprecated methods like we do for@final methods, so here's a fix.

I reorganized the file to avoid code duplication... so the diff is kind of impressive but the behavior is the same.

@nicolas-grekas
Copy link
Member

rebase unlocked - the same should also apply to internal methods, isn't it?

@nicolas-grekasnicolas-grekas added this to the3.4 milestoneAug 7, 2017
@GuilhemN
Copy link
ContributorAuthor

Yes, I'm on it.

@GuilhemNGuilhemN changed the title[Debug] Detect deprecated methods[Debug] Detect internal and deprecated methodsAug 7, 2017
@GuilhemN
Copy link
ContributorAuthor

GuilhemN commentedAug 7, 2017
edited
Loading

rebased

Edit: known issue, when you extend a method of an inherited trait, the deprecation will show the name of the class using the trait instead of the name of the trait itself. I didn't find a workaround but I think it's still better than no warning at all.

Simperfit reacted with thumbs up emoji

@GuilhemNGuilhemNforce-pushed thedeprecated branch 2 times, most recently from6ba9fd2 to0891882CompareAugust 7, 2017 14:16
@GuilhemN
Copy link
ContributorAuthor

fabbot failure is a false-positive. Travis and appveyor failures are unrelated.

*
* @return string[]
*/
private function getOwnInterfaces($class)

Choose a reason for hiding this comment

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

$ownInterfaces =class_implements($class,false);if ($parent =get_parent_class($class)) {foreach (class_implements($parent,false)as$interface) {                unset($ownInterfaces[$interface]);            }        }foreach ($ownInterfacesas$interface) {foreach (class_implements($interface)as$interface) {                unset($ownInterfaces[$interface]);            }        }return$ownInterfaces;

GuilhemN reacted with thumbs up emoji
if (!isset($parentInterfaces[$interface])) {
@trigger_error(sprintf('The "%s" %s "%s" that is deprecated %s', $name, $refl->isInterface() ? 'interface extends' : 'class implements', $interface, self::$deprecated[$interface]), E_USER_DEPRECATED);
// Detect method annotations
$doc = $method->getDocComment();
Copy link
Member

@nicolas-grekasnicolas-grekasAug 8, 2017
edited
Loading

Choose a reason for hiding this comment

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

could be merged with next line

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

done

@@ -361,4 +364,30 @@ public function loadClass($class)
return true;
}
}

/**
* `class_implements` includes interfaces from the parents so we have to

Choose a reason for hiding this comment

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

I think you can configure your IDE to auto-break lines at 120, not 80 :)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Done :)

}
}

$traits = class_uses($name, false);
Copy link
Member

@nicolas-grekasnicolas-grekasAug 8, 2017
edited
Loading

Choose a reason for hiding this comment

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

$traits = array($parent) + class_uses($name, false);
Then belowforeach ($interfaces + $traits to remove the array_merge() (directly$traits after, maybe renamed btw)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

array($parent) + $interfaces; could cause conflicts so I did$parentAndTraits = ($parent ? array($parent => $parent) : array()) + class_uses($name, false); instead.

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.

with minor comments

@nicolas-grekas
Copy link
Member

Thank you@GuilhemN.

GuilhemN reacted with hooray emoji

nicolas-grekas added a commit that referenced this pull requestAug 9, 2017
This PR was squashed before being merged into the 3.4 branch (closes#23816).Discussion----------[Debug] Detect internal and deprecated methods| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | no| New feature?  | yes <!-- don't forget updating src/**/CHANGELOG.md files -->| BC breaks?    | no| Deprecations? | no <!-- don't forget updating UPGRADE-*.md files -->| Tests pass?   | yes| Fixed tickets || License       | MIT| Doc PR        |I just realized we do not detect `@deprecated` methods like we do for `@final` methods, so here's a fix.I reorganized the file to avoid code duplication... so the diff is kind of impressive but the behavior is the same.Commits-------16eeabf [Debug] Detect internal and deprecated methods
@chalasrchalasr closed thisAug 9, 2017
nicolas-grekas added a commit that referenced this pull requestAug 9, 2017
…(GuilhemN)This PR was merged into the 3.4 branch.Discussion----------[Debug] Correctly detect methods not from the same vendor| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | yes| New feature?  | no <!-- don't forget updating src/**/CHANGELOG.md files -->| BC breaks?    | no| Deprecations? | no <!-- don't forget updating UPGRADE-*.md files -->| Tests pass?   | yes| Fixed tickets || License       | MIT| Doc PR        |I just realized there were two issues in#23816:* when a class extended another class from the same vendor itself extending a class from another vendor containing deprecated methods, the deprecation wasn't triggered in case the first class extended a deprecated method from the last class because the parent from the same vendor was used for "the same vendor check".* As stated in#23816 (comment), ReflectionMethod::$class doesn't contain the right value when using a trait so if you extended a trait containing methods from another vendor you would have always get deprecations. I fixed this by comparing the method file to the filename of the class using the trait.@nicolas-grekas are you aware of any issue of `ReflectionMethod::getFilename()`?Commits-------08d352a [Debug] Correctly detect methods not from the same vendor
jderusse pushed a commit to jderusse/symfony that referenced this pull requestAug 23, 2017
…vendor (GuilhemN)This PR was merged into the 3.4 branch.Discussion----------[Debug] Correctly detect methods not from the same vendor| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | yes| New feature?  | no <!-- don't forget updating src/**/CHANGELOG.md files -->| BC breaks?    | no| Deprecations? | no <!-- don't forget updating UPGRADE-*.md files -->| Tests pass?   | yes| Fixed tickets || License       | MIT| Doc PR        |I just realized there were two issues insymfony#23816:* when a class extended another class from the same vendor itself extending a class from another vendor containing deprecated methods, the deprecation wasn't triggered in case the first class extended a deprecated method from the last class because the parent from the same vendor was used for "the same vendor check".* As stated insymfony#23816 (comment), ReflectionMethod::$class doesn't contain the right value when using a trait so if you extended a trait containing methods from another vendor you would have always get deprecations. I fixed this by comparing the method file to the filename of the class using the trait.@nicolas-grekas are you aware of any issue of `ReflectionMethod::getFilename()`?Commits-------08d352a [Debug] Correctly detect methods not from the same vendor
jderusse pushed a commit to jderusse/symfony that referenced this pull requestAug 23, 2017
…vendor (GuilhemN)This PR was merged into the 3.4 branch.Discussion----------[Debug] Correctly detect methods not from the same vendor| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | yes| New feature?  | no <!-- don't forget updating src/**/CHANGELOG.md files -->| BC breaks?    | no| Deprecations? | no <!-- don't forget updating UPGRADE-*.md files -->| Tests pass?   | yes| Fixed tickets || License       | MIT| Doc PR        |I just realized there were two issues insymfony#23816:* when a class extended another class from the same vendor itself extending a class from another vendor containing deprecated methods, the deprecation wasn't triggered in case the first class extended a deprecated method from the last class because the parent from the same vendor was used for "the same vendor check".* As stated insymfony#23816 (comment), ReflectionMethod::$class doesn't contain the right value when using a trait so if you extended a trait containing methods from another vendor you would have always get deprecations. I fixed this by comparing the method file to the filename of the class using the trait.@nicolas-grekas are you aware of any issue of `ReflectionMethod::getFilename()`?Commits-------08d352a [Debug] Correctly detect methods not from the same vendor
jderusse pushed a commit to jderusse/symfony that referenced this pull requestAug 23, 2017
…vendor (GuilhemN)This PR was merged into the 3.4 branch.Discussion----------[Debug] Correctly detect methods not from the same vendor| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | yes| New feature?  | no <!-- don't forget updating src/**/CHANGELOG.md files -->| BC breaks?    | no| Deprecations? | no <!-- don't forget updating UPGRADE-*.md files -->| Tests pass?   | yes| Fixed tickets || License       | MIT| Doc PR        |I just realized there were two issues insymfony#23816:* when a class extended another class from the same vendor itself extending a class from another vendor containing deprecated methods, the deprecation wasn't triggered in case the first class extended a deprecated method from the last class because the parent from the same vendor was used for "the same vendor check".* As stated insymfony#23816 (comment), ReflectionMethod::$class doesn't contain the right value when using a trait so if you extended a trait containing methods from another vendor you would have always get deprecations. I fixed this by comparing the method file to the filename of the class using the trait.@nicolas-grekas are you aware of any issue of `ReflectionMethod::getFilename()`?Commits-------08d352a [Debug] Correctly detect methods not from the same vendor
jderusse pushed a commit to jderusse/symfony that referenced this pull requestAug 23, 2017
…vendor (GuilhemN)This PR was merged into the 3.4 branch.Discussion----------[Debug] Correctly detect methods not from the same vendor| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | yes| New feature?  | no <!-- don't forget updating src/**/CHANGELOG.md files -->| BC breaks?    | no| Deprecations? | no <!-- don't forget updating UPGRADE-*.md files -->| Tests pass?   | yes| Fixed tickets || License       | MIT| Doc PR        |I just realized there were two issues insymfony#23816:* when a class extended another class from the same vendor itself extending a class from another vendor containing deprecated methods, the deprecation wasn't triggered in case the first class extended a deprecated method from the last class because the parent from the same vendor was used for "the same vendor check".* As stated insymfony#23816 (comment), ReflectionMethod::$class doesn't contain the right value when using a trait so if you extended a trait containing methods from another vendor you would have always get deprecations. I fixed this by comparing the method file to the filename of the class using the trait.@nicolas-grekas are you aware of any issue of `ReflectionMethod::getFilename()`?Commits-------08d352a [Debug] Correctly detect methods not from the same vendor
jderusse pushed a commit to jderusse/symfony that referenced this pull requestAug 23, 2017
…vendor (GuilhemN)This PR was merged into the 3.4 branch.Discussion----------[Debug] Correctly detect methods not from the same vendor| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | yes| New feature?  | no <!-- don't forget updating src/**/CHANGELOG.md files -->| BC breaks?    | no| Deprecations? | no <!-- don't forget updating UPGRADE-*.md files -->| Tests pass?   | yes| Fixed tickets || License       | MIT| Doc PR        |I just realized there were two issues insymfony#23816:* when a class extended another class from the same vendor itself extending a class from another vendor containing deprecated methods, the deprecation wasn't triggered in case the first class extended a deprecated method from the last class because the parent from the same vendor was used for "the same vendor check".* As stated insymfony#23816 (comment), ReflectionMethod::$class doesn't contain the right value when using a trait so if you extended a trait containing methods from another vendor you would have always get deprecations. I fixed this by comparing the method file to the filename of the class using the trait.@nicolas-grekas are you aware of any issue of `ReflectionMethod::getFilename()`?Commits-------08d352a [Debug] Correctly detect methods not from the same vendor
@xabbuhxabbuh mentioned this pull requestSep 12, 2017
xabbuh added a commit that referenced this pull requestSep 12, 2017
This PR was merged into the 3.4 branch.Discussion----------[Debug] fix test assertion| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets || License       | MIT| Doc PR        |Fixes tests for#23816 after the changes made in#24149.Commits-------75a26bb [Debug] fix test assertion
This was referencedOct 18, 2017
@stof
Copy link
Member

This cause issue when you still need to extend the old method to keep support for older versions (look at the way bundles were able to support both Symfony 2.7 and 2.8 to configure options in form types, by implementing both the oldsetDefaultOptions for 2.7 and the newconfigureOptions for newer versions).

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
3.4
Development

Successfully merging this pull request may close these issues.

5 participants
@GuilhemN@nicolas-grekas@stof@chalasr@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp