Making sure that your code is not using any extension points which might be removed in the near future is important if you would like to avoid any extra work for refactoring code to other extension points.
PHP Analyzer comes with rich checks for usage of deprecated code. Instead of
hard-coding specific classes or functions which are deprecated, PHP Analyzer makes
use of the @deprecated
annotation which means that it can detect usage of
deprecated code for any library including your own project. For example, let’s
assume that you have renamed a method and you deprecate the old name:
class SomeClass
{
/**
* @deprecated Use getIssues() instead.
*/
public function getComments()
{
return $this->getIssues();
}
public function getIssues()
{
// ...
}
}
PHP Analyzer always displays the deprecation message when the issue is found. In the
example above the message would be “getComments()
was deprecated with message: use getIssues()
instead”.
When drafting the deprecation message, we would suggest to use something along the lines of “Deprecated since 1.2.3; use xyz() instead.”. Basically, try to point the reader into the direction of the new way of doing things, be that a single method or another location/URL where he/she can obtain more information. This not only helps PHP Analyzer be more useful, but any human reader of the source code will be grateful.
PHP Analyzer detects the following usages of deprecated code: