PHPackages                             php-static-analysis/rector-rule - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. php-static-analysis/rector-rule

ActiveRector-extension[Testing &amp; Quality](/categories/testing)

php-static-analysis/rector-rule
===============================

RectorPHP rule to convert PHPDoc annotations for static analysis to PHP attributes

0.5.0(11mo ago)2222.2k—8.9%11MITPHPPHP &gt;=8.1CI passing

Since Feb 9Pushed 11mo agoCompare

[ Source](https://github.com/php-static-analysis/rector-rule)[ Packagist](https://packagist.org/packages/php-static-analysis/rector-rule)[ GitHub Sponsors](https://github.com/carlos-granados)[ RSS](/packages/php-static-analysis-rector-rule/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (12)Versions (26)Used By (1)

PHP Static Analysis RectorPHP Rule
==================================

[](#php-static-analysis-rectorphp-rule)

[![Continuous Integration](https://github.com/php-static-analysis/rector-rule/workflows/All%20Tests/badge.svg)](https://github.com/php-static-analysis/rector-rule/actions)[![Latest Stable Version](https://camo.githubusercontent.com/4c04be088539d4d0443c24c031f8124d95c820f1dddb2eb4761e1975938c8b79/68747470733a2f2f706f7365722e707567782e6f72672f7068702d7374617469632d616e616c797369732f726563746f722d72756c652f762f737461626c65)](https://packagist.org/packages/php-static-analysis/rector-rule)[![License](https://camo.githubusercontent.com/056a54de509f45328475b85f26543d24228fa0e67e81e3306fa7a1b28ba20373/68747470733a2f2f706f7365722e707567782e6f72672f7068702d7374617469632d616e616c797369732f726563746f722d72756c652f6c6963656e7365)](https://github.com/php-static-analysis/rector-rule/blob/main/LICENSE)[![Total Downloads](https://camo.githubusercontent.com/07789cd5d62caf6b86b1f278a9ccb5c3b8bdee61ba6ccc93f7efbffbc91dfff4/68747470733a2f2f706f7365722e707567782e6f72672f7068702d7374617469632d616e616c797369732f726563746f722d72756c652f646f776e6c6f616473)](https://packagist.org/packages/php-static-analysis/rector-rule/stats)

Since the release of PHP 8.0 more and more libraries, frameworks and tools have been updated to use attributes instead of annotations in PHPDocs.

However, static analysis tools like PHPStan have not made this transition to attributes and they still rely on annotations in PHPDocs for a lot of their functionality.

This is a set of RectorPHP rules that allows us to convert standard PHP static analysis annotations into a new set of attributes that replace these annotations. These attributes are defined in [this repository](https://github.com/php-static-analysis/attributes)

Example
-------

[](#example)

In order to show how code would look with these attributes, we can look at the following example. This is how a class looks like with the current annotations:

```
