Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/Validator/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use PayNL\Sdk\Common\FactoryInterface;
use Psr\Container\ContainerInterface;
use PayNL\Sdk\Hydrator\HydratorAwareInterface;
use PayNL\Sdk\Packages\Laminas\Hydrator\HydratorAwareInterface;

/**
* Class Factory
Expand All @@ -16,9 +16,12 @@
class Factory implements FactoryInterface
{
/**
* @inheritDoc
*
* @param ContainerInterface $container
* @param string $requestedName
* @param array|null $options
* @return ValidatorInterface
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
public function __invoke(ContainerInterface $container, string $requestedName, array $options = null): ValidatorInterface
{
Expand Down
24 changes: 14 additions & 10 deletions src/Validator/RequiredMembers.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@

use PayNL\Sdk\Exception\InvalidArgumentException;
use PayNL\Sdk\Exception\RuntimeException;
use ReflectionClass, ReflectionException;
use PayNL\Sdk\Hydrator\HydratorAwareInterface;
use PayNL\Sdk\Hydrator\HydratorAwareTrait;
use ReflectionClass,

ReflectionException;
use PayNL\Sdk\Packages\Laminas\Hydrator\HydratorAwareInterface;
use PayNL\Sdk\Packages\Laminas\Hydrator\HydratorAwareTrait;

/**
* Class RequiredMembers
Expand Down Expand Up @@ -38,9 +40,10 @@ class RequiredMembers extends AbstractValidator implements HydratorAwareInterfac
];

/**
* @inheritDoc
* @param mixed $filledObjectToCheck
* @return boolean
*/
public function isValid($filledObjectToCheck): bool
public function isValid(mixed $filledObjectToCheck): bool
{
$className = get_class($filledObjectToCheck);
$required = $this->getRequiredMembers($className);
Expand Down Expand Up @@ -101,7 +104,8 @@ protected function getRequiredMembers(string $className): array

foreach ($ref->getProperties() as $property) {
$docComment = $property->getDocComment();
if (false !== $docComment
if (
false !== $docComment
&& false !== preg_match_all("/@(?P<tag>\S+)(?:\n|\s(?P<type>.+)\n)/s", $docComment, $annotations)
&& true === in_array('required', $annotations['tag'], true)
) {
Expand All @@ -120,7 +124,7 @@ protected function getRequiredMembers(string $className): array
*
* @return array
*/
private function getDataFromObject($objectToExtract): array
private function getDataFromObject(mixed $objectToExtract): array
{
$hydrator = $this->getHydrator();
if (null === $hydrator) {
Expand Down Expand Up @@ -149,12 +153,12 @@ private function getDataFromObject($objectToExtract): array
* Checks if the given $value is empty. In other words, its an empty string, null or
* (if the key is an id field) equal to zero (0).
*
* @param string|int $key
* @param string|integer $key
* @param mixed $value
*
* @return bool
* @return boolean
*/
private function isEmpty($key, $value): bool
private function isEmpty(string $key, mixed $value): bool
{
return null === $value
|| '' === $value
Expand Down