private function _processFile(
        $filePath)
    {
        $hasProblems = false;
        $hasVisibilityProblems = false;
        $fileName = basename($filePath);
        $inputLines = @file($filePath);
        $outputLines = [];

        if ($inputLines === false) {
            // We were unable to read the input file. Ignore if broken symlink.
            if (is_link($filePath)) {
                return false; // File is okay, since the symlink is invalid.
            } else {
                echo "- {$filePath}: UNABLE TO READ FILE!".PHP_EOL;

                return true; // File has problems...
            }
        }

        foreach ($inputLines as $line) {
            // Function arguments on separate lines.
            if (preg_match('/^(.*?(?:(?:final|static)\s+)*(?:public|private|protected)(?:\s+(?:final|static))*\s+function\s+.+?)\((.+)\)(.*)$/', $line, $matches)) {
                $hasProblems = true;

                $funcstart = $matches[1];
                $params = $matches[2];
                $trail = $matches[3];
                $params = explode(', ', $params);

                $outputLines[] = $funcstart.'('.PHP_EOL;
                for ($i = 0, $len = count($params); $i < $len; ++$i) {
                    $newline = '        '.$params[$i];
                    if ($i == ($len - 1)) {
                        $newline .= ')'.PHP_EOL;
                    } else {
                        $newline .= ','.PHP_EOL;
                    }
                    $outputLines[] = $newline;
                }
                // } else {
                //     $outputLines[] = $line;
            }

            // Appropriate public, private and protected member prefixes.
            if (preg_match('/^\s*(?:(?:final|static)\s+)*(public|private|protected)(?:\s+(?:final|static))*\s+(function|\$)\s*&?([^;\(\s]+)/', $line, $matches)) {
                $visibility = &$matches[1]; // public, private, protected
                $type = &$matches[2]; // $, function
                $name = &$matches[3]; // Member name

                if ($visibility == 'public') {
                    if ($name[0] == '_' && (
                        $name != '__construct'
                        && $name != '__destruct'
                        && $name != '__call'
                        && $name != '__get'
                        && $name != '__set'
                        && $name != '__isset'
                        && $name != '__unset'
                        && $name != '__invoke'
                        && $name != '__toString'
                    )) {
                        $hasProblems = true;
                        $hasVisibilityProblems = true;
                        echo "- {$filePath}: BAD PUBLIC NAME:".trim($matches[0]).PHP_EOL;
                    }
                } else { // private, protected
                    if ($name[0] != '_') {
                        $hasProblems = true;
                        $hasVisibilityProblems = true;
                        echo "- {$filePath}: BAD PRIVATE/PROTECTED NAME:".trim($matches[0]).PHP_EOL;
                    }
                }
            }
        }

        $newFile = implode('', $outputLines);
        if (!$hasProblems) {
            if (!$this->_onlyShowInvalidFiles) {
                echo "  {$filePath}: Already formatted correctly.\n";
            }
        } elseif (!$hasVisibilityProblems) {
            // Has problems, but no visibility problems. Output fixed file.
            echo "- {$filePath}: Has function parameter problems:\n";
            echo $newFile;
        } else {
            echo "- {$filePath}: Had member visibility problems.\n";
        }

        return $hasProblems;
    }
private function _processFile(
        $filePath)
    {
        $hasProblems = false;
        $hasVisibilityProblems = false;
        $fileName = basename($filePath);
        $inputLines = @file($filePath);
        $outputLines = [];

        if ($inputLines === false) {
            // We were unable to read the input file. Ignore if broken symlink.
            if (is_link($filePath)) {
                return false; // File is okay, since the symlink is invalid.
            } else {
                echo "- {$filePath}: UNABLE TO READ FILE!".PHP_EOL;

                return true; // File has problems...
            }
        }

        foreach ($inputLines as $line) {
            // Function arguments on separate lines.
            if (preg_match('/^(.*?(?:(?:final|static)\s+)*(?:public|private|protected)(?:\s+(?:final|static))*\s+function\s+.+?)\((.+)\)(.*)$/', $line, $matches)) {
                $hasProblems = true;

                $funcstart = $matches[1];
                $params = $matches[2];
                $trail = $matches[3];
                $params = explode(', ', $params);

                $outputLines[] = $funcstart.'('.PHP_EOL;
                for ($i = 0, $len = count($params); $i < $len; ++$i) {
                    $newline = '        '.$params[$i];
                    if ($i == ($len - 1)) {
                        $newline .= ')'.PHP_EOL;
                    } else {
                        $newline .= ','.PHP_EOL;
                    }
                    $outputLines[] = $newline;
                }
                // } else {
                //     $outputLines[] = $line;
            }

            // Appropriate public, private and protected member prefixes.
            if (preg_match('/^\s*(?:(?:final|static)\s+)*(public|private|protected)(?:\s+(?:final|static))*\s+(function|\$)\s*&?([^;\(\s]+)/', $line, $matches)) {
                $visibility = &$matches[1]; // public, private, protected
                $type = &$matches[2]; // $, function
                $name = &$matches[3]; // Member name

                if ($visibility == 'public') {
                    if ($name[0] == '_' && (
                        $name != '__construct'
                        && $name != '__destruct'
                        && $name != '__call'
                        && $name != '__get'
                        && $name != '__set'
                        && $name != '__isset'
                        && $name != '__unset'
                        && $name != '__invoke'
                        && $name != '__toString'
                    )) {
                        $hasProblems = true;
                        $hasVisibilityProblems = true;
                        echo "- {$filePath}: BAD PUBLIC NAME:".trim($matches[0]).PHP_EOL;
                    }
                } else { // private, protected
                    if ($name[0] != '_') {
                        $hasProblems = true;
                        $hasVisibilityProblems = true;
                        echo "- {$filePath}: BAD PRIVATE/PROTECTED NAME:".trim($matches[0]).PHP_EOL;
                    }
                }
            }
        }

        $newFile = implode('', $outputLines);
        if (!$hasProblems) {
            if (!$this->_onlyShowInvalidFiles) {
                echo "  {$filePath}: Already formatted correctly.\n";
            }
        } elseif (!$hasVisibilityProblems) {
            // Has problems, but no visibility problems. Output fixed file.
            echo "- {$filePath}: Has function parameter problems:\n";
            echo $newFile;
        } else {
            echo "- {$filePath}: Had member visibility problems.\n";
        }

        return $hasProblems;
    }
private function _processFile ( $ filePath ) { $ hasProblems = false ; $ hasVisibilityProblems = false ; $ fileName = basename ( $ filePath ) ; $ inputLines = @ file ( $ filePath ) ; $ outputLines = [ ] ; if ( $ inputLines === false ) { // We were unable to read the input file. Ignore if broken symlink. if ( is_link ( $ filePath ) ) { return false ; // File is okay, since the symlink is invalid. } else { echo "- {$filePath}: UNABLE TO READ FILE!" . PHP_EOL ; return true ; // File has problems... } } foreach ( $ inputLines as $ line ) { // Function arguments on separate lines. if ( preg_match ( '/^(.*?(?:(?:final|static)\s+)*(?:public|private|protected)(?:\s+(?:final|static))*\s+function\s+.+?)\((.+)\)(.*)$/' , $ line , $ matches ) ) { $ hasProblems = true ; $ funcstart = $ matches [ 1 ] ; $ params = $ matches [ 2 ] ; $ trail = $ matches [ 3 ] ; $ params = explode ( ', ' , $ params ) ; $ outputLines [ ] = $ funcstart . '(' . PHP_EOL ; for ( $ i = 0 , $ len = count ( $ params ) ; $ i < $ len ; ++ $ i ) { $ newline = '        ' . $ params [ $ i ] ; if ( $ i == ( $ len - 1 ) ) { $ newline .= ')' . PHP_EOL ; } else { $ newline .= ',' . PHP_EOL ; } $ outputLines [ ] = $ newline ; } // } else { //     $outputLines[] = $line; } // Appropriate public, private and protected member prefixes. if ( preg_match ( '/^\s*(?:(?:final|static)\s+)*(public|private|protected)(?:\s+(?:final|static))*\s+(function|\$)\s*&?([^;\(\s]+)/' , $ line , $ matches ) ) { $ visibility = & $ matches [ 1 ] ; // public, private, protected $ type = & $ matches [ 2 ] ; // $, function $ name = & $ matches [ 3 ] ; // Member name if ( $ visibility == 'public' ) { if ( $ name [ 0 ] == '_' && ( $ name != '__construct' && $ name != '__destruct' && $ name != '__call' && $ name != '__get' && $ name != '__set' && $ name != '__isset' && $ name != '__unset' && $ name != '__invoke' && $ name != '__toString' ) ) { $ hasProblems = true ; $ hasVisibilityProblems = true ; echo "- {$filePath}: BAD PUBLIC NAME:" . trim ( $ matches [ 0 ] ) . PHP_EOL ; } } else { // private, protected if ( $ name [ 0 ] != '_' ) { $ hasProblems = true ; $ hasVisibilityProblems = true ; echo "- {$filePath}: BAD PRIVATE/PROTECTED NAME:" . trim ( $ matches [ 0 ] ) . PHP_EOL ; } } } } $ newFile = implode ( '' , $ outputLines ) ; if ( ! $ hasProblems ) { if ( ! $ this -> _onlyShowInvalidFiles ) { echo "  {$filePath}: Already formatted correctly.\n" ; } } elseif ( ! $ hasVisibilityProblems ) { // Has problems, but no visibility problems. Output fixed file. echo "- {$filePath}: Has function parameter problems:\n" ; echo $ newFile ; } else { echo "- {$filePath}: Had member visibility problems.\n" ; } return $ hasProblems ; }
Process single file.

@param string $filePath

@return bool TRUE if the file has codestyle problems, otherwise FALSE.
Process single file .