src/Standards/BestIt/Sniffs/Functions/FluentSetterSniff.php
private function checkIfSetterFunction(int $classPosition, File $file, int $methodPosition): bool
    {
        $isSetter = false;
        $methodName = $file->getDeclarationName($methodPosition);

        if (substr($methodName, 0, 3) === 'set') {
            // We define in our styleguide, that there is only one class per file!
            $properties = (new PropertyHelper(new FileDecorator($file)))->getProperties(
                $file->getTokens()[$classPosition]
            );

            // We require camelCase for methods and properties,
            // so there should be an "lcfirst-Method" without set-prefix.
            $isSetter = in_array(lcfirst(substr($methodName, 3)), $properties, true);
        }

        return $isSetter;
    }
private function checkIfSetterFunction(int $classPosition, File $file, int $methodPosition): bool
    {
        $isSetter = false;
        $methodName = $file->getDeclarationName($methodPosition);

        if (substr($methodName, 0, 3) === 'set') {
            // We define in our styleguide, that there is only one class per file!
            $properties = (new PropertyHelper(new FileDecorator($file)))->getProperties(
                $file->getTokens()[$classPosition]
            );

            // We require camelCase for methods and properties,
            // so there should be an "lcfirst-Method" without set-prefix.
            $isSetter = in_array(lcfirst(substr($methodName, 3)), $properties, true);
        }

        return $isSetter;
    }
private function checkIfSetterFunction ( int $ classPosition , File $ file , int $ methodPosition ) : bool { $ isSetter = false ; $ methodName = $ file -> getDeclarationName ( $ methodPosition ) ; if ( substr ( $ methodName , 0 , 3 ) === 'set' ) { // We define in our styleguide, that there is only one class per file! $ properties = ( new PropertyHelper ( new FileDecorator ( $ file ) ) ) -> getProperties ( $ file -> getTokens ( ) [ $ classPosition ] ) ; // We require camelCase for methods and properties, // so there should be an "lcfirst-Method" without set-prefix. $ isSetter = in_array ( lcfirst ( substr ( $ methodName , 3 ) ) , $ properties , true ) ; } return $ isSetter ; }
Checks if the given method name relates to a setter function of a property.

@param int $classPosition The position of the class token.
@param File $file The file of the sniff.
@param int $methodPosition The position of the method token.

@return bool Indicator if the given method is a setter function
Checks if the given method name relates to a setter function of a property .