mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Ensure the class has a constructor
if there is no constructor (this means a model which does not inherit from Model) newInstance will throw an exception.
This commit is contained in:
parent
f4c27e04bc
commit
336c750b7e
1 changed files with 5 additions and 1 deletions
|
@ -138,7 +138,11 @@ class ClassRegistry {
|
|||
if ($reflection->isAbstract() || $reflection->isInterface()) {
|
||||
throw new CakeException(__d('cake_dev', 'Cannot create instance of %s, as it is abstract or is an interface', $class));
|
||||
}
|
||||
$instance = $reflection->newInstance($settings);
|
||||
if ($reflection->getConstructor()) {
|
||||
$instance = $reflection->newInstance($settings);
|
||||
} else {
|
||||
$instance = $reflection->newInstance();
|
||||
}
|
||||
if ($strict) {
|
||||
$instance = ($instance instanceof Model) ? $instance : null;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue