From 9198797aeac7883734dd876521bf448c3f47d678 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Wed, 12 May 2021 15:44:09 +0000 Subject: [PATCH] [CORE] Throw more meaningfull error when method doesn't exist in Security and Entity --- src/Core/Entity.php | 2 +- src/Core/Security.php | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Core/Entity.php b/src/Core/Entity.php index cf343d6c6b..7db4a39f40 100644 --- a/src/Core/Entity.php +++ b/src/Core/Entity.php @@ -40,7 +40,7 @@ abstract class Entity $private_property_accessor = $private_property_accessor->bindTo($this, get_called_class()); return $private_property_accessor($prop); } - throw new \Exception('Non existent method ' . get_called_class() . "::{$name} called with arguments: " . print_r($arguments, true)); + throw new \BadMethodCallException('Non existent method ' . get_called_class() . "::{$name} called with arguments: " . print_r($arguments, true)); } /** diff --git a/src/Core/Security.php b/src/Core/Security.php index 2f0db3aef5..95aed02a22 100644 --- a/src/Core/Security.php +++ b/src/Core/Security.php @@ -49,7 +49,11 @@ abstract class Security if (method_exists(self::$security, $name)) { return self::$security->{$name}(...$args); } else { - return self::$sanitizer->{$name}(...$args); + if (method_exists(self::$sanitizer, $name)) { + return self::$sanitizer->{$name}(...$args); + } else { + throw new \BadMethodCallException("Method Security::{$name} doesn't exist"); + } } } }