ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
GeneratedMockRegistry.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
36{
38 private static array $return_types = [];
39
41 private static array $builders = [];
42
46 public static function isGenerated(string $generated_fqcn): bool
47 {
48 return isset(self::$builders[$generated_fqcn]);
49 }
50
55 public static function register(
56 string $generated_fqcn,
57 array $return_types,
59 ): void {
60 self::$return_types[$generated_fqcn] = $return_types;
61 self::$builders[$generated_fqcn] = $builder;
62 }
63
68 public static function returnTypeFor(string $generated_fqcn, string $method): ?array
69 {
70 return self::$return_types[$generated_fqcn][$method] ?? null;
71 }
72
76 public static function defaultValueFor(object $mock, string $method): mixed
77 {
78 $builder = self::$builders[$mock::class] ?? null;
79
80 if ($builder === null) {
81 // not a generated mock - nothing to derive a value from
82 return null;
83 }
84
85 return $builder->defaultValueFor($mock, $method);
86 }
87}
Bookkeeping about the mock classes that have been generated into the running process.
static returnTypeFor(string $generated_fqcn, string $method)
static defaultValueFor(object $mock, string $method)
Entry point for the generated mocks themselves, see {.