From: Roland Häder Date: Thu, 12 Aug 2021 13:48:45 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e44c39a513f5c350acae16d2101b1c7b0371ca3d;p=hub.git Continued: - $infoInstance should not be NULL or anything beside an instance of ShareableInfo Signed-off-by: Roland Häder --- diff --git a/application/hub/classes/handler/package/class_NetworkPackageHandler.php b/application/hub/classes/handler/package/class_NetworkPackageHandler.php index 888aeb3cd..5c83d26d4 100644 --- a/application/hub/classes/handler/package/class_NetworkPackageHandler.php +++ b/application/hub/classes/handler/package/class_NetworkPackageHandler.php @@ -36,6 +36,7 @@ use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint; use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory; use Org\Mxchange\CoreFramework\Factory\Registry\Socket\SocketRegistryFactory; use Org\Mxchange\CoreFramework\Feature\FrameworkFeature; +use Org\Mxchange\CoreFramework\Generic\NullPointerException; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Registry\Registerable; use Org\Mxchange\CoreFramework\Socket\InvalidSocketException; @@ -49,6 +50,7 @@ use Org\Mxchange\CoreFramework\Visitor\Visitor; use \BadMethodCallException; use \InvalidArgumentException; use \Iterator; +use \LogicException; use \UnexpectedValueException; /** @@ -719,7 +721,13 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei $infoInstance = $this->getRegistryInstance()->getInfoInstanceFromPackageInstance($packageInstance); // Test helper instance - assert($infoInstance instanceof ShareableInfo); + if (is_null($infoInstance)) { + // Throw NPE + throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); + } elseif (!($infoInstance instanceof ShareableInfo)) { + // Not the right instance + throw new LogicException(sprintf('infoInstance[]=%s is not an instance of %s', gettype($infoInstance), ShareableInfo::class)); + } // Get helper instance $helperInstance = $infoInstance->getHelperInstance();