ObjectCalisthenics\Helper\ClassAnalyzer::getClassProperties PHP Method

getClassProperties() public static method

public static getClassProperties ( PHP_CodeSniffer_File $phpcsFile, integer $stackPtr ) : array
$phpcsFile PHP_CodeSniffer_File
$stackPtr integer
return array
    public static function getClassProperties(PHP_CodeSniffer_File $phpcsFile, int $stackPtr) : array
    {
        $tokens = $phpcsFile->getTokens();
        $token = $tokens[$stackPtr];
        $pointer = $token['scope_opener'];
        self::$propertyList = [];
        while (($pointer = $phpcsFile->findNext(T_VARIABLE, $pointer + 1, $token['scope_closer'])) !== false) {
            self::extractPropertyIfFound($phpcsFile, $pointer);
        }
        return self::$propertyList;
    }

Usage Example

 /**
  * @param PHP_CodeSniffer_File $phpcsFile
  * @param int                  $stackPtr
  */
 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
 {
     $this->propertyList = ClassAnalyzer::getClassProperties($phpcsFile, $stackPtr);
     $this->phpcsFile = $phpcsFile;
     $this->stackPtr = $stackPtr;
     if ($this->checkTotalPropertiesAmount()) {
         return;
     }
     if ($this->checkTrackedPropertiesAmount()) {
         return;
     }
     $this->checkUntrackedPropertyTypeAmount($phpcsFile, $stackPtr);
 }