1 | <?php |
||
14 | class BaseClassResolver implements BaseClassResolverInterface |
||
15 | { |
||
16 | |||
17 | /** |
||
18 | * Name used to group global base classes |
||
19 | */ |
||
20 | const DEFAULT_MODULE = '_default'; |
||
21 | |||
22 | /** |
||
23 | * @var string[][][] |
||
24 | */ |
||
25 | private static $baseClasses = []; |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $module; |
||
31 | |||
32 | /** |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $type; |
||
36 | |||
37 | /** |
||
38 | * @var string |
||
39 | */ |
||
40 | protected $suite; |
||
41 | |||
42 | /** |
||
43 | * BaseClassResolver constructor. |
||
44 | * |
||
45 | * @param CodeceptionTestType $type |
||
46 | * @param string $suite |
||
47 | * @param string|null $module |
||
48 | */ |
||
49 | public function __construct(CodeceptionTestType $type, string $suite, string $module = null) |
||
55 | |||
56 | /** |
||
57 | * @inheritDoc |
||
58 | */ |
||
59 | public function registerBaseClass($baseClass) |
||
65 | |||
66 | /** |
||
67 | * @inheritDoc |
||
68 | */ |
||
69 | public function getBaseClass() : string |
||
77 | |||
78 | /** |
||
79 | * @inheritDoc |
||
80 | */ |
||
81 | public static function registerBaseClassForModule(CodeceptionTestType $type, string $suite, string $module, $baseClass) |
||
85 | |||
86 | /** |
||
87 | * @inheritDoc |
||
88 | */ |
||
89 | public static function getBaseClassForModule(CodeceptionTestType $type, string $suite, string $module) : string |
||
93 | |||
94 | /** |
||
95 | * @param string $class |
||
96 | * |
||
97 | * @throws BaseClassDoesNotExist |
||
98 | */ |
||
99 | protected function validateClass(string $class) |
||
105 | |||
106 | } |
||
107 |
Let’s assume you have a class which uses late-static binding:
The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the
getSomeVariable()
on that sub-class, you will receive a runtime error:In the case above, it makes sense to update
SomeClass
to useself
instead: