aik099 / CodingStandard

The PHP_CodeSniffer coding standard I'm using on all of my projects
BSD 3-Clause "New" or "Revised" License
5 stars 2 forks source link

Create AssignByReferenceSniff #63

Closed aik099 closed 8 years ago

aik099 commented 9 years ago

In-Portal Specific Sniff.

Sniff will:

  1. have list of predefined functions with their definition files:
    • recallObject - core/kernel/application.php
    • makeClass - core/kernel/application.php
    • GetList - core/kernel/db/db_tag_processor.php
    • getObject - core/kernel/db/db_tag_processor.php
    • getObject - core/kernel/utility/event.php
    • do a one time query to corresponding files (when found) to determine if these function declaration has & or not
  2. look for calls to these functions in scanned file
    • report =& assignment as error, when function declaration don't have &
    • report = assignment as error, when function declaration has &
    • account for malformed assignment operator: $a = &$this->.... (= and & are separated by whitespace)

Related Issues: #12

aik099 commented 8 years ago

This would be hard to implement and slow to run. Instead I've used sgrep/spatch from https://github.com/facebook/pfff to mass find/fix such issues in all projects.