Showing 1 of 3 files from the diff.
Other files ignored by Codecov
phpstan.neon has changed.
composer.json has changed.

@@ -11,6 +11,7 @@
Loading
11 11
namespace Carbon\Traits;
12 12
13 13
use Closure;
14 +
use Generator;
14 15
use ReflectionClass;
15 16
use ReflectionException;
16 17
use ReflectionMethod;
@@ -69,7 +70,7 @@
Loading
69 70
    }
70 71
71 72
    /**
72 -
     * @param string $mixin
73 +
     * @param object|string $mixin
73 74
     *
74 75
     * @throws ReflectionException
75 76
     */
@@ -95,18 +96,14 @@
Loading
95 96
     */
96 97
    private static function loadMixinTrait($trait)
97 98
    {
98 -
        $baseClass = static::class;
99 -
        $context = eval('return new class() extends '.$baseClass.' {use '.$trait.';};');
99 +
        $context = eval(self::getAnonymousClassCodeForTrait($trait));
100 100
        $className = \get_class($context);
101 101
102 -
        foreach (get_class_methods($context) as $name) {
103 -
            if (method_exists($baseClass, $name)) {
104 -
                continue;
105 -
            }
106 -
102 +
        foreach (self::getMixableMethods($context) as $name) {
107 103
            $closureBase = Closure::fromCallable([$context, $name]);
108 104
109 105
            static::macro($name, function () use ($closureBase, $className) {
106 +
                /** @phpstan-ignore-next-line */
110 107
                $context = isset($this) ? $this->cast($className) : new $className();
111 108
112 109
                try {
@@ -120,6 +117,22 @@
Loading
120 117
        }
121 118
    }
122 119
120 +
    private static function getAnonymousClassCodeForTrait(string $trait)
121 +
    {
122 +
        return 'return new class() extends '.static::class.' {use '.$trait.';};';
123 +
    }
124 +
125 +
    private static function getMixableMethods(self $context): Generator
126 +
    {
127 +
        foreach (get_class_methods($context) as $name) {
128 +
            if (method_exists(static::class, $name)) {
129 +
                continue;
130 +
            }
131 +
132 +
            yield $name;
133 +
        }
134 +
    }
135 +
123 136
    /**
124 137
     * Stack a Carbon context from inside calls of self::this() and execute a given action.
125 138
     *
Files Complexity Coverage
src/Carbon 2,034 100.00%
Project Totals (885 files) 2034 100.00%
4964.11
7.3=.3
TRAVIS_OS_NAME=linux

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading