File tree Expand file tree Collapse file tree 1 file changed +11
-12
lines changed Expand file tree Collapse file tree 1 file changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -58,19 +58,18 @@ public function __construct(Request $request, Response $response)
58
58
*/
59
59
protected function prepareModel () : static
60
60
{
61
- if ( ! \property_exists ($ this , 'model ' )) {
62
- return $ this ;
61
+ if (\property_exists ($ this , 'model ' )) {
62
+ $ property = new ReflectionProperty ($ this , 'model ' );
63
+ $ type = $ property ->getType ();
64
+ if ( ! $ type instanceof ReflectionNamedType || $ type ->isBuiltin ()) {
65
+ throw new LogicException (
66
+ 'The ' . static ::class
67
+ . '::$model property must have one type to be instantiated '
68
+ );
69
+ }
70
+ $ name = $ type ->getName ();
71
+ $ this ->model = new $ name ();
63
72
}
64
- $ property = new ReflectionProperty ($ this , 'model ' );
65
- $ type = $ property ->getType ();
66
- if ( ! $ type instanceof ReflectionNamedType || $ type ->isBuiltin ()) {
67
- throw new LogicException (
68
- 'The ' . static ::class
69
- . '::$model property must have one type to be instantiated '
70
- );
71
- }
72
- $ name = $ type ->getName ();
73
- $ this ->model = new $ name ();
74
73
return $ this ;
75
74
}
76
75
You can’t perform that action at this time.
0 commit comments