class_uses_recursive example



    /** * Checks for traits with corresponding * methods for setUp or tearDown. * * @param string $stage 'setUp' or 'tearDown' */
    private function callTraitMethods(string $stage): void
    {
        if ($this->traits === null) {
            $this->traits = class_uses_recursive($this);
        }

        foreach ($this->traits as $trait) {
            $method = $stage . class_basename($trait);

            if (method_exists($this$method)) {
                $this->{$method}();
            }
        }
    }

    
Home | Imprint | This part of the site doesn't use cookies.