packages/PhpSpecToPHPUnit/src/Rector/Class_/PhpSpecClassToPHPUnitClassRector.php
private function removeSelfTypeMethod(Class_ $node): Class_
    {
        foreach ((array) $node->stmts as $key => $stmt) {
            if (! $stmt instanceof ClassMethod) {
                continue;
            }

            if (count((array) $stmt->stmts) !== 1) {
                continue;
            }

            $innerClassMethodStmt = $stmt->stmts[0] instanceof Expression ? $stmt->stmts[0]->expr : $stmt->stmts[0];

            if (! $innerClassMethodStmt instanceof MethodCall) {
                continue;
            }

            if (! $this->isName($innerClassMethodStmt, 'shouldHaveType')) {
                continue;
            }

            // not the tested type
            if (! $this->isValue($innerClassMethodStmt->args[0]->value, $this->testedClass)) {
                continue;
            }

            // remove it
            unset($node->stmts[$key]);
        }

        return $node;
    }
private function removeSelfTypeMethod(Class_ $node): Class_
    {
        foreach ((array) $node->stmts as $key => $stmt) {
            if (! $stmt instanceof ClassMethod) {
                continue;
            }

            if (count((array) $stmt->stmts) !== 1) {
                continue;
            }

            $innerClassMethodStmt = $stmt->stmts[0] instanceof Expression ? $stmt->stmts[0]->expr : $stmt->stmts[0];

            if (! $innerClassMethodStmt instanceof MethodCall) {
                continue;
            }

            if (! $this->isName($innerClassMethodStmt, 'shouldHaveType')) {
                continue;
            }

            // not the tested type
            if (! $this->isValue($innerClassMethodStmt->args[0]->value, $this->testedClass)) {
                continue;
            }

            // remove it
            unset($node->stmts[$key]);
        }

        return $node;
    }
private function removeSelfTypeMethod ( Class_ $ node ) : Class_ { foreach ( ( array ) $ node -> stmts as $ key => $ stmt ) { if ( ! $ stmt instanceof ClassMethod ) { continue ; } if ( count ( ( array ) $ stmt -> stmts ) !== 1 ) { continue ; } $ innerClassMethodStmt = $ stmt -> stmts [ 0 ] instanceof Expression ? $ stmt -> stmts [ 0 ] -> expr : $ stmt -> stmts [ 0 ] ; if ( ! $ innerClassMethodStmt instanceof MethodCall ) { continue ; } if ( ! $ this -> isName ( $ innerClassMethodStmt , 'shouldHaveType' ) ) { continue ; } // not the tested type if ( ! $ this -> isValue ( $ innerClassMethodStmt -> args [ 0 ] -> value , $ this -> testedClass ) ) { continue ; } // remove it unset ( $ node -> stmts [ $ key ] ) ; } return $ node ; }
This is already checked on construction of object
This is already checked on construction of object