packages/PhpSpecToPHPUnit/src/Rector/MethodCall/PhpSpecMocksToPHPUnitMocksRector.php
private function createCreateMockCall(Param $param, Name $name): ?Expression
    {
        /** @var Class_ $classNode */
        $classNode = $param->getAttribute(AttributeKey::CLASS_NODE);

        $classMocks = $this->phpSpecMockCollector->resolveClassMocksFromParam($classNode);

        $variable = $this->getName($param->var);
        $method = $param->getAttribute(AttributeKey::METHOD_NAME);

        $methodsWithWThisMock = $classMocks[$variable];

        // single use: "$mock = $this->createMock()"
        if (! $this->phpSpecMockCollector->isVariableMockInProperty($param->var)) {
            return $this->createNewMockVariableAssign($param, $name);
        }

        $reversedMethodsWithThisMock = array_flip($methodsWithWThisMock);

        // first use of many: "$this->mock = $this->createMock()"
        if ($reversedMethodsWithThisMock[$method] === 0) {
            return $this->createPropertyFetchMockVariableAssign($param, $name);
        }

        return null;
    }
private function createCreateMockCall(Param $param, Name $name): ?Expression
    {
        /** @var Class_ $classNode */
        $classNode = $param->getAttribute(AttributeKey::CLASS_NODE);

        $classMocks = $this->phpSpecMockCollector->resolveClassMocksFromParam($classNode);

        $variable = $this->getName($param->var);
        $method = $param->getAttribute(AttributeKey::METHOD_NAME);

        $methodsWithWThisMock = $classMocks[$variable];

        // single use: "$mock = $this->createMock()"
        if (! $this->phpSpecMockCollector->isVariableMockInProperty($param->var)) {
            return $this->createNewMockVariableAssign($param, $name);
        }

        $reversedMethodsWithThisMock = array_flip($methodsWithWThisMock);

        // first use of many: "$this->mock = $this->createMock()"
        if ($reversedMethodsWithThisMock[$method] === 0) {
            return $this->createPropertyFetchMockVariableAssign($param, $name);
        }

        return null;
    }
private function createCreateMockCall ( Param $ param , Name $ name ) : ? Expression { /** @var Class_ $classNode */ $ classNode = $ param -> getAttribute ( AttributeKey :: CLASS_NODE ) ; $ classMocks = $ this -> phpSpecMockCollector -> resolveClassMocksFromParam ( $ classNode ) ; $ variable = $ this -> getName ( $ param -> var ) ; $ method = $ param -> getAttribute ( AttributeKey :: METHOD_NAME ) ; $ methodsWithWThisMock = $ classMocks [ $ variable ] ; // single use: "$mock = $this->createMock()" if ( ! $ this -> phpSpecMockCollector -> isVariableMockInProperty ( $ param -> var ) ) { return $ this -> createNewMockVariableAssign ( $ param , $ name ) ; } $ reversedMethodsWithThisMock = array_flip ( $ methodsWithWThisMock ) ; // first use of many: "$this->mock = $this->createMock()" if ( $ reversedMethodsWithThisMock [ $ method ] === 0 ) { return $ this -> createPropertyFetchMockVariableAssign ( $ param , $ name ) ; } return null ; }
Variable or property fetch, based on number of present params in whole class
Variable or property fetch based on number of present params in whole class