-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Hydrator\AttributeHandling\Exception; | ||
|
||
use LogicException; | ||
|
||
final class AttributeResolverNonInstantiableException extends LogicException | ||
{ | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Hydrator\Exception; | ||
|
||
use ReflectionClass; | ||
|
||
final class AbstractClassException extends NonInstantiableException | ||
{ | ||
public function __construct(ReflectionClass $reflectionClass) | ||
{ | ||
parent::__construct( | ||
Check warning on line 13 in src/Exception/AbstractClassException.php GitHub Actions / mutation / PHP 8.2-ubuntu-latest
|
||
sprintf( | ||
'%s is not instantiable because it is abstract.', | ||
$reflectionClass->getName(), | ||
), | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Hydrator\Exception; | ||
|
||
final class NonExistClassException extends NonInstantiableException | ||
{ | ||
public function __construct(string $class) | ||
{ | ||
parent::__construct( | ||
Check warning on line 11 in src/Exception/NonExistClassException.php GitHub Actions / mutation / PHP 8.2-ubuntu-latest
|
||
sprintf( | ||
'Class %s not exist.', | ||
$class | ||
), | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Hydrator\Exception; | ||
|
||
use LogicException; | ||
|
||
class NonInstantiableException extends LogicException | ||
{ | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Hydrator\Exception; | ||
|
||
use ReflectionMethod; | ||
|
||
final class NonPublicConstructorException extends NonInstantiableException | ||
{ | ||
public function __construct(ReflectionMethod $constructor) | ||
{ | ||
$type = $this->getConstructorType($constructor); | ||
parent::__construct( | ||
Check warning on line 14 in src/Exception/NonPublicConstructorException.php GitHub Actions / mutation / PHP 8.2-ubuntu-latest
|
||
sprintf( | ||
'%s is not instantiable because contain non-public%s constructor.', | ||
$constructor->getDeclaringClass()->getName(), | ||
$type !== null ? ' (' . $type . ')' : '', | ||
Check warning on line 18 in src/Exception/NonPublicConstructorException.php GitHub Actions / mutation / PHP 8.2-ubuntu-latest
Check warning on line 18 in src/Exception/NonPublicConstructorException.php GitHub Actions / mutation / PHP 8.2-ubuntu-latest
Check warning on line 18 in src/Exception/NonPublicConstructorException.php GitHub Actions / mutation / PHP 8.2-ubuntu-latest
Check warning on line 18 in src/Exception/NonPublicConstructorException.php GitHub Actions / mutation / PHP 8.2-ubuntu-latest
Check warning on line 18 in src/Exception/NonPublicConstructorException.php GitHub Actions / mutation / PHP 8.2-ubuntu-latest
|
||
), | ||
); | ||
} | ||
|
||
private function getConstructorType(ReflectionMethod $constructor): ?string | ||
{ | ||
if ($constructor->isPrivate()) { | ||
return 'private'; | ||
} | ||
|
||
if ($constructor->isProtected()) { | ||
return 'protected'; | ||
} | ||
|
||
return null; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Hydrator\Exception; | ||
|
||
final class WrongConstructorArgumentsCountException extends NonInstantiableException | ||
{ | ||
public function __construct(\ReflectionMethod $constructor, int $countArguments) | ||
{ | ||
parent::__construct( | ||
sprintf( | ||
'Class "%s" cannot be instantiated because it has %d required parameters in constructor, but passed only %d.', | ||
$constructor->getDeclaringClass()->getName(), | ||
$constructor->getNumberOfRequiredParameters(), | ||
$countArguments, | ||
) | ||
); | ||
} | ||
} |