Trigger deprecation for certain method call using phpstorm meta
Well i just had a case where i just deprecated some action of controller, and now i need to deprecated all calls to generate url to it - i have method like `getUrlFor($routerName)`. By default there is no way to do it(or maybe im missing something?). I would suggest adding function like `triggerDeprecation(full path to method name, arguments)` for .phpstorm.meta.php like:
.phpstorm.meta.php:
namespace PHPSTORM_META {
triggerDeprecation(\MyNamespace\MyClass::xyz(), 'deprecated-call'); //also should accept less arguments than method defines and still trigger deprecation
}
And php code like this:
namespace MyNamepsace
class MyClass
{
public function xyz($argument)
{
}
}
$object = new \MyNamespace\MyClass();
$object->xyz('works'); // no deprecation call
$object->xyz('deprecated-call'); // it will treat this as deprecation call
Not sure how usable could this be, just got a case where it could be helpful to tell that certain call of method with certain sets of arguments should not be used.
请先登录再写评论。
Did you try annotating your methods as deprecated?
They will be highlighted accordingly in editor:
If that doesn't suit you: feel free to submit this to our tracker at https://youtrack.jetbrains.com/newIssue
@Dmitry Tronin
Already there: https://youtrack.jetbrains.com/issue/WI-48983
@Dmitry Tronin, Wojciech Slawski
What about SSR -- can such rule be created that will match specific parameter value?
If so -- you may use it even right now.
SSR: https://www.jetbrains.com/help/phpstorm/structural-search-and-replace.html
SSI: https://www.jetbrains.com/help/phpstorm/general-structural-search-inspection.html --- "Settings (Preferences on macOS) | Editor | Inspections | General | Structural search inspection"
Thanks for the hint!
Yeah, you can,e.g.:
That's a dirty, "xyz"-hardcoded solution but it works. One could probably come up with a more graceful solution by investing more time in this.
Yea i know about @deprecated, i was wondering if it's possible to deprecate call with certain argument, and other calls with other arguments works fine. Not sure about this SSR/SSI solution and how they work, what should i do?
Yea i created issue anyway.