From becc162df8661d13df78b1b953c428d335993b1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Sun, 15 Mar 2020 23:06:36 +0100 Subject: [PATCH] Do not wrap exception message in array --- src/StaticAddToTrait.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/StaticAddToTrait.php b/src/StaticAddToTrait.php index fa832f16..29ed6d93 100644 --- a/src/StaticAddToTrait.php +++ b/src/StaticAddToTrait.php @@ -30,7 +30,7 @@ trait StaticAddToTrait public static function addTo(object $parent, $seed = [], array $add_args = []) { if (func_num_args() > 3) { // prevent bad usage - throw new \Error(['Too many method arguments']); + throw new \Error('Too many method arguments'); } if (is_object($seed)) { @@ -38,7 +38,7 @@ public static function addTo(object $parent, $seed = [], array $add_args = []) } else { if (!is_array($seed)) { if (!is_scalar($seed)) { // allow single element seed but prevent bad usage - throw (new Exception(['Seed must be an array or a scalar'])) + throw (new Exception('Seed must be an array or a scalar')) ->addMoreInfo('seed_type', gettype($seed)); } @@ -62,7 +62,7 @@ private static function _addTo_add(object $parent, object $object, bool $unsafe, { // check if object is instance of this class if (!$unsafe && !($object instanceof static)) { - throw (new Exception(['Seed class name is not a subtype of the current class'])) + throw (new Exception('Seed class name is not a subtype of the current class')) ->addMoreInfo('seed_class', get_class($object)) ->addMoreInfo('current_class', static::class); } @@ -83,7 +83,7 @@ private static function _addTo_add(object $parent, object $object, bool $unsafe, public static function addToWithClassName(object $parent, $seed = [], array $add_args = []) { if (func_num_args() > 3) { // prevent bad usage - throw new \Error(['Too many method arguments']); + throw new \Error('Too many method arguments'); } return static::_addToWithClassName($parent, $seed, false, $add_args); @@ -99,7 +99,7 @@ public static function addToWithClassName(object $parent, $seed = [], array $add public static function addToWithClassNameUnsafe(object $parent, $seed = [], array $add_args = []) { if (func_num_args() > 3) { // prevent bad usage - throw new \Error(['Too many method arguments']); + throw new \Error('Too many method arguments'); } return static::_addToWithClassName($parent, $seed, true, $add_args); @@ -115,7 +115,7 @@ private static function _addToWithClassName(object $parent, $seed, bool $unsafe, } else { if (!is_array($seed)) { if (!is_scalar($seed)) { // allow single element seed but prevent bad usage - throw (new Exception(['Seed must be an array or a scalar'])) + throw (new Exception('Seed must be an array or a scalar')) ->addMoreInfo('seed_type', gettype($seed)); }