{"record":{"id":"3e3b37102ce69c6a","repo":"mockery/mockery","slug":"unknown-reflectiontype-s","errorCode":null,"errorMessage":"Unknown ReflectionType: %s","messagePattern":"Unknown ReflectionType: (.+?)","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"library/Mockery/Reflector.php","lineNumber":264,"sourceCode":"            );\n\n            $intersect = array_intersect(self::TRAVERSABLE_ARRAY, $types);\n            if (self::TRAVERSABLE_ARRAY === $intersect) {\n                $types = array_merge(self::ITERABLE, array_diff($types, self::TRAVERSABLE_ARRAY));\n            }\n\n            return implode(\n                '|',\n                array_map(\n                    static function (string $type): string {\n                        return strpos($type, '&') === false ? $type : sprintf('(%s)', $type);\n                    },\n                    $types\n                )\n            );\n        }\n\n        throw new InvalidArgumentException('Unknown ReflectionType: ' . get_debug_type($type));\n    }\n\n    /**\n     * Get the string representation of the given type.\n     *\n     * @return list<array{typeHint:string,isPrimitive:bool}>\n     */\n    private static function getTypeInformation(ReflectionType $type, ReflectionClass $declaringClass): array\n    {\n        // PHP 8 union types and PHP 8.1 intersection types can be recursively processed\n        if ($type instanceof ReflectionUnionType || $type instanceof ReflectionIntersectionType) {\n            $types = [];\n\n            foreach ($type->getTypes() as $innerType) {\n                foreach (self::getTypeInformation($innerType, $declaringClass) as $info) {\n                    if ('null' === $info['typeHint'] && $info['isPrimitive']) {\n                        continue;\n                    }","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/mockery/mockery/blob/c6401d35bcd28bd997382f2dae3545355ee77865/library/Mockery/Reflector.php#L246-L282","documentation":"Mockery's Reflector class turns a ReflectionType from the mocked class's method signatures into a string so the generated mock can redeclare the signature. It knows ReflectionNamedType, ReflectionUnionType and ReflectionIntersectionType; anything else falls through to 'Unknown ReflectionType: %s' (Reflector.php:264). This error therefore means your PHP engine produces a reflection type object this Mockery version was never built to understand.","triggerScenarios":"Mocking any class/interface whose method signatures use a type construct introduced after your Mockery release — historically: PHP 8.0 union types on old Mockery, PHP 8.1 intersection types on Mockery < ~1.4.4/1.5, and by construction any future ReflectionType subtype (e.g. from a new PHP minor) on current Mockery. Fires during mock generation/shouldReceive, before any expectation runs.","commonSituations":"CI image or local PHP upgraded (8.0 → 8.1 → 8.x) while composer.lock kept an old mockery; a dependency introduced intersection-typed signatures; running a cutting-edge PHP RC with a released Mockery version.","solutions":["Update Mockery: composer update mockery/mockery — each PHP release is supported in a patch/minor release soon after.","If you cannot update Mockery, pin PHP to a version your Mockery release supports (composer.json require php constraint).","As a stopgap, mock an interface whose signatures avoid the new type syntax, or configure Mockery's internal-class parameter overrides if the offending signature is on an internal class.","Report/patch the new ReflectionType subtype upstream — the fallthrough at Reflector.php:264 is exactly where support gets added."],"exampleFix":"// before: PHP 8.1 intersection type + old mockery => Unknown ReflectionType\n$mock = Mockery::mock(Repo::class); // Repo::find(): A&B\n\n// after: upgrade the library that needs the newer PHP types\n// composer update mockery/mockery\n$mock = Mockery::mock(Repo::class);","handlingStrategy":"try-catch","validationCode":"// Fail fast with an actionable message when the toolchain is too new for this Mockery\nif (version_compare(PHP_VERSION, '8.1', '>=') && \\Composer\\InstalledVersions::getPrettyVersion('mockery/mockery') !== null\n    && version_compare(\\Composer\\InstalledVersions::getPrettyVersion('mockery/mockery'), '1.5', '<')) {\n    throw new RuntimeException('PHP ' . PHP_VERSION . ' types need mockery >= 1.5; run composer update mockery/mockery');\n}\n$mock = Mockery::mock(Repo::class);","typeGuard":null,"tryCatchPattern":"try {\n    $mock = Mockery::mock(Repo::class);\n} catch (\\InvalidArgumentException $e) {\n    if (str_starts_with($e->getMessage(), 'Unknown ReflectionType:')) {\n        throw new RuntimeException(\n            'Mockery ' . \\Mockery::VERSION . ' does not support a PHP ' . PHP_VERSION . ' type; update mockery/mockery',\n            0,\n            $e\n        );\n    }\n    throw $e;\n}","preventionTips":["Upgrade mockery/mockery in lockstep with PHP version upgrades in CI.","Pin the php platform version in composer.json so old mocks cannot install on new PHP.","When a new PHP minor ships, check Mockery's changelog before adopting new type syntax in mocked signatures."],"tags":["mockery","php","reflection","type-hint","php-version","union-types"],"backgroundTag":"unsupported-php-version","analyzedSha":"c6401d35bcd28bd997382f2dae3545355ee77865","analyzedAt":"2026-08-21T04:45:00.060Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}