src/Standards/BestIt/Sniffs/Functions/FluentSetterSniff.php
private function checkForFluentSetterErrors(File $phpcsFile, int $functionPos, int $classPos): void
    {
        $tokens = $phpcsFile->getTokens();
        $errorData = $phpcsFile->getDeclarationName($classPos) . '::' . $phpcsFile->getDeclarationName($functionPos);

        $functionToken = $tokens[$functionPos];
        $openBracePtr = $functionToken['scope_opener'];
        $closeBracePtr = $functionToken['scope_closer'];

        $returnPtr = $phpcsFile->findNext(T_RETURN, $openBracePtr, $closeBracePtr);

        if ($returnPtr === false) {
            $fixNoReturnFound = $phpcsFile->addFixableError(
                self::ERROR_NO_RETURN_FOUND,
                $functionPos,
                static::CODE_NO_RETURN_FOUND,
                $errorData
            );

            if ($fixNoReturnFound) {
                $this->fixNoReturnFound($phpcsFile, $closeBracePtr);
            }

            return;
        }

        $this->checkAndRegisterEmptyReturnErrors($phpcsFile, $functionPos, $returnPtr, $errorData);
    }
private function checkForFluentSetterErrors(File $phpcsFile, int $functionPos, int $classPos): void
    {
        $tokens = $phpcsFile->getTokens();
        $errorData = $phpcsFile->getDeclarationName($classPos) . '::' . $phpcsFile->getDeclarationName($functionPos);

        $functionToken = $tokens[$functionPos];
        $openBracePtr = $functionToken['scope_opener'];
        $closeBracePtr = $functionToken['scope_closer'];

        $returnPtr = $phpcsFile->findNext(T_RETURN, $openBracePtr, $closeBracePtr);

        if ($returnPtr === false) {
            $fixNoReturnFound = $phpcsFile->addFixableError(
                self::ERROR_NO_RETURN_FOUND,
                $functionPos,
                static::CODE_NO_RETURN_FOUND,
                $errorData
            );

            if ($fixNoReturnFound) {
                $this->fixNoReturnFound($phpcsFile, $closeBracePtr);
            }

            return;
        }

        $this->checkAndRegisterEmptyReturnErrors($phpcsFile, $functionPos, $returnPtr, $errorData);
    }
private function checkForFluentSetterErrors ( File $ phpcsFile , int $ functionPos , int $ classPos ) : void { $ tokens = $ phpcsFile -> getTokens ( ) ; $ errorData = $ phpcsFile -> getDeclarationName ( $ classPos ) . '::' . $ phpcsFile -> getDeclarationName ( $ functionPos ) ; $ functionToken = $ tokens [ $ functionPos ] ; $ openBracePtr = $ functionToken [ 'scope_opener' ] ; $ closeBracePtr = $ functionToken [ 'scope_closer' ] ; $ returnPtr = $ phpcsFile -> findNext ( T_RETURN , $ openBracePtr , $ closeBracePtr ) ; if ( $ returnPtr === false ) { $ fixNoReturnFound = $ phpcsFile -> addFixableError ( self :: ERROR_NO_RETURN_FOUND , $ functionPos , static :: CODE_NO_RETURN_FOUND , $ errorData ) ; if ( $ fixNoReturnFound ) { $ this -> fixNoReturnFound ( $ phpcsFile , $ closeBracePtr ) ; } return ; } $ this -> checkAndRegisterEmptyReturnErrors ( $ phpcsFile , $ functionPos , $ returnPtr , $ errorData ) ; }
Checks if there are fluent setter errors and registers errors if needed.

@param File $phpcsFile The file for this sniff.
@param int $functionPos The position of the used token.
@param int $classPos The position of the class.

@return void
Checks if there are fluent setter errors and registers errors if needed .