()
| 1132 | class ClassStringVarDemo |
| 1133 | { |
| 1134 | public function demo(): void |
| 1135 | { |
| 1136 | // new $var where $var holds a class-string |
| 1137 | $cls = Pen::class; |
| 1138 | $pen = new $cls; |
| 1139 | $pen->write(); // resolves Pen from class-string |
| 1140 | |
| 1141 | // $var::staticMethod() where $var holds a class-string |
| 1142 | $userClass = User::class; |
| 1143 | $found = $userClass::findByEmail('test@example.com'); |
| 1144 | $found->getEmail(); // resolves User from class-string static call |
| 1145 | } |
| 1146 | } |
| 1147 | |
| 1148 |
nothing calls this directly
no test coverage detected