From db59cf63a5a5e1c645046ebddc0861cefba56f7d Mon Sep 17 00:00:00 2001 From: "celine.c" Date: Wed, 27 Sep 2023 17:47:55 +0200 Subject: [PATCH 1/5] feat: change xmlrpc bundle --- DependencyInjection/Configuration.php | 2 +- .../MppUniversignExtension.php | 2 +- Event/UniversignCallbackEvent.php | 12 +- Model/CertificateType.php | 6 +- Model/DocSignatureField.php | 53 +-- Model/Document.php | 165 ++------- Model/IdDocument.php | 46 ++- Model/Language.php | 22 +- Model/MatchingFilter.php | 1 - Model/MatchingResult.php | 16 +- Model/PersonalInfo.php | 62 +--- Model/RaCertificateInfo.php | 50 +-- Model/SignOptions.php | 8 +- Model/SignatureField.php | 1 - Model/Signer.php | 317 +++--------------- Model/TransactionFilter.php | 217 ++---------- Model/TransactionRequest.php | 2 +- Model/TransactionResponse.php | 4 +- Model/ValidatorResult.php | 6 +- Model/XmlRpc/Base64.php | 16 + Requester/RegistrationAuthority.php | 30 +- Requester/RegistrationAuthorityInterface.php | 8 +- Requester/Signer.php | 121 ++++--- Requester/SignerInterface.php | 2 +- Requester/XmlRpcRequester.php | 66 +++- Resources/config/services.yaml | 18 +- composer.json | 6 +- 27 files changed, 353 insertions(+), 906 deletions(-) create mode 100644 Model/XmlRpc/Base64.php diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 782c1f0..df1afe1 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -9,7 +9,7 @@ class Configuration implements ConfigurationInterface { - const CONFIGURATION_ROOT = 'mpp_universign'; + public const CONFIGURATION_ROOT = 'mpp_universign'; public function getConfigTreeBuilder() { diff --git a/DependencyInjection/MppUniversignExtension.php b/DependencyInjection/MppUniversignExtension.php index 8866c3a..61da4dd 100644 --- a/DependencyInjection/MppUniversignExtension.php +++ b/DependencyInjection/MppUniversignExtension.php @@ -19,7 +19,7 @@ public function load(array $configs, ContainerBuilder $container) { $configuration = new Configuration($container->getParameter('kernel.debug')); $config = $this->processConfiguration($configuration, $configs); - $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); $loader->load('services.yaml'); $container->setParameter( diff --git a/Event/UniversignCallbackEvent.php b/Event/UniversignCallbackEvent.php index fe26fda..acc39d3 100644 --- a/Event/UniversignCallbackEvent.php +++ b/Event/UniversignCallbackEvent.php @@ -4,15 +4,15 @@ class UniversignCallbackEvent { - const STATUS_READY = 0; - const STATUS_EXPIRED = 1; - const STATUS_COMPLETED = 2; - const STATUS_CANCELED = 3; - const STATUS_ERROR = 4; + public const STATUS_READY = 0; + public const STATUS_EXPIRED = 1; + public const STATUS_COMPLETED = 2; + public const STATUS_CANCELED = 3; + public const STATUS_ERROR = 4; /** * All signatories have signed BUT waiting for Universign registration authority validation. */ - const STATUS_SIGNED = 5; + public const STATUS_SIGNED = 5; /** * @var string diff --git a/Model/CertificateType.php b/Model/CertificateType.php index 1ffa426..84d4357 100644 --- a/Model/CertificateType.php +++ b/Model/CertificateType.php @@ -4,7 +4,7 @@ class CertificateType { - const SIMPLE = 'simple'; - const CERTIFIED = 'certified'; - const ADVANCED = 'advanced'; + public const SIMPLE = 'simple'; + public const CERTIFIED = 'certified'; + public const ADVANCED = 'advanced'; } diff --git a/Model/DocSignatureField.php b/Model/DocSignatureField.php index d662197..ef59d14 100644 --- a/Model/DocSignatureField.php +++ b/Model/DocSignatureField.php @@ -2,31 +2,22 @@ namespace Mpp\UniversignBundle\Model; +use Mpp\UniversignBundle\Model\XmlRpc\Base64; use Symfony\Component\OptionsResolver\Exception\AccessException; use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; use Symfony\Component\OptionsResolver\Exception\MissingOptionsException; use Symfony\Component\OptionsResolver\Exception\NoSuchOptionException; use Symfony\Component\OptionsResolver\Exception\OptionDefinitionException; use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException; -use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; class DocSignatureField extends SignatureField { - /** - * @var string - */ - protected $patternName; + protected string $patternName; - /** - * @var string - */ - protected $label; + protected string $label; - /** - * @var \Laminas\XmlRpc\Value\Base64 - */ - protected $image; + protected Base64 $image; /** * @param OptionsResolver $resolver @@ -38,7 +29,7 @@ public static function configureData(OptionsResolver $resolver) $resolver ->setDefault('patternName', null)->setAllowedTypes('patternName', ['string', 'null']) ->setDefault('label', null)->setAllowedTypes('label', ['string', 'null']) - ->setDefault('image', null)->setAllowedTypes('image', ['string', 'null']) + ->setDefault('image', null)->setAllowedTypes('image', [Base64::class, 'null']) ; } @@ -61,22 +52,17 @@ public static function createFromArray(array $options): self $resolvedOptions = $resolver->resolve($options); return (new self()) + ->setPatternName($resolvedOptions['patternName']) + ->setLabel($resolvedOptions['label']) + ->setImage($resolvedOptions['image']) ->setName($resolvedOptions['name']) ->setPage($resolvedOptions['page']) ->setX($resolvedOptions['x']) ->setY($resolvedOptions['y']) ->setSignerIndex($resolvedOptions['signerIndex']) - ->setPatternName($resolvedOptions['patternName']) - ->setLabel($resolvedOptions['label']) - ->setImage($resolvedOptions['image']) ; } - /** - * @param string $patternName - * - * @return self - */ public function setPatternName(?string $patternName): self { $this->patternName = $patternName; @@ -84,19 +70,11 @@ public function setPatternName(?string $patternName): self return $this; } - /** - * @return string - */ public function getPatternName(): string { return $this->patternName; } - /** - * @param string $label - * - * @return self - */ public function setLabel(?string $label): self { $this->label = $label; @@ -104,30 +82,19 @@ public function setLabel(?string $label): self return $this; } - /** - * @return string - */ public function getLabel(): string { return $this->label; } - /** - * @param array $image - * - * @return self - */ - public function setImage(?array $image): self + public function setImage(?Base64 $image): self { $this->image = $image; return $this; } - /** - * @return \Laminas\XmlRpc\Value\Base64 - */ - public function getImage(): \Laminas\XmlRpc\Value\Base64 + public function getImage(): Base64 { return $this->image; } diff --git a/Model/Document.php b/Model/Document.php index 59fb981..bc872e6 100644 --- a/Model/Document.php +++ b/Model/Document.php @@ -2,6 +2,7 @@ namespace Mpp\UniversignBundle\Model; +use Mpp\UniversignBundle\Model\XmlRpc\Base64; use Symfony\Component\OptionsResolver\Exception\AccessException; use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; use Symfony\Component\OptionsResolver\Exception\MissingOptionsException; @@ -13,77 +14,40 @@ class Document { - /** - * @var int - */ - protected $id; + protected ?int $id; - /** - * @var string - */ - protected $documentType; + protected ?string $documentType; - /** - * @var \Laminas\XmlRpc\Value\Base64 - */ - protected $content; + protected ?Base64 $content; - /** - * @var string - */ - protected $url; + protected ?string $url; - /** - * @var string - */ - protected $fileName; + protected ?string $fileName; /** * @var array */ - protected $signatureFields; + protected array $signatureFields; - /** - * @var array - */ - protected $checkBoxTexts; + protected ?array $checkBoxTexts; - /** - * @var array - */ - protected $metaData; + protected ?array $metaData; - /** - * @var string - */ - protected $title; + protected ?string $title; - /** - * @var SepaData - */ - protected $sepaData; + protected ?SepaData $sepaData; - /** - * @param OptionsResolver $resolver - */ - public static function configureData(OptionsResolver $resolver) + public static function configureData(OptionsResolver $resolver): void { $resolver ->setDefault('id', null)->setAllowedTypes('id', ['null', 'string']) ->setDefault('documentType', 'pdf')->setAllowedValues('documentType', ['pdf', 'pdf-for-presentation', 'pdf-optional', 'sepa']) - ->setDefault('content', null)->setAllowedTypes('content', ['null', 'string', \Laminas\XmlRpc\Value\Base64::class])->setNormalizer('content', function (Options $options, $value): ?\Laminas\XmlRpc\Value\Base64 { - if ($value instanceof \Laminas\XmlRpc\Value\Base64) { + ->setDefault('content', null)->setAllowedTypes('content', ['null', 'string', Base64::class])->setNormalizer('content', function (Options $options, $value): ?Base64 { + if (null === $value || $value instanceof Base64) { return $value; } - if (null === $value || !file_exists($value)) { - return null; - } - - $file = file_get_contents($value); - $b64 = new \Laminas\XmlRpc\Value\Base64($file); - - return $b64; + return new Base64($value); }) ->setDefault('url', null)->setAllowedTypes('url', ['null', 'string']) ->setDefault('fileName', null)->setAllowedTypes('fileName', ['null', 'string']) @@ -99,7 +63,7 @@ public static function configureData(OptionsResolver $resolver) return $signatureFields; }) - ->setDefault('checkBoxTexts', null)->setAllowedTypes('checkBoxTexts', ['null', 'array'])->setNormalizer('checkBoxTexts', function (Options $options, $value) { + ->setDefault('checkBoxTexts', null)->setAllowedTypes('checkBoxTexts', ['null', 'array'])->setNormalizer('checkBoxTexts', function (Options $options, $value) { if ('pdf-for-presentation' === $options['documentType']) { return null; } @@ -123,10 +87,6 @@ public static function configureData(OptionsResolver $resolver) } /** - * @param array $options - * - * @return self - * * @throws UndefinedOptionsException If an option name is undefined * @throws InvalidOptionsException If an option doesn't fulfill the language specified validation rules * @throws MissingOptionsException If a required option is missing @@ -154,11 +114,6 @@ public static function createFromArray(array $options): Document ; } - /** - * @param int|null $id - * - * @return self - */ public function setId(?int $id): self { $this->id = $id; @@ -166,19 +121,11 @@ public function setId(?int $id): self return $this; } - /** - * @return int|null - */ public function getId(): ?int { return $this->id; } - /** - * @param string|null $documentType - * - * @return self - */ public function setDocumentType(?string $documentType): self { $this->documentType = $documentType; @@ -186,39 +133,23 @@ public function setDocumentType(?string $documentType): self return $this; } - /** - * @return string|null - */ public function getDocumentType(): ?string { return $this->documentType; } - /** - * @param \Laminas\XmlRpc\Value\Base64|null $content - * - * @return self - */ - public function setContent(?\Laminas\XmlRpc\Value\Base64 $content): self + public function setContent(?Base64 $content): self { $this->content = $content; return $this; } - /** - * @return \Laminas\XmlRpc\Value\Base64|null - */ - public function getContent(): ?\Laminas\XmlRpc\Value\Base64 + public function getContent(): ?Base64 { return $this->content; } - /** - * @param string|null $url - * - * @return self - */ public function setUrl(?string $url): self { $this->url = $url; @@ -226,19 +157,11 @@ public function setUrl(?string $url): self return $this; } - /** - * @return string|null - */ public function getUrl(): ?string { return $this->url; } - /** - * @param string|null $fileName - * - * @return self - */ public function setFileName(?string $fileName): self { $this->fileName = $fileName; @@ -246,19 +169,11 @@ public function setFileName(?string $fileName): self return $this; } - /** - * @return string|null - */ public function getFileName(): ?string { return $this->fileName; } - /** - * @param SignatureField $signatureField - * - * @return self - */ public function addSignatureField(SignatureField $signatureField): self { $this->signatureFields[] = $signatureField; @@ -266,31 +181,18 @@ public function addSignatureField(SignatureField $signatureField): self return $this; } - /** - * @param array|null $signatureFields - * - * @return self - */ - public function setSignatureFields(?array $signatureFields): self + public function setSignatureFields(array $signatureFields): self { $this->signatureFields = $signatureFields; return $this; } - /** - * @return array|null - */ - public function getSignatureFields(): ?array + public function getSignatureFields(): array { return $this->signatureFields; } - /** - * @param array|null $checkBoxTexts - * - * @return self - */ public function setCheckBoxTexts(?array $checkBoxTexts): self { $this->checkBoxTexts = $checkBoxTexts; @@ -298,19 +200,11 @@ public function setCheckBoxTexts(?array $checkBoxTexts): self return $this; } - /** - * @return array|null - */ public function getCheckBoxTexts(): ?array { return $this->checkBoxTexts; } - /** - * @param array|null $metaData - * - * @return self - */ public function setMetaData(?array $metaData): self { $this->metaData = $metaData; @@ -318,19 +212,11 @@ public function setMetaData(?array $metaData): self return $this; } - /** - * @return array|null - */ public function getMetaData(): ?array { return $this->metaData; } - /** - * @param string|null $title - * - * @return self - */ public function setTitle(?string $title): self { $this->title = $title; @@ -338,19 +224,11 @@ public function setTitle(?string $title): self return $this; } - /** - * @return string|null - */ public function getTitle(): ?string { return $this->title; } - /** - * @param SepaData|null $sepaData - * - * @return self - */ public function setSepaData(?SepaData $sepaData): self { $this->sepaData = $sepaData; @@ -358,9 +236,6 @@ public function setSepaData(?SepaData $sepaData): self return $this; } - /** - * @return SepaData|null - */ public function getSepaData(): ?SepaData { return $this->sepaData; diff --git a/Model/IdDocument.php b/Model/IdDocument.php index 805eaab..428d761 100644 --- a/Model/IdDocument.php +++ b/Model/IdDocument.php @@ -2,7 +2,7 @@ namespace Mpp\UniversignBundle\Model; -use Laminas\XmlRpc\Value\Base64; +use Mpp\UniversignBundle\Model\XmlRpc\Base64; use Symfony\Component\OptionsResolver\Exception\AccessException; use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; use Symfony\Component\OptionsResolver\Exception\MissingOptionsException; @@ -14,42 +14,44 @@ class IdDocument { - const TYPE_IDENTITY_CARD = 0; - const TYPE_PASSPORT = 1; - const TYPE_RESIDENCE_PERMIT = 2; - const TYPE_EUROPEAN_DRIVER_LICENSE = 3; + public const TYPE_IDENTITY_CARD = 0; + public const TYPE_PASSPORT = 1; + public const TYPE_RESIDENCE_PERMIT = 2; + public const TYPE_EUROPEAN_DRIVER_LICENSE = 3; /** * @var Base64[] */ - protected $photos; + protected array $photos; - /** - * @var int - */ - protected $type; + protected int $type; /** - * @param OptionsResolver $resolver + * @throws \UnexpectedValueException */ - public static function configureData(OptionsResolver $resolver) + public static function configureData(OptionsResolver $resolver): void { $resolver ->setRequired('type')->setAllowedValues('type', [self::TYPE_EUROPEAN_DRIVER_LICENSE, self::TYPE_RESIDENCE_PERMIT, self::TYPE_PASSPORT, self::TYPE_IDENTITY_CARD]) ->setRequired('photos')->setAllowedTypes('photos', ['array'])->setNormalizer('photos', function (Options $options, $array): ?array { $list = []; foreach ($array as $value) { + if (null === $value) { + continue; + } + if ($value instanceof Base64) { $list[] = $value; continue; } - if (null === $value || !file_exists($value)) { - continue; + if (!is_string($value)) { + throw new \UnexpectedValueException( + 'Type ' . gettype($value) . ' is not allowed in photo array' + ); } - $file = file_get_contents($value); - $list[] = new \Laminas\XmlRpc\Value\Base64($file); + $list[] = new Base64($value); } return $list; @@ -90,9 +92,7 @@ public function getPhotos(): array } /** - * @param array $photos - * - * @return self + * @param Base64[] $photos */ public function setPhotos(array $photos): self { @@ -101,19 +101,11 @@ public function setPhotos(array $photos): self return $this; } - /** - * @return int - */ public function getType(): int { return $this->type; } - /** - * @param int $type - * - * @return self - */ public function setType(int $type): self { $this->type = $type; diff --git a/Model/Language.php b/Model/Language.php index bcbed26..d2c68bb 100644 --- a/Model/Language.php +++ b/Model/Language.php @@ -4,15 +4,15 @@ class Language { - const BULGARIAN = 'bg'; - const CATALAN = 'ca'; - const GERMAN = 'de'; - const ENGLISH = 'en'; - const SPANISH = 'es'; - const FRENCH = 'fr'; - const ITALIAN = 'it'; - const DUTCH = 'nl'; - const POLISH = 'pl'; - const PORTUGUESE = 'pt'; - const ROMANIAN = 'ro'; + public const BULGARIAN = 'bg'; + public const CATALAN = 'ca'; + public const GERMAN = 'de'; + public const ENGLISH = 'en'; + public const SPANISH = 'es'; + public const FRENCH = 'fr'; + public const ITALIAN = 'it'; + public const DUTCH = 'nl'; + public const POLISH = 'pl'; + public const PORTUGUESE = 'pt'; + public const ROMANIAN = 'ro'; } \ No newline at end of file diff --git a/Model/MatchingFilter.php b/Model/MatchingFilter.php index dbb9e52..a5afbee 100644 --- a/Model/MatchingFilter.php +++ b/Model/MatchingFilter.php @@ -8,7 +8,6 @@ use Symfony\Component\OptionsResolver\Exception\NoSuchOptionException; use Symfony\Component\OptionsResolver\Exception\OptionDefinitionException; use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException; -use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; class MatchingFilter diff --git a/Model/MatchingResult.php b/Model/MatchingResult.php index e004b77..98b435e 100644 --- a/Model/MatchingResult.php +++ b/Model/MatchingResult.php @@ -13,13 +13,13 @@ class MatchingResult { - const CERTIFICATE_LEVEL_NONE = 'none'; - const CERTIFICATE_LEVEL_ADVANCED = 'advanced'; - const CERTIFICATE_LEVEL_CERTIFIED = 'certified'; + public const CERTIFICATE_LEVEL_NONE = 'none'; + public const CERTIFICATE_LEVEL_ADVANCED = 'advanced'; + public const CERTIFICATE_LEVEL_CERTIFIED = 'certified'; - const CERTIFICATE_STATUS_VALID = 'valid'; - const CERTIFICATE_STATUS_REVOKED = 'revoked'; - const CERTIFICATE_STATUS_AWAITING_VALIDATION = 'awaiting-validation'; + public const CERTIFICATE_STATUS_VALID = 'valid'; + public const CERTIFICATE_STATUS_REVOKED = 'revoked'; + public const CERTIFICATE_STATUS_AWAITING_VALIDATION = 'awaiting-validation'; /** * @var string|null */ @@ -69,14 +69,14 @@ public static function configureData(OptionsResolver $resolver) ->setDefault('email', null)->setAllowedTypes('email', ['string', 'null']) ->setDefault('certificateLevel', null)->setAllowedTypes('certificateLevel', ['string', 'null']) ->setDefault('certificateStatus', null)->setAllowedTypes('certificateStatus', ['string', 'null']) - ->setDefault('expirationDate', null)->setAllowedTypes('expirationDate', ['string', 'null', \DateTime::class])->setNormalizer('expirationDate', function(Options $options, $value) { + ->setDefault('expirationDate', null)->setAllowedTypes('expirationDate', ['string', 'null', \DateTime::class])->setNormalizer('expirationDate', function (Options $options, $value) { if (!is_string($value)) { return $value; } return \DateTime::createFromFormat('Ymd\TH:i:s', $value, new \DateTimeZone('UTC')); }) - ->setDefault('certificateInfo', null)->setAllowedTypes('certificateInfo', ['array', 'null', RaCertificateInfo::class])->setNormalizer('certificateInfo', function(Options $options, $value) { + ->setDefault('certificateInfo', null)->setAllowedTypes('certificateInfo', ['array', 'null', RaCertificateInfo::class])->setNormalizer('certificateInfo', function (Options $options, $value) { if (null === $value || $value instanceof RaCertificateInfo) { return $value; } diff --git a/Model/PersonalInfo.php b/Model/PersonalInfo.php index 7c508e8..af9207b 100644 --- a/Model/PersonalInfo.php +++ b/Model/PersonalInfo.php @@ -2,56 +2,32 @@ namespace Mpp\UniversignBundle\Model; -use Laminas\XmlRpc\Value\DateTime; use Symfony\Component\OptionsResolver\Exception\AccessException; use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; use Symfony\Component\OptionsResolver\Exception\MissingOptionsException; use Symfony\Component\OptionsResolver\Exception\NoSuchOptionException; use Symfony\Component\OptionsResolver\Exception\OptionDefinitionException; use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException; -use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; class PersonalInfo { - /** - * @var string - */ - protected $firstname; + protected string $firstname; - /** - * @var string - */ - protected $lastname; + protected string $lastname; - /** - * @var DateTime - */ - protected $birthDate; + protected \DateTimeInterface $birthDate; - /** - * @param OptionsResolver $resolver - */ - public static function configureData(OptionsResolver $resolver) + public static function configureData(OptionsResolver $resolver): void { $resolver ->setRequired('firstname')->setAllowedTypes('firstname', ['string']) ->setRequired('lastname')->setAllowedTypes('lastname', ['string']) - ->setRequired('birthDate')->setAllowedTypes('birthDate', [\DateTimeInterface::class])->setNormalizer('birthDate', function(Options $options, $value) { - if (null === $value || $value instanceof DateTime) { - return $value; - } - - return new DateTime($value); - }) + ->setRequired('birthDate')->setAllowedTypes('birthDate', [\DateTimeInterface::class]) ; } /** - * @param array $options - * - * @return self - * * @throws UndefinedOptionsException If an option name is undefined * @throws InvalidOptionsException If an option doesn't fulfill the language specified validation rules * @throws MissingOptionsException If a required option is missing @@ -72,19 +48,11 @@ public static function createFromArray(array $options): self ; } - /** - * @return string - */ public function getFirstname(): string { return $this->firstname; } - /** - * @param string $firstname - * - * @return self - */ public function setFirstname(string $firstname): self { $this->firstname = $firstname; @@ -92,19 +60,11 @@ public function setFirstname(string $firstname): self return $this; } - /** - * @return string - */ public function getLastname(): string { return $this->lastname; } - /** - * @param string $lastname - * - * @return self - */ public function setLastname(string $lastname): self { $this->lastname = $lastname; @@ -112,20 +72,12 @@ public function setLastname(string $lastname): self return $this; } - /** - * @return DateTime - */ - public function getBirthDate(): DateTime + public function getBirthDate(): \DateTimeInterface { return $this->birthDate; } - /** - * @param DateTime $birthDate - * - * @return self - */ - public function setBirthDate(DateTime $birthDate): self + public function setBirthDate(\DateTimeInterface $birthDate): self { $this->birthDate = $birthDate; diff --git a/Model/RaCertificateInfo.php b/Model/RaCertificateInfo.php index 647e80b..fe2e5b8 100644 --- a/Model/RaCertificateInfo.php +++ b/Model/RaCertificateInfo.php @@ -2,7 +2,7 @@ namespace Mpp\UniversignBundle\Model; -use Laminas\XmlRpc\Value\Base64; +use Mpp\UniversignBundle\Model\XmlRpc\Base64; use Symfony\Component\OptionsResolver\Exception\AccessException; use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; use Symfony\Component\OptionsResolver\Exception\MissingOptionsException; @@ -14,35 +14,31 @@ class RaCertificateInfo { - /** - * @var string - */ - protected $subjectDN; + protected string $subjectDN; - /** - * @var string - */ - protected $serialNumber; + protected string $serialNumber; /** * @var Base64[] */ - protected $chain; + protected array $chain; /** - * @param OptionsResolver $resolver + * @throws \UnexpectedValueException */ - public static function configureData(OptionsResolver $resolver) + public static function configureData(OptionsResolver $resolver): void { $resolver ->setRequired('subjectDN')->setAllowedTypes('subjectDN', ['string']) ->setRequired('serialNumber')->setAllowedTypes('serialNumber', ['string']) - ->setRequired('chain')->setAllowedTypes('chain', ['array', Base64::class])->setNormalizer('chain', function (Options $options, $value): array { - if (null === $value) { - return $value; - } + ->setRequired('chain')->setAllowedTypes('chain', ['array'])->setNormalizer('chain', function (Options $options, $value): array { $result = []; foreach ($value as $item) { + if (!is_string($item)) { + throw new \UnexpectedValueException( + 'Type ' . gettype($item) . ' is not allowed in chain array' + ); + } $result[] = new Base64($item); } @@ -52,10 +48,6 @@ public static function configureData(OptionsResolver $resolver) } /** - * @param array $options - * - * @return self - * * @throws UndefinedOptionsException If an option name is undefined * @throws InvalidOptionsException If an option doesn't fulfill the language specified validation rules * @throws MissingOptionsException If a required option is missing @@ -77,19 +69,11 @@ public static function createFromArray(array $options): self ; } - /** - * @return string - */ public function getSubjectDN(): string { return $this->subjectDN; } - /** - * @param string $subjectDN - * - * @return self - */ public function setSubjectDN(string $subjectDN): self { $this->subjectDN = $subjectDN; @@ -97,19 +81,11 @@ public function setSubjectDN(string $subjectDN): self return $this; } - /** - * @return string - */ public function getSerialNumber(): string { return $this->serialNumber; } - /** - * @param string $serialNumber - * - * @return self - */ public function setSerialNumber(string $serialNumber): self { $this->serialNumber = $serialNumber; @@ -127,8 +103,6 @@ public function getChain(): array /** * @param Base64[] $chain - * - * @return self */ public function setChain(array $chain): self { diff --git a/Model/SignOptions.php b/Model/SignOptions.php index b002a0c..d442b97 100644 --- a/Model/SignOptions.php +++ b/Model/SignOptions.php @@ -13,9 +13,9 @@ class SignOptions { - const SINGNATURE_FORMAT_PADES = 'PADES'; - const SINGNATURE_FORMAT_PADES_COMP = 'PADES-COMP'; - const SINGNATURE_FORMAT_ISO32000_1 = 'ISO-32000-1'; + public const SINGNATURE_FORMAT_PADES = 'PADES'; + public const SINGNATURE_FORMAT_PADES_COMP = 'PADES-COMP'; + public const SINGNATURE_FORMAT_ISO32000_1 = 'ISO-32000-1'; /** * @var string|null @@ -59,7 +59,7 @@ public static function configureData(OptionsResolver $resolver) { $resolver ->setDefault('profile', 'default')->setAllowedTypes('profile', ['string']) - ->setDefault('signatureField', null)->setAllowedTypes('signatureField', ['null', 'array', SignatureField::class])->setNormalizer('signatureField', function(Options $options, $value) { + ->setDefault('signatureField', null)->setAllowedTypes('signatureField', ['null', 'array', SignatureField::class])->setNormalizer('signatureField', function (Options $options, $value) { if (null === $value || $value instanceof SignatureField) { return $value; } diff --git a/Model/SignatureField.php b/Model/SignatureField.php index cb31afa..5d7a73f 100644 --- a/Model/SignatureField.php +++ b/Model/SignatureField.php @@ -8,7 +8,6 @@ use Symfony\Component\OptionsResolver\Exception\NoSuchOptionException; use Symfony\Component\OptionsResolver\Exception\OptionDefinitionException; use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException; -use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; class SignatureField diff --git a/Model/Signer.php b/Model/Signer.php index 0f8ac65..dd38efe 100644 --- a/Model/Signer.php +++ b/Model/Signer.php @@ -16,118 +16,47 @@ class Signer public const ROLE_SIGNER = 'signer'; public const ROLE_OBSERVER = 'observer'; - /** - * @var string - */ - protected $firstname; + protected ?string $firstname; - /** - * @var string - */ - protected $lastname; + protected ?string $lastname; - /** - * @var string - */ - protected $organization; + protected ?string $organization; - /** - * @var string - */ - protected $profile; + protected ?string $profile; - /** - * @var string - */ - protected $emailAddress; + protected ?string $emailAddress; - /** - * @var string - */ - protected $phoneNum; + protected ?string $phoneNum; - /** - * @var string - */ - protected $language; + protected string $language; - /** - * @var string - */ - protected $role; + protected string $role; - /** - * @var \Laminas\XmlRpc\Value\DateTime - */ - protected $birthDate; + protected ?\DateTimeInterface $birthDate; - /** - * @var string - */ - protected $universignId; + protected ?string $universignId; - /** - * @var array - */ - protected $successRedirection; + protected array $successRedirection; - /** - * @var array - */ - protected $cancelRedirection; + protected array $cancelRedirection; - /** - * @var array - */ - protected $failRedirection; + protected array $failRedirection; - /** - * @var string - */ - protected $certificateType; + protected ?string $certificateType; - /** - * @var RegistrationRequest - */ - protected $idDocuments; + protected ?RegistrationRequest $idDocuments; - /** - * @var string - */ - protected $validationSessionId; + protected ?string $validationSessionId; - /** - * @var string - */ - protected $redirectPolicy; + protected ?string $redirectPolicy; - /** - * @var int - */ - protected $redirectWait; + protected int $redirectWait; - /** - * @var bool - */ - protected $autoSendAgreements; + protected ?bool $autoSendAgreements; - /** - * @var string - */ - protected $invitationMessage; + protected ?string $invitationMessage; - public function __construct() - { - $this->successRedirection = []; - $this->cancelRedirection = []; - $this->failRedirection = []; - $this->idDocuments = []; - } - - /** - * @param OptionsResolver $resolver - */ - public static function configureData(OptionsResolver $resolver) + public static function configureData(OptionsResolver $resolver): void { $resolver ->setDefault('firstname', null)->setAllowedTypes('firstname', ['null', 'string']) @@ -138,17 +67,11 @@ public static function configureData(OptionsResolver $resolver) ->setDefault('profile', null)->setAllowedTypes('profile', ['null', 'string']) ->setDefault('language', 'en')->setAllowedValues('language', [Language::BULGARIAN, Language::CATALAN, Language::GERMAN, Language::ENGLISH, Language::SPANISH, Language::FRENCH, Language::ITALIAN, Language::DUTCH, Language::POLISH, Language::PORTUGUESE, Language::ROMANIAN]) ->setDefault('role', self::ROLE_SIGNER)->setAllowedValues('role', [self::ROLE_SIGNER, self::ROLE_OBSERVER]) - ->setDefault('birthDate', null)->setAllowedTypes('birthDate', ['DateTime', 'null'])->setNormalizer('birthDate', function (Options $options, $value): ?\Laminas\XmlRpc\Value\DateTime { - if (null === $value) { - return null; - } - - return new \Laminas\XmlRpc\Value\DateTime($value); - }) + ->setDefault('birthDate', null)->setAllowedTypes('birthDate', [\DateTimeInterface::class, 'null']) ->setDefault('universignId', null)->setAllowedTypes('universignId', ['null', 'string']) - ->setDefault('successRedirection', null)->setAllowedTypes('successRedirection', ['array', 'null']) - ->setDefault('cancelRedirection', null)->setAllowedTypes('cancelRedirection', ['array', 'null']) - ->setDefault('failRedirection', null)->setAllowedTypes('failRedirection', ['array', 'null']) + ->setDefault('successRedirection', [])->setAllowedTypes('successRedirection', ['array']) + ->setDefault('cancelRedirection', [])->setAllowedTypes('cancelRedirection', ['array']) + ->setDefault('failRedirection', [])->setAllowedTypes('failRedirection', ['array']) ->setDefault('certificateType', null)->setAllowedValues('certificateType', [null, CertificateType::SIMPLE, CertificateType::CERTIFIED, CertificateType::ADVANCED]) ->setDefault('idDocuments', null)->setAllowedTypes('idDocuments', ['array', RegistrationRequest::class, 'null'])->setNormalizer('idDocuments', function (Options $options, $value) { if ($value instanceof RegistrationRequest || null === $value) { @@ -158,7 +81,7 @@ public static function configureData(OptionsResolver $resolver) return RegistrationRequest::createFromArray($value); }) ->setDefault('validationSessionId', null)->setAllowedTypes('validationSessionId', ['null', 'string']) - ->setDefault('redirectPolicy', null)->setAllowedValues('redirectPolicy', [null, 'dashboard', 'quick']) + ->setDefault('redirectPolicy', null)->setAllowedValues('redirectPolicy', ['null', 'dashboard', 'quick']) ->setDefault('redirectWait', 5)->setAllowedTypes('redirectWait', ['int'])->setNormalizer('redirectWait', function (Options $options, $value) { if ('quick' === $options['redirectPolicy']) { return null; @@ -213,11 +136,6 @@ public static function createFromArray(array $options): self ; } - /** - * @param string|null $firstname - * - * @return self - */ public function setFirstname(?string $firstname): self { $this->firstname = $firstname; @@ -225,19 +143,11 @@ public function setFirstname(?string $firstname): self return $this; } - /** - * @return string|null - */ public function getFirstname(): ?string { return $this->firstname; } - /** - * @param string|null $lastname - * - * @return self - */ public function setLastname(?string $lastname): self { $this->lastname = $lastname; @@ -245,19 +155,11 @@ public function setLastname(?string $lastname): self return $this; } - /** - * @return string|null - */ public function getLastname(): ?string { return $this->lastname; } - /** - * @param string|null $organization - * - * @return self - */ public function setOrganization(?string $organization): self { $this->organization = $organization; @@ -265,19 +167,11 @@ public function setOrganization(?string $organization): self return $this; } - /** - * @return string|null - */ public function getOrganization(): ?string { return $this->organization; } - /** - * @param string|null $profile - * - * @return self - */ public function setProfile(?string $profile): self { $this->profile = $profile; @@ -285,19 +179,11 @@ public function setProfile(?string $profile): self return $this; } - /** - * @return string|null - */ public function getProfile(): ?string { return $this->profile; } - /** - * @param string|null $emailAddress - * - * @return self - */ public function setEmailAddress(?string $emailAddress): self { $this->emailAddress = $emailAddress; @@ -305,19 +191,11 @@ public function setEmailAddress(?string $emailAddress): self return $this; } - /** - * @return string|null - */ public function getEmailAddress(): ?string { return $this->emailAddress; } - /** - * @param string|null $phoneNum - * - * @return self - */ public function setPhoneNum(?string $phoneNum): self { $this->phoneNum = $phoneNum; @@ -325,79 +203,47 @@ public function setPhoneNum(?string $phoneNum): self return $this; } - /** - * @return string|null - */ public function getPhoneNum(): ?string { return $this->phoneNum; } - /** - * @param string|null $language - * - * @return self - */ - public function setLanguage(?string $language): self + public function setLanguage(string $language): self { $this->language = $language; return $this; } - /** - * @return string|null - */ - public function getLanguage(): ?string + public function getLanguage(): string { return $this->language; } - /** - * @param string|null $role - * - * @return self - */ - public function setRole(?string $role): self + public function setRole(string $role): self { $this->role = $role; return $this; } - /** - * @return string|null - */ - public function getRole(): ?string + public function getRole(): string { return $this->role; } - /** - * @param \Laminas\XmlRpc\Value\DateTime|null $birthDate - * - * @return self - */ - public function setBirthDate(?\Laminas\XmlRpc\Value\DateTime $birthDate): self + public function setBirthDate(?\DateTimeInterface $birthDate): self { $this->birthDate = $birthDate; return $this; } - /** - * @return \Laminas\XmlRpc\Value\DateTime|null - */ - public function getBirthDate(): ?\Laminas\XmlRpc\Value\DateTime + public function getBirthDate(): ?\DateTimeInterface { return $this->birthDate; } - /** - * @param string|null $universignId - * - * @return self - */ public function setUniversignId(?string $universignId): self { $this->universignId = $universignId; @@ -405,79 +251,47 @@ public function setUniversignId(?string $universignId): self return $this; } - /** - * @return string|null - */ public function getUniversignId(): ?string { return $this->universignId; } - /** - * @param array|null $successRedirection - * - * @return self - */ - public function setSuccessRedirection(?array $successRedirection): self + public function setSuccessRedirection(array $successRedirection): self { $this->successRedirection = $successRedirection; return $this; } - /** - * @return array|null - */ - public function getSuccessRedirection(): ?array + public function getSuccessRedirection(): array { return $this->successRedirection; } - /** - * @param array|null $failRedirection - * - * @return self - */ - public function setFailRedirection(?array $failRedirection): self + public function setFailRedirection(array $failRedirection): self { $this->failRedirection = $failRedirection; return $this; } - /** - * @return array|null - */ - public function getFailRedirection(): ?array + public function getFailRedirection(): array { return $this->failRedirection; } - /** - * @param array|null $cancelRedirection - * - * @return self - */ - public function setCancelRedirection(?array $cancelRedirection): self + public function setCancelRedirection(array $cancelRedirection): self { $this->cancelRedirection = $cancelRedirection; return $this; } - /** - * @return array|null - */ - public function getCancelRedirection(): ?array + public function getCancelRedirection(): array { return $this->cancelRedirection; } - /** - * @param string|null $certificateType - * - * @return self - */ public function setCertificateType(?string $certificateType): self { $this->certificateType = $certificateType; @@ -485,19 +299,11 @@ public function setCertificateType(?string $certificateType): self return $this; } - /** - * @return string|null - */ public function getCertificateType(): ?string { return $this->certificateType; } - /** - * @param array|null $idDocument - * - * @return self - */ public function setIdDocuments(?RegistrationRequest $idDocuments): self { $this->idDocuments = $idDocuments; @@ -505,19 +311,11 @@ public function setIdDocuments(?RegistrationRequest $idDocuments): self return $this; } - /** - * @return array|null - */ public function getIdDocuments(): ?RegistrationRequest { return $this->idDocuments; } - /** - * @param string|null $validationSessionId - * - * @return self - */ public function setValidationSessionId(?string $validationSessionId): self { $this->validationSessionId = $validationSessionId; @@ -525,19 +323,11 @@ public function setValidationSessionId(?string $validationSessionId): self return $this; } - /** - * @return string|null - */ public function getValidationSessionId(): ?string { return $this->validationSessionId; } - /** - * @param string|null $redirectPolicy - * - * @return self - */ public function setRedirectPolicy(?string $redirectPolicy): self { $this->redirectPolicy = $redirectPolicy; @@ -545,39 +335,23 @@ public function setRedirectPolicy(?string $redirectPolicy): self return $this; } - /** - * @return string|null - */ public function getRedirectPolicy(): ?string { return $this->redirectPolicy; } - /** - * @param int|null $redirectWait - * - * @return self - */ - public function setRedirectWait(?int $redirectWait): self + public function setRedirectWait(int $redirectWait): self { $this->redirectWait = $redirectWait; return $this; } - /** - * @return int|null - */ - public function getRedirectWait(): ?int + public function getRedirectWait(): int { return $this->redirectWait; } - /** - * @param bool|null $autoSendAgreements - * - * @return self - */ public function setAutoSendAgreements(?bool $autoSendAgreements): self { $this->autoSendAgreements = $autoSendAgreements; @@ -585,19 +359,11 @@ public function setAutoSendAgreements(?bool $autoSendAgreements): self return $this; } - /** - * @return bool|null - */ public function getAutoSendAgreements(): ?bool { return $this->autoSendAgreements; } - /** - * @param string|null $invitationMessage - * - * @return self - */ public function setInvitationMessage(?string $invitationMessage): self { $this->invitationMessage = $invitationMessage; @@ -605,9 +371,6 @@ public function setInvitationMessage(?string $invitationMessage): self return $this; } - /** - * @return string|null - */ public function getInvitationMessage(): ?string { return $this->invitationMessage; diff --git a/Model/TransactionFilter.php b/Model/TransactionFilter.php index b254232..87db6f4 100644 --- a/Model/TransactionFilter.php +++ b/Model/TransactionFilter.php @@ -8,130 +8,49 @@ use Symfony\Component\OptionsResolver\Exception\NoSuchOptionException; use Symfony\Component\OptionsResolver\Exception\OptionDefinitionException; use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException; -use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; class TransactionFilter { - /** - * @var string - */ - protected $requesterEmail; + protected ?string $requesterEmail; - /** - * @var string - */ - protected $profile; + protected ?string $profile; - /** - * @var \Laminas\XmlRpc\Value\DateTime - */ - protected $notBefore; + protected ?\DateTimeInterface $notBefore; - /** - * @var \Laminas\XmlRpc\Value\DateTime - */ - protected $notAfter; + protected ?\DateTimeInterface $notAfter; - /** - * @var int - */ - protected $startRange; + protected ?int $startRange; - /** - * @var int - */ - protected $stopRange; + protected ?int $stopRange; - /** - * @var string - */ - protected $signerId; + protected ?string $signerId; - /** - * @var \Laminas\XmlRpc\Value\DateTime - */ - protected $notBeforeCompletion; + protected ?\DateTimeInterface $notBeforeCompletion; - /** - * @var \Laminas\XmlRpc\Value\DateTime - */ - protected $notAfterCompletion; + protected ?\DateTimeInterface $notAfterCompletion; - /** - * @var int - */ - protected $status; + protected ?int $status; - /** - * @var bool - */ - protected $withAffiliated; + protected ?bool $withAffiliated; - /** - * @return TransactionFilter - */ - public function initiateTransactionFilter(): TransactionFilter - { - return new self(); - } - - /** - * @param OptionsResolver $resolver - */ - public static function configureData(OptionsResolver $resolver) + public static function configureData(OptionsResolver $resolver): void { $resolver ->setDefault('requesterEmail', null)->setAllowedTypes('requesterEmail', ['string', 'null']) ->setDefault('profile', null)->setAllowedTypes('profile', ['string', 'null']) - ->setDefault('notBefore', null)->setAllowedTypes('notBefore', ['DateTime', 'null'])->setNormalizer('notBefore', function (Options $option, $value) { - if (null === $value) { - return null; - } - $value = $value->format('Ymd\TH:i:s'); - $date = new \Laminas\XmlRpc\Value\DateTime($value); - - return $date; - }) - ->setDefault('notAfter', null)->setAllowedTypes('notAfter', ['DateTime', 'null'])->setNormalizer('notAfter', function (Options $options, $value) { - if (null === $value) { - return null; - } - $value = $value->format('Ymd\TH:i:s'); - $date = new \Laminas\XmlRpc\Value\DateTime($value); - - return $date; - }) + ->setDefault('notBefore', null)->setAllowedTypes('notBefore', [\DateTimeInterface::class, 'null']) + ->setDefault('notAfter', null)->setAllowedTypes('notAfter', [\DateTimeInterface::class, 'null']) ->setDefault('startRange', null)->setAllowedTypes('startRange', ['int', 'null']) ->setDefault('stopRange', null)->setAllowedTypes('stopRange', ['int', 'null']) ->setDefault('signerId', null)->setAllowedTypes('signerId', ['string', 'null']) - ->setDefault('notBeforeCompletion', null)->setAllowedTypes('notBeforeCompletion', ['DateTime', 'null'])->setNormalizer('notBeforeCompletion', function (Options $options, $value) { - if (null === $value) { - return null; - } - $value = $value->format('Ymd\TH:i:s'); - $date = new \Laminas\XmlRpc\Value\DateTime($value); - - return $date; - }) - ->setDefault('notAfterCompletion', null)->setAllowedTypes('notAfterCompletion', ['DateTime', 'null'])->setNormalizer('notAfterCompletion', function (Options $options, $value) { - if (null === $value) { - return null; - } - $value = $value->format('Ymd\TH:i:s'); - $date = new \Laminas\XmlRpc\Value\DateTime($value); - - return $date; - }) + ->setDefault('notBeforeCompletion', null)->setAllowedTypes('notBeforeCompletion', [\DateTimeInterface::class, 'null']) + ->setDefault('notAfterCompletion', null)->setAllowedTypes('notAfterCompletion', [\DateTimeInterface::class, 'null']) ->setDefault('status', null)->setAllowedTypes('status', ['int', 'null']) ->setDefault('withAffiliated', null)->setAllowedTypes('withAffiliated', ['bool', 'null']); } /** - * @param array $options - * - * @return self - * * @throws UndefinedOptionsException If an option name is undefined * @throws InvalidOptionsException If an option doesn't fulfill the language specified validation rules * @throws MissingOptionsException If a required option is missing @@ -160,11 +79,6 @@ public static function createFromArray(array $options): self ; } - /** - * @param string|null $requesterEmail - * - * @return self - */ public function setRequesterEmail(?string $requesterEmail): self { $this->requesterEmail = $requesterEmail; @@ -172,19 +86,11 @@ public function setRequesterEmail(?string $requesterEmail): self return $this; } - /** - * @return string|null - */ public function getRequesterEmail(): ?string { return $this->requesterEmail; } - /** - * @param string|null - * - * @return self - */ public function setProfile(?string $profile): self { $this->profile = $profile; @@ -192,59 +98,35 @@ public function setProfile(?string $profile): self return $this; } - /** - * @return string|null - */ public function getProfile(): ?string { return $this->profile; } - /** - * @param \Laminas\XmlRpc\Value\DateTime|null $notBefore - * - * @return self - */ - public function setNotBefore(?\Laminas\XmlRpc\Value\DateTime $notBefore): self + public function setNotBefore(?\DateTimeInterface $notBefore): self { $this->notBefore = $notBefore; return $this; } - /** - * @return \Laminas\XmlRpc\Value\DateTime|null - */ - public function getNotBefore(): ?\Laminas\XmlRpc\Value\DateTime + public function getNotBefore(): ?\DateTimeInterface { return $this->notBefore; } - /** - * @param \Laminas\XmlRpc\Value\DateTime|null $notAfter - * - * @return self - */ - public function setNotAfter(?\Laminas\XmlRpc\Value\DateTime $notAfter): self + public function setNotAfter(?\DateTimeInterface $notAfter): self { $this->notAfter = $notAfter; return $this; } - /** - * @return \Laminas\XmlRpc\Value\DateTime|null - */ - public function getNotAfter(): ?\Laminas\XmlRpc\Value\DateTime + public function getNotAfter(): ?\DateTimeInterface { return $this->notAfter; } - /** - * @param int|null $startRange - * - * @return self - */ public function setStartRange(?int $startRange): self { $this->startRange = $startRange; @@ -252,19 +134,11 @@ public function setStartRange(?int $startRange): self return $this; } - /** - * @return int|null - */ public function getStartRange(): ?int { return $this->startRange; } - /** - * @param int|null $stopRange - * - * @return self - */ public function setStopRange(?int $stopRange): self { $this->stopRange = $stopRange; @@ -272,19 +146,11 @@ public function setStopRange(?int $stopRange): self return $this; } - /** - * @return int|null - */ public function getStopRange(): ?int { return $this->stopRange; } - /** - * @param string|null - * - * @return self - */ public function setSignerId(?string $signerId): self { $this->signerId = $signerId; @@ -292,59 +158,35 @@ public function setSignerId(?string $signerId): self return $this; } - /** - * @return string|null - */ public function getSignerId(): ?string { return $this->signerId; } - /** - * @param \Laminas\XmlRpc\Value\DateTime|null $notBeforeCompletion - * - * @return self - */ - public function setNotBeforeCompletion(?\Laminas\XmlRpc\Value\DateTime $notBeforeCompletion): self + public function setNotBeforeCompletion(?\DateTimeInterface $notBeforeCompletion): self { $this->notBeforeCompletion = $notBeforeCompletion; return $this; } - /** - * @return \Laminas\XmlRpc\Value\DateTime|null - */ - public function getNotBeforeCompletion(): ?\Laminas\XmlRpc\Value\DateTime + public function getNotBeforeCompletion(): ?\DateTimeInterface { return $this->notBeforeCompletion; } - /** - * @param \Laminas\XmlRpc\Value\DateTime|null $notAfterCompletion - * - * @return self - */ - public function setNotAfterCompletion(?\Laminas\XmlRpc\Value\DateTime $notAfterCompletion): self + public function setNotAfterCompletion(?\DateTimeInterface $notAfterCompletion): self { $this->notAfterCompletion = $notAfterCompletion; return $this; } - /** - * @return \Laminas\XmlRpc\Value\DateTime|null - */ - public function getNotAfterCompletion(): ?\Laminas\XmlRpc\Value\DateTime + public function getNotAfterCompletion(): ?\DateTimeInterface { return $this->notAfterCompletion; } - /** - * @param int|null $status - * - * @return self - */ public function setStatus(?int $status): self { $this->status = $status; @@ -352,19 +194,11 @@ public function setStatus(?int $status): self return $this; } - /** - * @return int|null - */ public function getStatus(): ?int { return $this->status; } - /** - * @param bool|null $withAffiliated - * - * @return self - */ public function setWithAffiliated(?bool $withAffiliated): self { $this->withAffiliated = $withAffiliated; @@ -372,9 +206,6 @@ public function setWithAffiliated(?bool $withAffiliated): self return $this; } - /** - * @return bool|null - */ public function getWithAffiliated(): ?bool { return $this->withAffiliated; diff --git a/Model/TransactionRequest.php b/Model/TransactionRequest.php index c9f5bef..f0762fe 100644 --- a/Model/TransactionRequest.php +++ b/Model/TransactionRequest.php @@ -718,7 +718,7 @@ public function setCancelRedirection(?RedirectionConfig $cancelRedirection): sel /** * @return RedirectionConfig|null */ - public function getCancelRedirection(): ? RedirectionConfig + public function getCancelRedirection(): ?RedirectionConfig { return $this->cancelRedirection; } diff --git a/Model/TransactionResponse.php b/Model/TransactionResponse.php index b86fb15..7d5a82c 100644 --- a/Model/TransactionResponse.php +++ b/Model/TransactionResponse.php @@ -4,8 +4,8 @@ class TransactionResponse { - const STATE_SUCCESS = 'SUCCESS'; - const STATE_ERROR = 'ERROR'; + public const STATE_SUCCESS = 'SUCCESS'; + public const STATE_ERROR = 'ERROR'; /** * @var string diff --git a/Model/ValidatorResult.php b/Model/ValidatorResult.php index 3da8230..9e0e3c8 100644 --- a/Model/ValidatorResult.php +++ b/Model/ValidatorResult.php @@ -13,9 +13,9 @@ class ValidatorResult { - const STATUS_PENDING = 0; - const STATUS_VALID = 1; - const STATUS_INVALID = 2; + public const STATUS_PENDING = 0; + public const STATUS_VALID = 1; + public const STATUS_INVALID = 2; /** * @var string diff --git a/Model/XmlRpc/Base64.php b/Model/XmlRpc/Base64.php new file mode 100644 index 0000000..f5709be --- /dev/null +++ b/Model/XmlRpc/Base64.php @@ -0,0 +1,16 @@ +logger = $logger; $this->router = $router; $this->entrypoint = $entrypoint; - parent::__construct($clientOptions); + parent::__construct($encoder, $clientOptions); } /** @@ -49,10 +55,15 @@ private function call(string $method, $args) $response = null; try { - $response = $this->xmlRpcClient->call($method, self::flatten($args)); + $response = $this->send($method, $args); $this->logger->info(sprintf('[Universign - %s] SUCCESS', $method)); - } catch (FaultException $fe) { - $this->logger->error(sprintf('[Universign - %s] ERROR (%s): %s', $method, $fe->getCode(), $fe->getMessage())); + } catch (Exception $e) { + $this->logger->error(sprintf( + '[Universign - %s] ERROR (%s): %s', + $method, + $e->getCode(), + $e->getMessage() + )); } return $response; @@ -103,7 +114,10 @@ public function validate(ValidationRequest $validationRequest): ?ValidatorResult ) ); - $this->logger->info(sprintf('[Universign - validate] define default callback URL : "%s"', $validationRequest->getCallbackURL())); + $this->logger->info(sprintf( + '[Universign - validate] define default callback URL : "%s"', + $validationRequest->getCallbackURL() + )); } $result = $this->call('validator.validate', [$validationRequest]); diff --git a/Requester/RegistrationAuthorityInterface.php b/Requester/RegistrationAuthorityInterface.php index 2bd66c0..8c4d595 100644 --- a/Requester/RegistrationAuthorityInterface.php +++ b/Requester/RegistrationAuthorityInterface.php @@ -9,10 +9,10 @@ interface RegistrationAuthorityInterface { - const OPERATOR_STATUS_NOT_OPERATOR = 0; - const OPERATOR_STATUS_RA_OPERATOR = 1; - const OPERATOR_STATUS_INVITED_RA_OPERATOR = 2; - const OPERATOR_STATUS_NOT_EXISTENT = 5; + public const OPERATOR_STATUS_NOT_OPERATOR = 0; + public const OPERATOR_STATUS_RA_OPERATOR = 1; + public const OPERATOR_STATUS_INVITED_RA_OPERATOR = 2; + public const OPERATOR_STATUS_NOT_EXISTENT = 5; /** * @param string $email Email of User diff --git a/Requester/Signer.php b/Requester/Signer.php index 7c76f21..7b4497d 100644 --- a/Requester/Signer.php +++ b/Requester/Signer.php @@ -2,10 +2,6 @@ namespace Mpp\UniversignBundle\Requester; -use Laminas\XmlRpc\Client; -use Laminas\XmlRpc\Client\Exception\FaultException; -use Laminas\XmlRpc\Value\Base64; -use Laminas\XmlRpc\Value\DateTime; use Mpp\UniversignBundle\Model\InitiatorInfo; use Mpp\UniversignBundle\Model\RedirectionConfig; use Mpp\UniversignBundle\Model\SignerInfo; @@ -13,6 +9,9 @@ use Mpp\UniversignBundle\Model\TransactionInfo; use Mpp\UniversignBundle\Model\TransactionRequest; use Mpp\UniversignBundle\Model\TransactionResponse; +use Mpp\UniversignBundle\Model\XmlRpc\Base64; +use PhpXmlRpc\Encoder; +use PhpXmlRpc\Exception; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Routing\Router; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; @@ -39,14 +38,20 @@ class Signer extends XmlRpcRequester implements SignerInterface */ protected $options; - public function __construct(LoggerInterface $logger, Router $router, array $entrypoint, array $options, array $clientOptions) - { + public function __construct( + Encoder $encoder, + LoggerInterface $logger, + Router $router, + array $entrypoint, + array $options, + array $clientOptions + ) { $this->logger = $logger; $this->router = $router; $this->entrypoint = $entrypoint; $this->options = $options; - parent::__construct($clientOptions); + parent::__construct($encoder, $clientOptions); } /** @@ -127,25 +132,27 @@ public function requestTransaction(TransactionRequest $transactionRequest): Tran { $transactionResponse = new TransactionResponse(); - $flattenedTransactionRequest = self::flatten($transactionRequest); + $flattenedTransactionRequest = $this->flatten($transactionRequest); $flattenedTransactionRequest['documents'] = array_values($flattenedTransactionRequest['documents']); try { - $response = $this->xmlRpcClient->call('requester.requestTransaction', [$flattenedTransactionRequest]); + $response = $this->send('requester.requestTransaction', $this->flatten([$flattenedTransactionRequest])); $this->logger->info('[Universign - requester.requestTransaction] SUCCESS'); $transactionResponse ->setId($response['id']) ->setUrl($response['url']) ->setState(TransactionResponse::STATE_SUCCESS) ; - } catch (FaultException $fe) { + } catch (Exception $e) { $transactionResponse ->setState(TransactionResponse::STATE_ERROR) - ->setErrorCode($fe->getCode()) - ->setErrorMessage($fe->getMessage()) + ->setErrorCode($e->getCode()) + ->setErrorMessage($e->getMessage()) ; - $this->logger->error(sprintf('[Universign - requester.requestTransaction] ERROR (%s): %s', $fe->getCode(), $fe->getMessage())); + $this->logger->error( + sprintf('[Universign - requester.requestTransaction] ERROR (%s): %s', $e->getCode(), $e->getMessage()) + ); } return $transactionResponse; @@ -159,10 +166,12 @@ public function getDocuments(string $documentId): array $documents = []; try { - $documents = $this->xmlRpcClient->call('requester.getDocuments', $documentId); + $documents = $this->send('requester.getDocuments', $documentId); $this->logger->info('[Universign - requester.getDocuments] SUCCESS'); - } catch (FaultException $fe) { - $this->logger->error(sprintf('[Universign - requester.getDocuments] ERROR (%s): %s', $fe->getCode(), $fe->getMessage())); + } catch (Exception $e) { + $this->logger->error( + sprintf('[Universign - requester.getDocuments] ERROR (%s): %s', $e->getCode(), $e->getMessage()) + ); } return $documents; @@ -176,10 +185,14 @@ public function getDocumentsByCustomId(string $customId): array $documents = []; try { - $documents = $this->xmlRpcClient->call('requester.getDocumentsByCustomId', $customId); + $documents = $this->send('requester.getDocumentsByCustomId', $customId); $this->logger->info('[Universign - requester.getDocumentsByCustomId] SUCCESS'); - } catch (FaultException $fe) { - $this->logger->error(sprintf('[Universign - requester.getDocumentsByCustomId] ERROR (%s): %s', $fe->getCode(), $fe->getMessage())); + } catch (Exception $e) { + $this->logger->error(sprintf( + '[Universign - requester.getDocumentsByCustomId] ERROR (%s): %s', + $e->getCode(), + $e->getMessage() + )); } return $documents; @@ -193,7 +206,7 @@ public function getTransactionInfo(string $transactionId): TransactionInfo $transactionInfo = new TransactionInfo(); try { - $response = $this->xmlRpcClient->call('requester.getTransactionInfo', $transactionId); + $response = $this->send('requester.getTransactionInfo', $transactionId); $this->logger->info('[Universign - requester.getTransactionInfo] SUCCESS'); $transactionInfo ->setState(TransactionInfo::STATE_SUCCESS) @@ -211,13 +224,15 @@ public function getTransactionInfo(string $transactionId): TransactionInfo foreach ($response['signerInfos'] as $signerInfo) { $transactionInfo->addSignerInfo(SignerInfo::createFromArray($signerInfo)); } - } catch (FaultException $fe) { - $this->logger->error(sprintf('[Universign - requester.getTransactionInfo] ERROR (%s): %s', $fe->getCode(), $fe->getMessage())); + } catch (Exception $e) { + $this->logger->error( + sprintf('[Universign - requester.getTransactionInfo] ERROR (%s): %s', $e->getCode(), $e->getMessage()) + ); $transactionInfo ->setState(TransactionInfo::STATE_ERROR) - ->setErrorCode($fe->getCode()) - ->setErrorMessage($fe->getMessage()) + ->setErrorCode($e->getCode()) + ->setErrorMessage($e->getMessage()) ; } @@ -232,7 +247,7 @@ public function getTransactionInfoByCustomId(string $customId): TransactionInfo $transactionInfo = new TransactionInfo(); try { - $response = $this->xmlRpcClient->call('requester.getTransactionInfoByCustomId', $customId); + $response = $this->send('requester.getTransactionInfoByCustomId', $customId); $this->logger->info('[Universign - requester.getTransactionInfoByCustomId] SUCCESS'); $transactionInfo ->setState(TransactionInfo::STATE_SUCCESS) @@ -247,13 +262,17 @@ public function getTransactionInfoByCustomId(string $customId): TransactionInfo ->setRedirectPolicy($response['redirectPolicy'] ?? null) ->setRedirectWait($response['redirectWait'] ?? null) ; - } catch (FaultException $fe) { - $this->logger->error(sprintf('[Universign - requester.getTransactionInfoByCustomId] ERROR (%s): %s', $fe->getCode(), $fe->getMessage())); + } catch (Exception $e) { + $this->logger->error(sprintf( + '[Universign - requester.getTransactionInfoByCustomId] ERROR (%s): %s', + $e->getCode(), + $e->getMessage() + )); $transactionInfo ->setState(TransactionInfo::STATE_ERROR) - ->setErrorCode($fe->getCode()) - ->setErrorMessage($fe->getMessage()) + ->setErrorCode($e->getCode()) + ->setErrorMessage($e->getMessage()) ; } @@ -268,16 +287,20 @@ public function relaunchTransaction(string $transactionId): TransactionInfo $transactionInfo = new TransactionInfo(); try { - $response = $this->xmlRpcClient->call('requester.relaunchTransaction', $transactionId); + $response = $this->send('requester.relaunchTransaction', $transactionId); $this->logger->info('[Universign - requester.relaunchTransaction] SUCCESS'); $transactionInfo->setState(TransactionInfo::STATE_SUCCESS); - } catch (FaultException $fe) { - $this->logger->error(sprintf('[Universign - requester.relaunchTransaction] ERROR (%s): %s', $fe->getCode(), $fe->getMessage())); + } catch (Exception $e) { + $this->logger->error(sprintf( + '[Universign - requester.relaunchTransaction] ERROR (%s): %s', + $e->getCode(), + $e->getMessage() + )); $transactionInfo ->setState(TransactionInfo::STATE_ERROR) - ->setErrorCode($fe->getCode()) - ->setErrorMessage($fe->getMessage()) + ->setErrorCode($e->getCode()) + ->setErrorMessage($e->getMessage()) ; } @@ -292,16 +315,18 @@ public function cancelTransaction(string $transactionId): TransactionInfo $transactionInfo = new TransactionInfo(); try { - $response = $this->xmlRpcClient->call('requester.cancelTransaction', $transactionId); + $response = $this->send('requester.cancelTransaction', $transactionId); $this->logger->info('[Universign - requester.cancelTransaction] SUCCESS'); $transactionInfo->setState(TransactionInfo::STATE_SUCCESS); - } catch (FaultException $fe) { - $this->logger->error(sprintf('[Universign - requester.cancelTransaction] ERROR (%s): %s', $fe->getCode(), $fe->getMessage())); + } catch (Exception $e) { + $this->logger->error( + sprintf('[Universign - requester.cancelTransaction] ERROR (%s): %s', $e->getCode(), $e->getMessage()) + ); $transactionInfo ->setState(TransactionInfo::STATE_ERROR) - ->setErrorCode($fe->getCode()) - ->setErrorMessage($fe->getMessage()) + ->setErrorCode($e->getCode()) + ->setErrorMessage($e->getMessage()) ; } @@ -315,14 +340,16 @@ public function sign(Base64 $document): ?string { $response = null; $data = [ - 'document' => new Base64($document), + 'document' => $document, ]; try { - $response = $this->xmlRpcClient->call('signer.sign', self::flatten($data)); + $response = $this->send('signer.sign', $this->flatten($data)); $this->logger->info('[Universign - signer.sign] SUCCESS'); - } catch (FaultException $fe) { - $this->logger->error(sprintf('[Universign - signer.sign] ERROR (%s): %s', $fe->getCode(), $fe->getMessage())); + } catch (Exception $e) { + $this->logger->error( + sprintf('[Universign - signer.sign] ERROR (%s): %s', $e->getCode(), $e->getMessage()) + ); } return $response; @@ -340,10 +367,12 @@ public function signWithOptions(Base64 $document, SignOptions $options): ?string ]; try { - $response = $this->xmlRpcClient->call('signer.signWithOptions', self::flatten($data)); + $response = $this->send('signer.signWithOptions', $this->flatten($data)); $this->logger->info('[Universign - signer.signWithOptions] SUCCESS'); - } catch (FaultException $fe) { - $this->logger->error(sprintf('[Universign - signer.signWithOptions] ERROR (%s): %s', $fe->getCode(), $fe->getMessage())); + } catch (Exception $e) { + $this->logger->error( + sprintf('[Universign - signer.signWithOptions] ERROR (%s): %s', $e->getCode(), $e->getMessage()) + ); } return $response; diff --git a/Requester/SignerInterface.php b/Requester/SignerInterface.php index e3f36a0..f3adc87 100644 --- a/Requester/SignerInterface.php +++ b/Requester/SignerInterface.php @@ -2,12 +2,12 @@ namespace Mpp\UniversignBundle\Requester; -use Laminas\XmlRpc\Value\Base64; use Mpp\UniversignBundle\Model\Document; use Mpp\UniversignBundle\Model\SignOptions; use Mpp\UniversignBundle\Model\TransactionInfo; use Mpp\UniversignBundle\Model\TransactionRequest; use Mpp\UniversignBundle\Model\TransactionResponse; +use Mpp\UniversignBundle\Model\XmlRpc\Base64; interface SignerInterface { diff --git a/Requester/XmlRpcRequester.php b/Requester/XmlRpcRequester.php index 77d1bde..a670ea4 100644 --- a/Requester/XmlRpcRequester.php +++ b/Requester/XmlRpcRequester.php @@ -2,9 +2,11 @@ namespace Mpp\UniversignBundle\Requester; -use Laminas\XmlRpc\Client; -use Laminas\XmlRpc\Value\Base64; -use Laminas\XmlRpc\Value\DateTime; +use PhpXmlRpc\Client; +use PhpXmlRpc\Encoder; +use PhpXmlRpc\Helper\XMLParser; +use PhpXmlRpc\Request; +use PhpXmlRpc\Value; abstract class XmlRpcRequester { @@ -13,9 +15,20 @@ abstract class XmlRpcRequester */ protected $xmlRpcClient; - public function __construct(?array $clientOptions = null) + /** + * @var Encoder + */ + protected $encoder; + + + public function __construct(Encoder $encoder, array $clientOptions = []) { - $this->xmlRpcClient = new Client($this->getURL(), new \Laminas\Http\Client(null, $clientOptions)); + $this->encoder = $encoder; + $this->xmlRpcClient = new Client($this->getUrl()); + foreach ($clientOptions as $name => $value) { + $this->xmlRpcClient->setOption($name, $value); + } + $this->xmlRpcClient->setOption(Client::OPT_RETURN_TYPE, XMLParser::RETURN_PHP); } /** @@ -27,31 +40,35 @@ abstract public function getUrl(); * @param mixed $data * @param bool $skipNullValue * - * @return mixed + * @return Value|array */ - public static function flatten($data, bool $skipNullValue = true) + public function flatten($data, bool $skipNullValue = true) { $flattenedData = []; - if (is_object($data) && - !($data instanceof DateTime) && - !($data instanceof Base64) - ) { - return self::dismount($data, $skipNullValue); + if (is_object($data) && !$data instanceof Value && !$data instanceof \DateTime) { + return $this->dismount($data, $skipNullValue); } if (is_array($data)) { foreach ($data as $key => $value) { - $flattenedValue = self::flatten($value, $skipNullValue); + $flattenedValue = $this->flatten($value, $skipNullValue); if (true === $skipNullValue && null === $flattenedValue) { continue; } + if (!$flattenedValue instanceof Value) { + $flattenedValue = $this->encoder->encode($flattenedValue); + } $flattenedData[$key] = $flattenedValue; } return $flattenedData; } + if (!$data instanceof Value) { + $data = $this->encoder->encode($data); + } + return $data; } @@ -61,7 +78,7 @@ public static function flatten($data, bool $skipNullValue = true) * * @return array */ - public static function dismount($object, bool $skipNullValue = true): array + public function dismount($object, bool $skipNullValue = true): array { $rc = new \ReflectionClass($object); $data = []; @@ -72,9 +89,28 @@ public static function dismount($object, bool $skipNullValue = true): array if (true === $skipNullValue && (null === $value || (is_array($value) && empty($value)))) { continue; } - $data[$property->getName()] = self::flatten($value, $skipNullValue); + $data[$property->getName()] = $this->flatten($value, $skipNullValue); } return $data; } + + protected function send(string $method, $params): mixed + { + $response = $this->xmlRpcClient->send($this::buildRequest($method, $this->flatten($params))); + + return $response->value(); + } + + protected static function buildRequest(string $method, $params) + { + if (!is_array($params)) { + $params = [$params]; + } + + return new Request( + $method, + $params + ); + } } diff --git a/Resources/config/services.yaml b/Resources/config/services.yaml index eb765b9..e9395d7 100644 --- a/Resources/config/services.yaml +++ b/Resources/config/services.yaml @@ -8,18 +8,18 @@ services: Mpp\UniversignBundle\Requester\Signer: arguments: - - '@logger' - - '@router' - - '%mpp_universign.entrypoint%' - - '%mpp_universign.options%' - - '%mpp_universign.client_options%' + $logger: '@logger' + $router: '@router' + $entrypoint: '%mpp_universign.entrypoint%' + $options: '%mpp_universign.options%' + $clientOptions: '%mpp_universign.client_options%' Mpp\UniversignBundle\Requester\RegistrationAuthority: arguments: - - '@logger' - - '@router' - - '%mpp_universign.entrypoint%' - - '%mpp_universign.client_options%' + $logger: '@logger' + $router: '@router' + $entrypoint: '%mpp_universign.entrypoint%' + $clientOptions: '%mpp_universign.client_options%' Mpp\UniversignBundle\Requester\SignerInterface: '@Mpp\UniversignBundle\Requester\Signer' Mpp\UniversignBundle\Requester\RegistrationAuthorityInterface: '@Mpp\UniversignBundle\Requester\RegistrationAuthority' \ No newline at end of file diff --git a/composer.json b/composer.json index 3071442..5143f16 100644 --- a/composer.json +++ b/composer.json @@ -17,13 +17,13 @@ } ], "require": { - "php": ">=7.3", - "laminas/laminas-xmlrpc": "^2.10.1", + "php": ">=7.4", "symfony/dependency-injection": "^4.0 | ^5.0 | ^6.0", "symfony/event-dispatcher": "*", "symfony/framework-bundle": "^4.0 | ^5.0 | ^6.0", "symfony/monolog-bundle": "*", - "ext-json": "*" + "ext-json": "*", + "phpxmlrpc/phpxmlrpc": "^4.9" }, "autoload":{ "psr-4":{ From 6e32e0d3622866de7d76c3ab301f8341ac8c6449 Mon Sep 17 00:00:00 2001 From: "celine.c" Date: Fri, 29 Sep 2023 17:02:53 +0200 Subject: [PATCH 2/5] refacto: remove unecessary docBlocks and add return on all methods --- Controller/CallbackController.php | 12 +- DependencyInjection/Configuration.php | 2 +- .../MppUniversignExtension.php | 6 +- Event/UniversignCallbackEvent.php | 31 +- Model/CertificateInfo.php | 49 +-- Model/DocSignatureField.php | 15 +- Model/IdDocument.php | 4 - Model/InitiatorInfo.php | 51 +-- Model/Language.php | 2 +- Model/MatchingFilter.php | 61 +-- Model/MatchingResult.php | 111 +----- Model/RedirectionConfig.php | 33 +- Model/RegistrationRequest.php | 49 +-- Model/SepaData.php | 128 ++----- Model/SepaThirdParty.php | 94 +---- Model/SignOptions.php | 107 +----- Model/SignatureField.php | 82 +--- Model/Signer.php | 4 - Model/SignerInfo.php | 216 +---------- Model/TransactionInfo.php | 190 +-------- Model/TransactionRequest.php | 359 +++--------------- Model/TransactionResponse.php | 73 +--- Model/ValidationRequest.php | 67 +--- Model/ValidatorResult.php | 81 +--- Requester/RegistrationAuthority.php | 28 +- Requester/RegistrationAuthorityInterface.php | 16 +- Requester/Signer.php | 61 +-- Requester/SignerInterface.php | 46 +-- Requester/XmlRpcRequester.php | 31 +- 29 files changed, 240 insertions(+), 1769 deletions(-) diff --git a/Controller/CallbackController.php b/Controller/CallbackController.php index 0458d44..d004dd7 100644 --- a/Controller/CallbackController.php +++ b/Controller/CallbackController.php @@ -12,15 +12,9 @@ class CallbackController extends AbstractController { - /** - * @var LoggerInterface - */ - private $logger; + private LoggerInterface $logger; - /** - * @var EventDispatcherInterface - */ - private $dispatcher; + private EventDispatcherInterface $dispatcher; public function __construct(LoggerInterface $logger, EventDispatcherInterface $dispatcher) { @@ -31,7 +25,7 @@ public function __construct(LoggerInterface $logger, EventDispatcherInterface $d /** * @Route("/universign/callback", name="mpp_universign_callback", methods="GET") */ - public function process(Request $request) + public function process(Request $request): Response { $status = $request->query->get('status'); $transactionId = $request->query->get('id'); diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index df1afe1..bf0a2c5 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -11,7 +11,7 @@ class Configuration implements ConfigurationInterface { public const CONFIGURATION_ROOT = 'mpp_universign'; - public function getConfigTreeBuilder() + public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder(self::CONFIGURATION_ROOT); diff --git a/DependencyInjection/MppUniversignExtension.php b/DependencyInjection/MppUniversignExtension.php index 61da4dd..4aeccd3 100644 --- a/DependencyInjection/MppUniversignExtension.php +++ b/DependencyInjection/MppUniversignExtension.php @@ -11,11 +11,7 @@ class MppUniversignExtension extends Extension { - /** - * @param array $configs - * @param ContainerBuilder $container - */ - public function load(array $configs, ContainerBuilder $container) + public function load(array $configs, ContainerBuilder $container): void { $configuration = new Configuration($container->getParameter('kernel.debug')); $config = $this->processConfiguration($configuration, $configs); diff --git a/Event/UniversignCallbackEvent.php b/Event/UniversignCallbackEvent.php index acc39d3..385dbc4 100644 --- a/Event/UniversignCallbackEvent.php +++ b/Event/UniversignCallbackEvent.php @@ -14,26 +14,12 @@ class UniversignCallbackEvent */ public const STATUS_SIGNED = 5; - /** - * @var string - */ - private $transactionId; + private string $transactionId; - /** - * @var int|null - */ - private $indexSigner; + private ?int $indexSigner; - /** - * @var int - */ - private $status; + private int $status; - /** - * @param string $transactionId - * @param int|null $indexSigner - * @param int $status - */ public function __construct(string $transactionId, ?int $indexSigner, int $status) { $this->transactionId = $transactionId; @@ -41,25 +27,16 @@ public function __construct(string $transactionId, ?int $indexSigner, int $statu $this->status = $status; } - /** - * @retrun string - */ - public function getTransactionId() + public function getTransactionId(): string { return $this->transactionId; } - /** - * @return int - */ public function getIndexSigner(): ?int { return $this->indexSigner; } - /** - * @return int - */ public function getStatus(): int { return $this->status; diff --git a/Model/CertificateInfo.php b/Model/CertificateInfo.php index 6f6e390..a8fcb6e 100644 --- a/Model/CertificateInfo.php +++ b/Model/CertificateInfo.php @@ -8,30 +8,17 @@ use Symfony\Component\OptionsResolver\Exception\NoSuchOptionException; use Symfony\Component\OptionsResolver\Exception\OptionDefinitionException; use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException; -use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; class CertificateInfo { - /** - * @var string - */ - protected $subject; + protected ?string $subject; - /** - * @var string - */ - protected $issuer; + protected ?string $issuer; - /** - * @var string - */ - protected $serial; + protected ?string $serial; - /** - * @param OptionsResolver $resolver - */ - public static function configureData(OptionsResolver $resolver) + public static function configureData(OptionsResolver $resolver): void { $resolver ->setDefault('subject', null)->setAllowedTypes('subject', ['null', 'string']) @@ -41,10 +28,6 @@ public static function configureData(OptionsResolver $resolver) } /** - * @param array $options - * - * @return self - * * @throws UndefinedOptionsException If an option name is undefined * @throws InvalidOptionsException If an option doesn't fulfill the language specified validation rules * @throws MissingOptionsException If a required option is missing @@ -65,11 +48,6 @@ public static function createFromArray(array $options): self ; } - /** - * @param string|null $subject - * - * @return self - */ public function setSubject(?string $subject): self { $this->subject = $subject; @@ -77,19 +55,11 @@ public function setSubject(?string $subject): self return $this; } - /** - * @return string|null - */ public function getSubject(): ?string { return $this->subject; } - /** - * @param string|null $issuer - * - * @return self - */ public function setIssuer(?string $issuer): self { $this->issuer = $issuer; @@ -97,19 +67,11 @@ public function setIssuer(?string $issuer): self return $this; } - /** - * @return string|null - */ public function getIssuer(): ?string { return $this->issuer; } - /** - * @param string|null $serial - * - * @return self - */ public function setSerial(?string $serial): self { $this->serial = $serial; @@ -117,9 +79,6 @@ public function setSerial(?string $serial): self return $this; } - /** - * @return string|null - */ public function getSerial(): ?string { return $this->serial; diff --git a/Model/DocSignatureField.php b/Model/DocSignatureField.php index ef59d14..445c1a3 100644 --- a/Model/DocSignatureField.php +++ b/Model/DocSignatureField.php @@ -13,16 +13,13 @@ class DocSignatureField extends SignatureField { - protected string $patternName; + protected ?string $patternName; - protected string $label; + protected ?string $label; - protected Base64 $image; + protected ?Base64 $image; - /** - * @param OptionsResolver $resolver - */ - public static function configureData(OptionsResolver $resolver) + public static function configureData(OptionsResolver $resolver): void { parent::configureData($resolver); @@ -34,10 +31,6 @@ public static function configureData(OptionsResolver $resolver) } /** - * @param array $options - * - * @return self - * * @throws UndefinedOptionsException If an option name is undefined * @throws InvalidOptionsException If an option doesn't fulfill the language specified validation rules * @throws MissingOptionsException If a required option is missing diff --git a/Model/IdDocument.php b/Model/IdDocument.php index 428d761..31e6958 100644 --- a/Model/IdDocument.php +++ b/Model/IdDocument.php @@ -60,10 +60,6 @@ public static function configureData(OptionsResolver $resolver): void } /** - * @param array $options - * - * @return self - * * @throws UndefinedOptionsException If an option name is undefined * @throws InvalidOptionsException If an option doesn't fulfill the language specified validation rules * @throws MissingOptionsException If a required option is missing diff --git a/Model/InitiatorInfo.php b/Model/InitiatorInfo.php index 3f33eb2..051c6dc 100644 --- a/Model/InitiatorInfo.php +++ b/Model/InitiatorInfo.php @@ -8,30 +8,17 @@ use Symfony\Component\OptionsResolver\Exception\NoSuchOptionException; use Symfony\Component\OptionsResolver\Exception\OptionDefinitionException; use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException; -use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; class InitiatorInfo { - /** - * @var string - */ - protected $email; + protected ?string $email; - /** - * @var string - */ - protected $firstName; + protected ?string $firstName; - /** - * @var string - */ - protected $lastName; + protected ?string $lastName; - /** - * @param OptionsResolver $resolver - */ - public static function configureData(OptionsResolver $resolver) + public static function configureData(OptionsResolver $resolver): void { $resolver ->setDefault('email', null)->setAllowedTypes('email', ['null', 'string']) @@ -41,10 +28,6 @@ public static function configureData(OptionsResolver $resolver) } /** - * @param array|null $options - * - * @return self - * * @throws UndefinedOptionsException If an option name is undefined * @throws InvalidOptionsException If an option doesn't fulfill the language specified validation rules * @throws MissingOptionsException If a required option is missing @@ -52,7 +35,7 @@ public static function configureData(OptionsResolver $resolver) * @throws NoSuchOptionException If a lazy option reads an unavailable option * @throws AccessException If called from a lazy option or normalizer */ - public static function createFromArray(?array $options): self + public static function createFromArray(array $options): ?self { if (null === $options) { return null; @@ -69,11 +52,6 @@ public static function createFromArray(?array $options): self ; } - /** - * @param string|null $email - * - * @return self - */ public function setEmail(?string $email): self { $this->email = $email; @@ -81,19 +59,11 @@ public function setEmail(?string $email): self return $this; } - /** - * @return string|null - */ public function getEmail(): ?string { return $this->email; } - /** - * @param string|null $firstName - * - * @return self - */ public function setFirstName(?string $firstName): self { $this->firstName = $firstName; @@ -101,19 +71,11 @@ public function setFirstName(?string $firstName): self return $this; } - /** - * @return string|null - */ public function getFirstName(): ?string { return $this->firstName; } - /** - * @param string|null $lastName - * - * @return self - */ public function setLastName(?string $lastName): self { $this->lastName = $lastName; @@ -121,9 +83,6 @@ public function setLastName(?string $lastName): self return $this; } - /** - * @return string|null - */ public function getLastName(): ?string { return $this->lastName; diff --git a/Model/Language.php b/Model/Language.php index d2c68bb..4eb8c26 100644 --- a/Model/Language.php +++ b/Model/Language.php @@ -15,4 +15,4 @@ class Language public const POLISH = 'pl'; public const PORTUGUESE = 'pt'; public const ROMANIAN = 'ro'; -} \ No newline at end of file +} diff --git a/Model/MatchingFilter.php b/Model/MatchingFilter.php index a5afbee..070e98f 100644 --- a/Model/MatchingFilter.php +++ b/Model/MatchingFilter.php @@ -12,30 +12,15 @@ class MatchingFilter { - /** - * @var string - */ - protected $firstname; + protected string $firstname; - /** - * @var string - */ - protected $lastname; + protected string $lastname; - /** - * @var string|null - */ - protected $mobile; + protected ?string $mobile; - /** - * @var string|null - */ - protected $email; + protected ?string $email; - /** - * @param OptionsResolver $resolver - */ - public static function configureData(OptionsResolver $resolver) + public static function configureData(OptionsResolver $resolver): void { $resolver ->setRequired('firstname')->setAllowedTypes('firstname', ['string']) @@ -46,10 +31,6 @@ public static function configureData(OptionsResolver $resolver) } /** - * @param array $options - * - * @return self - * * @throws UndefinedOptionsException If an option name is undefined * @throws InvalidOptionsException If an option doesn't fulfill the language specified validation rules * @throws MissingOptionsException If a required option is missing @@ -71,19 +52,11 @@ public static function createFromArray(array $options): self ; } - /** - * @return string - */ public function getFirstname(): string { return $this->firstname; } - /** - * @param string $firstname - * - * @return self - */ public function setFirstname(string $firstname): self { $this->firstname = $firstname; @@ -91,19 +64,11 @@ public function setFirstname(string $firstname): self return $this; } - /** - * @return string - */ public function getLastname(): string { return $this->lastname; } - /** - * @param string $lastname - * - * @return self - */ public function setLastname(string $lastname): self { $this->lastname = $lastname; @@ -111,19 +76,11 @@ public function setLastname(string $lastname): self return $this; } - /** - * @return string|null - */ public function getMobile(): ?string { return $this->mobile; } - /** - * @param string|null $mobile - * - * @return self - */ public function setMobile(?string $mobile): self { $this->mobile = $mobile; @@ -131,19 +88,11 @@ public function setMobile(?string $mobile): self return $this; } - /** - * @return string|null - */ public function getEmail(): ?string { return $this->email; } - /** - * @param string|null $email - * - * @return self - */ public function setEmail(?string $email): self { $this->email = $email; diff --git a/Model/MatchingResult.php b/Model/MatchingResult.php index 98b435e..1e25f9b 100644 --- a/Model/MatchingResult.php +++ b/Model/MatchingResult.php @@ -20,47 +20,24 @@ class MatchingResult public const CERTIFICATE_STATUS_VALID = 'valid'; public const CERTIFICATE_STATUS_REVOKED = 'revoked'; public const CERTIFICATE_STATUS_AWAITING_VALIDATION = 'awaiting-validation'; - /** - * @var string|null - */ - protected $firstname; - /** - * @var string|null - */ - protected $lastname; + protected ?string $firstname; - /** - * @var string|null - */ - protected $mobile; + protected ?string $lastname; - /** - * @var string|null - */ - protected $email; + protected ?string $mobile; - /** - * @var string|null - */ - protected $certificateLevel; + protected ?string $email; - /** - * @var string|null - */ - protected $certificateStatus; + protected ?string $certificateLevel; - /** - * @var RaCertificateInfo|null - */ - protected $certificateInfo; + protected ?string $certificateStatus; - /** - * @var \DateTime|null - */ - protected $expirationDate; + protected ?RaCertificateInfo $certificateInfo; - public static function configureData(OptionsResolver $resolver) + protected ?\DateTime $expirationDate; + + public static function configureData(OptionsResolver $resolver): void { $resolver ->setDefault('firstname', null)->setAllowedTypes('firstname', ['null', 'string']) @@ -87,10 +64,6 @@ public static function configureData(OptionsResolver $resolver) } /** - * @param array $options - * - * @return self - * * @throws UndefinedOptionsException If an option name is undefined * @throws InvalidOptionsException If an option doesn't fulfill the language specified validation rules * @throws MissingOptionsException If a required option is missing @@ -116,19 +89,11 @@ public static function createFromArray(array $options): self ; } - /** - * @return string|null - */ public function getFirstname(): ?string { return $this->firstname; } - /** - * @param string|null $firstname - * - * @return self - */ public function setFirstname(?string $firstname): self { $this->firstname = $firstname; @@ -136,19 +101,11 @@ public function setFirstname(?string $firstname): self return $this; } - /** - * @return string|null - */ public function getLastname(): ?string { return $this->lastname; } - /** - * @param string|null $lastname - * - * @return self - */ public function setLastname(?string $lastname): self { $this->lastname = $lastname; @@ -156,19 +113,11 @@ public function setLastname(?string $lastname): self return $this; } - /** - * @return string|null - */ public function getMobile(): ?string { return $this->mobile; } - /** - * @param string|null $mobile - * - * @return self - */ public function setMobile(?string $mobile): self { $this->mobile = $mobile; @@ -176,19 +125,11 @@ public function setMobile(?string $mobile): self return $this; } - /** - * @return string|null - */ public function getEmail(): ?string { return $this->email; } - /** - * @param string|null $email - * - * @return self - */ public function setEmail(?string $email): self { $this->email = $email; @@ -196,19 +137,11 @@ public function setEmail(?string $email): self return $this; } - /** - * @return string|null - */ public function getCertificateLevel(): ?string { return $this->certificateLevel; } - /** - * @param string|null $certificateLevel - * - * @return self - */ public function setCertificateLevel(?string $certificateLevel): self { $this->certificateLevel = $certificateLevel; @@ -216,19 +149,11 @@ public function setCertificateLevel(?string $certificateLevel): self return $this; } - /** - * @return string|null - */ public function getCertificateStatus(): ?string { return $this->certificateStatus; } - /** - * @param string|null $certificateStatus - * - * @return self - */ public function setCertificateStatus(?string $certificateStatus): self { $this->certificateStatus = $certificateStatus; @@ -236,19 +161,11 @@ public function setCertificateStatus(?string $certificateStatus): self return $this; } - /** - * @return RaCertificateInfo|null - */ public function getCertificateInfo(): ?RaCertificateInfo { return $this->certificateInfo; } - /** - * @param RaCertificateInfo|null $certificateInfo - * - * @return self - */ public function setCertificateInfo(?RaCertificateInfo $certificateInfo): self { $this->certificateInfo = $certificateInfo; @@ -256,19 +173,11 @@ public function setCertificateInfo(?RaCertificateInfo $certificateInfo): self return $this; } - /** - * @return \DateTime|null - */ public function getExpirationDate(): ?\DateTime { return $this->expirationDate; } - /** - * @param \DateTime|null $expirationDate - * - * @return MatchingResult - */ public function setExpirationDate(?\DateTime $expirationDate): self { $this->expirationDate = $expirationDate; diff --git a/Model/RedirectionConfig.php b/Model/RedirectionConfig.php index 17cdc3b..58f34a6 100644 --- a/Model/RedirectionConfig.php +++ b/Model/RedirectionConfig.php @@ -8,25 +8,18 @@ use Symfony\Component\OptionsResolver\Exception\NoSuchOptionException; use Symfony\Component\OptionsResolver\Exception\OptionDefinitionException; use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException; -use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; class RedirectionConfig { - /** - * @var string - */ - protected $URL; + protected ?string $URL; - /** - * @var string - */ - protected $displayName; + protected ?string $displayName; /** * @param OptionsResolver */ - public static function configureData(OptionsResolver $resolver) + public static function configureData(OptionsResolver $resolver): void { $resolver ->setDefault('URL', null)->setAllowedTypes('URL', ['string', 'null']) @@ -35,10 +28,6 @@ public static function configureData(OptionsResolver $resolver) } /** - * @param array $options - * - * @return self - * * @throws UndefinedOptionsException If an option name is undefined * @throws InvalidOptionsException If an option doesn't fulfill the language specified validation rules * @throws MissingOptionsException If a required option is missing @@ -58,11 +47,6 @@ public static function createFromArray(array $options): self ; } - /** - * @param string|null $url - * - * @return self - */ public function setUrl(?string $url): self { $this->URL = $url; @@ -70,19 +54,11 @@ public function setUrl(?string $url): self return $this; } - /** - * @return string|null - */ public function getUrl(): ?string { return $this->URL; } - /** - * @param string|null $displayName - * - * @return self - */ public function setDisplayName(?string $displayName): self { $this->displayName = $displayName; @@ -90,9 +66,6 @@ public function setDisplayName(?string $displayName): self return $this; } - /** - * @return string|null - */ public function getDisplayName(): ?string { return $this->displayName; diff --git a/Model/RegistrationRequest.php b/Model/RegistrationRequest.php index 07b4fe6..188efb9 100644 --- a/Model/RegistrationRequest.php +++ b/Model/RegistrationRequest.php @@ -8,7 +8,6 @@ use Symfony\Component\OptionsResolver\Exception\NoSuchOptionException; use Symfony\Component\OptionsResolver\Exception\OptionDefinitionException; use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException; -use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; class RegistrationRequest @@ -17,37 +16,19 @@ class RegistrationRequest public const DOCTYPE_PASSPORT = 'passport_eu'; public const DOCTYPE_TITLE_STAY = 'titre_sejour'; - /** - * @var array - */ - protected $documents; + protected array $documents; - /** - * @var string - */ - protected $type; + protected ?string $type; - public function __construct() - { - $this->documents = []; - } - - /** - * @param OptionsResolver $resolver - */ - public static function configureData(OptionsResolver $resolver) + public static function configureData(OptionsResolver $resolver): void { $resolver - ->setDefined('documents', [])->setAllowedTypes('documents', ['array']) - ->setDefined('type', null)->setAllowedTypes('type', ['null', 'string']) + ->setDefault('documents', [])->setAllowedTypes('documents', ['array']) + ->setDefault('type', null)->setAllowedTypes('type', ['null', 'string']) ; } /** - * @param array $options - * - * @return self - * * @throws UndefinedOptionsException If an option name is undefined * @throws InvalidOptionsException If an option doesn't fulfill the language specified validation rules * @throws MissingOptionsException If a required option is missing @@ -67,31 +48,18 @@ public static function createFromArray(array $options): self ; } - /** - * @param array|null $documents - * - * @return self - */ - public function setDocuments(?array $documents): self + public function setDocuments(array $documents): self { $this->documents = $documents; return $this; } - /** - * @return array|null - */ - public function getDocuments(): ?array + public function getDocuments(): array { return $this->documents; } - /** - * @param string|null $type - * - * @return self - */ public function setType(?string $type): self { $this->type = $type; @@ -99,9 +67,6 @@ public function setType(?string $type): self return $this; } - /** - * @return string|null - */ public function getType(): ?string { return $this->type; diff --git a/Model/SepaData.php b/Model/SepaData.php index b917d02..c9aa9b5 100644 --- a/Model/SepaData.php +++ b/Model/SepaData.php @@ -13,40 +13,19 @@ class SepaData { - /** - * @var string - */ - protected $rum; + protected string $rum; - /** - * @var string - */ - protected $ics; + protected string $ics; - /** - * @var string - */ - protected $iban; + protected string $iban; - /** - * @var string - */ - protected $bic; + protected string $bic; - /** - * @var bool - */ - protected $recuring; + protected bool $recuring; - /** - * @var SepaThirdParty - */ - protected $debtor; + protected SepaThirdParty $debtor; - /** - * @var SepaThirdParty - */ - protected $creditor; + protected SepaThirdParty $creditor; public function __construct() { @@ -54,10 +33,7 @@ public function __construct() $this->creditor = []; } - /** - * @param OptionsResolver $resolver - */ - public static function configureData(OptionsResolver $resolver) + public static function configureData(OptionsResolver $resolver): void { $resolver ->setRequired('rum')->setAllowedTypes('rum', ['string']) @@ -83,10 +59,6 @@ public static function configureData(OptionsResolver $resolver) } /** - * @param array $options - * - * @return self - * * @throws UndefinedOptionsException If an option name is undefined * @throws InvalidOptionsException If an option doesn't fulfill the language specified validation rules * @throws MissingOptionsException If a required option is missing @@ -111,142 +83,86 @@ public static function createFromArray(array $options): self ; } - /** - * @param string|null $rum - * - * @return self - */ - public function setRum(?string $rum): self + public function setRum(string $rum): self { $this->rum = $rum; return $this; } - /** - * @return string|null - */ - public function getRum(): ?string + public function getRum(): string { return $this->rum; } - /** - * @param string|null $ics - * - * @return self - */ - public function setIcs(?string $ics): self + public function setIcs(string $ics): self { $this->ics = $ics; return $this; } - /** - * @return string|null - */ - public function getIcs(): ?string + public function getIcs(): string { return $this->ics; } - /** - * @param string|null $iban - * - * @return self - */ - public function setIban(?string $iban): self + public function setIban(string $iban): self { $this->iban = $iban; return $this; } - /** - * @return string|null - */ - public function getIban(): ?string + public function getIban(): string { return $this->iban; } - /** - * @param string|null $bic - * - * @return self - */ - public function setBic(?string $bic): self + public function setBic(string $bic): self { $this->bic = $bic; return $this; } - /** - * @return string|null - */ - public function getBic(): ?string + public function getBic(): string { return $this->bic; } - /** - * @param bool|null $recuring - * - * @return self - */ - public function setRecuring(?bool $recuring): self + public function setRecuring(bool $recuring): self { $this->recuring = $recuring; return $this; } - /** - * @return bool|null - */ - public function getRecuring(): ?bool + public function getRecuring(): bool { return $this->recuring; } - /** - * @param SepaThirdParty|null $debtor - * - * @return self - */ - public function setDebtor(?SepaThirdParty $debtor): self + public function setDebtor(SepaThirdParty $debtor): self { $this->debtor = $debtor; return $this; } - /** - * @return SepaThirdParty|null - */ - public function getDebtor(): ?SepaThirdParty + public function getDebtor(): SepaThirdParty { return $this->debtor; } - /** - * @param SepaThirdParty|null $creditor - * - * @return self - */ - public function setCreditor(?SepaThirdParty $creditor): self + public function setCreditor(SepaThirdParty $creditor): self { $this->creditor = $creditor; return $this; } - /** - * @return SepaThirdParty|null - */ - public function getCreditor(): ?SepaThirdParty + public function getCreditor(): SepaThirdParty { return $this->creditor; } diff --git a/Model/SepaThirdParty.php b/Model/SepaThirdParty.php index ab69529..48dae7b 100644 --- a/Model/SepaThirdParty.php +++ b/Model/SepaThirdParty.php @@ -12,35 +12,17 @@ class SepaThirdParty { - /** - * @var string - */ - protected $name; + protected string $name; - /** - * @var string - */ - protected $address; + protected string $address; - /** - * @var string - */ - protected $postalCode; + protected string $postalCode; - /** - * @var string - */ - protected $city; + protected string $city; - /** - * @var string - */ - protected $country; + protected string $country; - /** - * @param OptionsResolver $resolver - */ - public static function configureData(OptionsResolver $resolver) + public static function configureData(OptionsResolver $resolver): void { $resolver ->setRequired('name')->setAllowedTypes('name', ['string']) @@ -52,10 +34,6 @@ public static function configureData(OptionsResolver $resolver) } /** - * @param array $options - * - * @return SepaThirdParty - * * @throws UndefinedOptionsException If an option name is undefined * @throws InvalidOptionsException If an option doesn't fulfill the language specified validation rules * @throws MissingOptionsException If a required option is missing @@ -78,102 +56,62 @@ public static function createFromArray(array $options): SepaThirdParty ; } - /** - * @param string|null $name - * - * @return self - */ - public function setName(?string $name): self + public function setName(string $name): self { $this->name = $name; return $this; } - /** - * @return string|null - */ - public function getName(): ?string + public function getName(): string { return $this->name; } - /** - * @param string|null $address - * - * @return self - */ - public function setAddress(?string $address): self + public function setAddress(string $address): self { $this->address = $address; return $this; } - /** - * @return string|null - */ - public function getAddress(): ?string + public function getAddress(): string { return $this->address; } - /** - * @param string|null $postalCode - * - * @return self - */ - public function setPostalCode(?string $postalCode): self + public function setPostalCode(string $postalCode): self { $this->postalCode = $postalCode; return $this; } - /** - * @return string|null - */ - public function getPostalCode(): ?string + public function getPostalCode(): string { return $this->postalCode; } - /** - * @param string|null $city - * - * @return self - */ - public function setCity(?string $city): self + public function setCity(string $city): self { $this->city = $city; return $this; } - /** - * @return string|null - */ - public function getCity(): ?string + public function getCity(): string { return $this->city; } - /** - * @param string|null $country - * - * @return self - */ - public function setCountry(?string $country): self + public function setCountry(string $country): self { $this->country = $country; return $this; } - /** - * @return string|null - */ - public function getCountry(): ?string + public function getCountry(): string { return $this->country; } diff --git a/Model/SignOptions.php b/Model/SignOptions.php index d442b97..aea2329 100644 --- a/Model/SignOptions.php +++ b/Model/SignOptions.php @@ -17,45 +17,21 @@ class SignOptions public const SINGNATURE_FORMAT_PADES_COMP = 'PADES-COMP'; public const SINGNATURE_FORMAT_ISO32000_1 = 'ISO-32000-1'; - /** - * @var string|null - */ - protected $profile; + protected ?string $profile; - /** - * @var SignatureField|null - */ - protected $signatureField; + protected ?SignatureField $signatureField; - /** - * @var string|null - */ - protected $reason; + protected ?string $reason; - /** - * @var string|null - */ - protected $location; + protected ?string $location; - /** - * @var string|null - */ - protected $signatureFormat; + protected ?string $signatureFormat; - /** - * @var string|null - */ - protected $language; + protected ?string $language; - /** - * @var string|null - */ - protected $patternName; + protected ?string $patternName; - /** - * @param OptionsResolver $resolver - */ - public static function configureData(OptionsResolver $resolver) + public static function configureData(OptionsResolver $resolver): void { $resolver ->setDefault('profile', 'default')->setAllowedTypes('profile', ['string']) @@ -75,10 +51,6 @@ public static function configureData(OptionsResolver $resolver) } /** - * @param array $options - * - * @return self - * * @throws UndefinedOptionsException If an option name is undefined * @throws InvalidOptionsException If an option doesn't fulfill the language specified validation rules * @throws MissingOptionsException If a required option is missing @@ -103,127 +75,78 @@ public static function createFromArray(array $options): self ; } - /** - * @return string|null - */ public function getProfile(): ?string { return $this->profile; } - /** - * @param string|null $profile - * @return SignOptions - */ - public function setProfile(?string $profile): SignOptions + public function setProfile(?string $profile): self { $this->profile = $profile; return $this; } - /** - * @return SignatureField|null - */ public function getSignatureField(): ?SignatureField { return $this->signatureField; } - /** - * @param SignatureField|null $signatureField - * @return SignOptions - */ - public function setSignatureField(?SignatureField $signatureField): SignOptions + public function setSignatureField(?SignatureField $signatureField): self { $this->signatureField = $signatureField; return $this; } - /** - * @return string|null - */ public function getReason(): ?string { return $this->reason; } - /** - * @param string|null $reason - * @return SignOptions - */ - public function setReason(?string $reason): SignOptions + public function setReason(?string $reason): self { $this->reason = $reason; return $this; } - /** - * @return string|null - */ public function getLocation(): ?string { return $this->location; } - /** - * @param string|null $location - * @return SignOptions - */ - public function setLocation(?string $location): SignOptions + public function setLocation(?string $location): self { $this->location = $location; return $this; } - /** - * @return string|null - */ public function getSignatureFormat(): ?string { return $this->signatureFormat; } - /** - * @param string|null $signatureFormat - * @return SignOptions - */ - public function setSignatureFormat(?string $signatureFormat): SignOptions + public function setSignatureFormat(?string $signatureFormat): self { $this->signatureFormat = $signatureFormat; return $this; } - /** - * @return string|null - */ public function getLanguage(): ?string { return $this->language; } - /** - * @param string|null $language - * @return SignOptions - */ - public function setLanguage(?string $language): SignOptions + public function setLanguage(?string $language): self { $this->language = $language; return $this; } - /** - * @return string|null - */ public function getPatternName(): ?string { return $this->patternName; } - /** - * @param string|null $patternName - * @return SignOptions - */ - public function setPatternName(?string $patternName): SignOptions + public function setPatternName(?string $patternName): self { $this->patternName = $patternName; return $this; diff --git a/Model/SignatureField.php b/Model/SignatureField.php index 5d7a73f..f15723f 100644 --- a/Model/SignatureField.php +++ b/Model/SignatureField.php @@ -12,35 +12,17 @@ class SignatureField { - /** - * @var string - */ - protected $name; + protected ?string $name; - /** - * @var int - */ - protected $page; + protected ?int $page; - /** - * @var int - */ - protected $x; + protected ?int $x; - /** - * @var int - */ - protected $y; + protected ?int $y; - /** - * @var int - */ - protected $signerIndex; + protected int $signerIndex; - /** - * @param OptionsResolver $resolver - */ - public static function configureData(OptionsResolver $resolver) + public static function configureData(OptionsResolver $resolver): void { $resolver ->setDefault('name', null)->setAllowedTypes('name', ['null', 'string']) @@ -52,10 +34,6 @@ public static function configureData(OptionsResolver $resolver) } /** - * @param array $options - * - * @return self - * * @throws UndefinedOptionsException If an option name is undefined * @throws InvalidOptionsException If an option doesn't fulfill the language specified validation rules * @throws MissingOptionsException If a required option is missing @@ -78,11 +56,6 @@ public static function createFromArray(array $options): self ; } - /** - * @param string $name - * - * @return self - */ public function setName(?string $name): self { $this->name = $name; @@ -90,19 +63,11 @@ public function setName(?string $name): self return $this; } - /** - * @return string - */ public function getName(): ?string { return $this->name; } - /** - * @param int $page - * - * @return self - */ public function setPage(?int $page): self { $this->page = $page; @@ -110,19 +75,11 @@ public function setPage(?int $page): self return $this; } - /** - * @return int - */ - public function getPage(): int + public function getPage(): ?int { return $this->page; } - /** - * @param int $x; - * - * @return self - */ public function setX(?int $x): self { $this->x = $x; @@ -130,19 +87,11 @@ public function setX(?int $x): self return $this; } - /** - * @return int - */ - public function getX(): int + public function getX(): ?int { return $this->x; } - /** - * @param int $y; - * - * @return self - */ public function setY(?int $y): self { $this->y = $y; @@ -150,29 +99,18 @@ public function setY(?int $y): self return $this; } - /** - * @return int - */ - public function getY(): int + public function getY(): ?int { return $this->y; } - /** - * @param int $signerIndex - * - * @return self - */ - public function setSignerIndex(?int $signerIndex): self + public function setSignerIndex(int $signerIndex): self { $this->signerIndex = $signerIndex; return $this; } - /** - * @return int - */ public function getSignerIndex(): int { return $this->signerIndex; diff --git a/Model/Signer.php b/Model/Signer.php index dd38efe..da9cef3 100644 --- a/Model/Signer.php +++ b/Model/Signer.php @@ -95,10 +95,6 @@ public static function configureData(OptionsResolver $resolver): void } /** - * @param array $options - * - * @return self - * * @throws UndefinedOptionsException If an option name is undefined * @throws InvalidOptionsException If an option doesn't fulfill the language specified validation rules * @throws MissingOptionsException If a required option is missing diff --git a/Model/SignerInfo.php b/Model/SignerInfo.php index 34ec79d..37747c5 100644 --- a/Model/SignerInfo.php +++ b/Model/SignerInfo.php @@ -23,90 +23,43 @@ class SignerInfo public const STATUS_CANCELED = 'canceled'; public const STATUS_FAILED = 'failed'; - /** - * @var string - */ - protected $status; + protected ?string $status; - /** - * @var string - */ - protected $error; + protected ?string $error; - /** - * @var CertificateInfo - */ - protected $certificateInfo; + protected ?CertificateInfo $certificateInfo; - /** - * @var string - */ - protected $url; + protected ?string $url; - /** - * @var string - */ - protected $id; + protected ?string $id; - /** - * @var string - */ - protected $email; + protected ?string $email; - /** - * @var string - */ - protected $firstName; + protected ?string $firstName; - /** - * @var string - */ - protected $lastName; + protected ?string $lastName; - /** - * @var \DateTime - */ - protected $actionDate; + protected ?\DateTime $actionDate; /** * @var array */ - protected $refusedDocs; + protected array $refusedDocs; - /** - * @var string - */ - protected $refusalComment; - - /** - * @var string - */ - protected $redirectPolicy; + protected ?string $refusalComment; - /** - * @var int - */ - protected $redirectWait; + protected ?string $redirectPolicy; - /** - * @var null|array - */ - protected $idDocuments; + protected ?int $redirectWait; - public function __construct() - { - $this->refusedDocs = []; - } + protected ?array $idDocuments; - /** - * @param OptionsResolver $resolver - */ - public static function configureData(OptionsResolver $resolver) + public static function configureData(OptionsResolver $resolver): void { $resolver ->setDefault('status', null)->setAllowedTypes('status', ['null', 'string']) ->setDefault('error', null)->setAllowedTypes('error', ['null', 'string']) - ->setDefault('certificateInfo', null)->setAllowedTypes('certificateInfo', ['null', 'array', CertificateInfo::class])->setNormalizer('certificateInfo', function(Options $options, $value) { + ->setDefault('certificateInfo', null)->setAllowedTypes('certificateInfo', ['null', 'array', CertificateInfo::class])->setNormalizer('certificateInfo', function (Options $options, $value) { if (null === $value || $value instanceof CertificateInfo) { return $value; } @@ -118,14 +71,14 @@ public static function configureData(OptionsResolver $resolver) ->setDefault('email', null)->setAllowedTypes('email', ['null', 'string']) ->setDefault('firstName', null)->setAllowedTypes('firstName', ['null', 'string']) ->setDefault('lastName', null)->setAllowedTypes('lastName', ['null', 'string']) - ->setDefault('actionDate', null)->setAllowedTypes('actionDate', ['null', 'string', \DateTime::class])->setNormalizer('actionDate', function(Options $options, $value) { + ->setDefault('actionDate', null)->setAllowedTypes('actionDate', ['null', 'string', \DateTime::class])->setNormalizer('actionDate', function (Options $options, $value) { if (null === $value || $value instanceof \DateTime) { return $value; } return \DateTime::createFromFormat("Ymd\TH:i:s", $value); }) - ->setDefault('refusedDocs', null)->setAllowedTypes('refusedDocs', ['null', 'string']) + ->setDefault('refusedDocs', [])->setAllowedTypes('refusedDocs', ['null', 'array']) ->setDefault('refusalComment', null)->setAllowedTypes('refusalComment', ['null', 'string']) ->setDefault('redirectPolicy', null)->setAllowedTypes('redirectPolicy', ['null', 'string']) ->setDefault('redirectWait', null)->setAllowedTypes('redirectWait', ['null', 'int']) @@ -134,10 +87,6 @@ public static function configureData(OptionsResolver $resolver) } /** - * @param array $options - * - * @return self - * * @throws UndefinedOptionsException If an option name is undefined * @throws InvalidOptionsException If an option doesn't fulfill the language specified validation rules * @throws MissingOptionsException If a required option is missing @@ -169,24 +118,6 @@ public static function createFromArray(array $options): self ; } - /** - * @param string|null $date - * - * @return \DateTime|null - */ - private static function createDate(?string $date): ?\DateTime { - if (is_null($date)) { - return null; - } - - return \DateTime::createFromFormat("Ymd\TH:i:s", $date); - } - - /** - * @param string|null $status - * - * @return self - */ public function setStatus(?string $status): self { $this->status = $status; @@ -194,19 +125,11 @@ public function setStatus(?string $status): self return $this; } - /** - * @return string|null - */ public function getStatus(): ?string { return $this->status; } - /** - * @param string|null $error - * - * @return self - */ public function setError(?string $error): self { $this->error = $error; @@ -214,19 +137,11 @@ public function setError(?string $error): self return $this; } - /** - * @return string|null - */ public function getError(): ?string { return $this->error; } - /** - * @param CertificateInfo|null $certificateInfo - * - * @return self - */ public function setCertificateInfo(?CertificateInfo $certificateInfo): self { $this->certificateInfo = $certificateInfo; @@ -234,19 +149,11 @@ public function setCertificateInfo(?CertificateInfo $certificateInfo): self return $this; } - /** - * @return CertificateInfo|null - */ public function getCertificateInfo(): ?CertificateInfo { return $this->certificateInfo; } - /** - * @param string|null $url - * - * @return self - */ public function setUrl(?string $url): self { $this->url = $url; @@ -254,19 +161,11 @@ public function setUrl(?string $url): self return $this; } - /** - * @return string|null - */ public function getUrl(): ?string { return $this->url; } - /** - * @param string|null $id - * - * @return self - */ public function setId(?string $id): self { $this->id = $id; @@ -274,19 +173,11 @@ public function setId(?string $id): self return $this; } - /** - * @return string|null - */ public function getId(): ?string { return $this->id; } - /** - * @param string|null $email - * - * @return self - */ public function setEmail(?string $email): self { $this->email = $email; @@ -294,19 +185,11 @@ public function setEmail(?string $email): self return $this; } - /** - * @return string|null - */ public function getEmail(): ?string { return $this->email; } - /** - * @param string|null $firstName - * - * @return self - */ public function setFirstName(?string $firstName): self { $this->firstName = $firstName; @@ -314,19 +197,11 @@ public function setFirstName(?string $firstName): self return $this; } - /** - * @return string|null - */ public function getFirstName(): ?string { return $this->firstName; } - /** - * @param string|null $lastName - * - * @return self - */ public function setLastName(?string $lastName): self { $this->lastName = $lastName; @@ -334,19 +209,11 @@ public function setLastName(?string $lastName): self return $this; } - /** - * @return string|null - */ public function getLastName(): ?string { return $this->lastName; } - /** - * @param \DateTime|null $actionDate - * - * @return self - */ public function setActionDate(?\DateTime $actionDate): self { $this->actionDate = $actionDate; @@ -354,39 +221,23 @@ public function setActionDate(?\DateTime $actionDate): self return $this; } - /** - * @return \DateTime|null - */ public function getActionDate(): ?\DateTime { return $this->actionDate; } - /** - * @param array|null $refusedDocs - * - * @return self - */ - public function setRefusedDocs(?array $refusedDocs): self + public function setRefusedDocs(array $refusedDocs): self { $this->refusedDocs = $refusedDocs; return $this; } - /** - * @return array|null - */ - public function getRefusedDocs(): ?array + public function getRefusedDocs(): array { return $this->refusedDocs; } - /** - * @param string|null $refusalComment - * - * @return self - */ public function setRefusalComment(?string $refusalComment): self { $this->refusalComment = $refusalComment; @@ -394,19 +245,11 @@ public function setRefusalComment(?string $refusalComment): self return $this; } - /** - * @return string|null - */ public function getRefusalComment(): ?string { return $this->refusalComment; } - /** - * @param string|null $redirectPolicy - * - * @return self - */ public function setRediRectPolicy(?string $redirectPolicy): self { $this->redirectPolicy = $redirectPolicy; @@ -414,19 +257,11 @@ public function setRediRectPolicy(?string $redirectPolicy): self return $this; } - /** - * @return string|null - */ public function getRedirectPolicy(): ?string { return $this->redirectPolicy; } - /** - * @param int|null $redirectWait - * - * @return self - */ public function setRedirectWait(?int $redirectWait): self { $this->redirectWait = $redirectWait; @@ -434,27 +269,16 @@ public function setRedirectWait(?int $redirectWait): self return $this; } - /** - * @return int|null - */ public function getRedirectWait(): ?int { return $this->redirectWait; } - /** - * @return array|null - */ public function getIdDocuments(): ?array { return $this->idDocuments; } - /** - * @param array|null $idDocuments - * - * @return SignerInfo - */ public function setIdDocuments(?array $idDocuments): SignerInfo { $this->idDocuments = $idDocuments; diff --git a/Model/TransactionInfo.php b/Model/TransactionInfo.php index 41085cc..61ec3cc 100644 --- a/Model/TransactionInfo.php +++ b/Model/TransactionInfo.php @@ -13,75 +13,36 @@ class TransactionInfo public const STATUS_FAILED = 'failed'; public const STATUS_COMPLETED = 'completed'; - /** - * @var string - */ - protected $state; + protected ?string $state; - /** - * @var string - */ - protected $errorMessage; + protected ?string $errorMessage; - /** - * @var int - */ - protected $errorCode; + protected int $errorCode; - /** - * @var string - */ - protected $status; + protected ?string $status; /** * @var array */ - protected $signerInfos; + protected array $signerInfos; - /** - * @var int - */ - protected $currentSigner; + protected ?int $currentSigner; - /** - * @var \DateTime - */ - protected $creationDate; + protected ?\DateTime $creationDate; - /** - * @var string - */ - protected $description; + protected ?string $description; - /** - * @var InitiatorInfo - */ - protected $initiatorInfo; + protected InitiatorInfo $initiatorInfo; - /** - * @var bool - */ - protected $eachField; + protected ?bool $eachField; - /** - * @var string - */ - protected $customerId; + protected ?string $customerId; - /** - * @var string - */ - protected $transactionId; + protected ?string $transactionId; - /** - * @var string - */ - protected $redirectPolicy; + protected ?string $redirectPolicy; - /** - * @var int - */ - protected $redirectWait; + protected ?int $redirectWait; public function __construct() { @@ -101,11 +62,6 @@ public function __construct() $this->errorCode = 0; } - /** - * @param string|null $state - * - * @return self - */ public function setState(?string $state): self { $this->state = $state; @@ -113,19 +69,11 @@ public function setState(?string $state): self return $this; } - /** - * @return string|null - */ public function getState(): ?string { return $this->state; } - /** - * @param string|null $errorMessage - * - * @return self - */ public function setErrorMessage(?string $errorMessage): self { $this->errorMessage = $errorMessage; @@ -133,39 +81,23 @@ public function setErrorMessage(?string $errorMessage): self return $this; } - /** - * @return string|null - */ public function getErrorMessage(): ?string { return $this->errorMessage; } - /** - * @return int - */ public function getErrorCode(): int { return $this->errorCode; } - /** - * @param int $errorCode - * - * @return TransactionInfo - */ - public function setErrorCode(int $errorCode): TransactionInfo + public function setErrorCode(int $errorCode): self { $this->errorCode = $errorCode; return $this; } - /** - * @param string|null $status - * - * @return self - */ public function setStatus(?string $status): self { $this->status = $status; @@ -173,32 +105,22 @@ public function setStatus(?string $status): self return $this; } - /** - * @return string|null - */ public function getStatus(): ?string { return $this->status; } /** - * @param array|null $signerInfos - * - * @return self + * @param array $signerInfos */ - public function setSignerInfos(?array $signerInfos): self + public function setSignerInfos(array $signerInfos): self { $this->signerInfos = $signerInfos; return $this; } - /** - * @param SignerInfo|null $signerInfo - * - * @return self - */ - public function addSignerInfo(?SignerInfo $signerInfo): self + public function addSignerInfo(SignerInfo $signerInfo): self { $this->signerInfos[] = $signerInfo; @@ -206,18 +128,13 @@ public function addSignerInfo(?SignerInfo $signerInfo): self } /** - * @return array|null + * @return array */ - public function getSignerInfos(): ?array + public function getSignerInfos(): array { return $this->signerInfos; } - /** - * @param int|null $currentSigner - * - * @return self - */ public function setCurrentSigner(?int $currentSigner): self { $this->currentSigner = $currentSigner; @@ -225,19 +142,11 @@ public function setCurrentSigner(?int $currentSigner): self return $this; } - /** - * @return int|null - */ public function getCurrentSigner(): ?int { return $this->currentSigner; } - /** - * @param \DateTime|null $creationDate - * - * @return self - */ public function setCreationDate(?\DateTime $creationDate): self { $this->creationDate = $creationDate; @@ -245,19 +154,11 @@ public function setCreationDate(?\DateTime $creationDate): self return $this; } - /** - * @return \DateTime|null - */ public function getCreationDate(): ?\DateTime { return $this->creationDate; } - /** - * @param string|null $description - * - * @return self - */ public function setDescription(?string $description): self { $this->description = $description; @@ -265,19 +166,11 @@ public function setDescription(?string $description): self return $this; } - /** - * @return string|null - */ public function getDescription(): ?string { return $this->description; } - /** - * @param InitiatorInfo|null $initiatorInfo - * - * @return self - */ public function setInitiatorInfo(?InitiatorInfo $initiatorInfo): self { $this->initiatorInfo = $initiatorInfo; @@ -285,19 +178,11 @@ public function setInitiatorInfo(?InitiatorInfo $initiatorInfo): self return $this; } - /** - * @return InitiatorInfo|null - */ public function getInitiatorInfo(): ?InitiatorInfo { return $this->initiatorInfo; } - /** - * @param bool|null $eachField - * - * @return self - */ public function setEachField(?bool $eachField): self { $this->eachField = $eachField; @@ -305,19 +190,11 @@ public function setEachField(?bool $eachField): self return $this; } - /** - * @return bool|null - */ public function getEachField(): ?bool { return $this->eachField; } - /** - * @param string|null $customerId - * - * @return self - */ public function setCustomerId(?string $customerId): self { $this->customerId = $customerId; @@ -325,19 +202,11 @@ public function setCustomerId(?string $customerId): self return $this; } - /** - * @return string|null - */ public function getCustomerId(): ?string { return $this->customerId; } - /** - * @param string|null $transactionId - * - * @return self - */ public function setTransactionId(?string $transactionId): self { $this->transactionId = $transactionId; @@ -345,19 +214,11 @@ public function setTransactionId(?string $transactionId): self return $this; } - /** - * @return string|null - */ public function getTransactionId(): ?string { return $this->transactionId; } - /** - * @param string|null $redirectPolicy - * - * @return self - */ public function setRedirectPolicy(?string $redirectPolicy): self { $this->redirectPolicy = $redirectPolicy; @@ -365,19 +226,11 @@ public function setRedirectPolicy(?string $redirectPolicy): self return $this; } - /** - * @return string|null - */ public function getRedirectPolicy(): ?string { return $this->redirectPolicy; } - /** - * @param int|null $redirectWait - * - * @return self - */ public function setRedirectWait(?int $redirectWait): self { $this->redirectWait = $redirectWait; @@ -385,9 +238,6 @@ public function setRedirectWait(?int $redirectWait): self return $this; } - /** - * @return int|null - */ public function getRedirectWait(): ?int { return $this->redirectWait; diff --git a/Model/TransactionRequest.php b/Model/TransactionRequest.php index f0762fe..e008802 100644 --- a/Model/TransactionRequest.php +++ b/Model/TransactionRequest.php @@ -13,136 +13,61 @@ class TransactionRequest { - /** - * @var string - */ - protected $profile; + protected ?string $profile; - /** - * @var string - */ - protected $customId; + protected ?string $customId; /** * @var array */ - protected $signers; + protected array $signers; /** * @var array */ - protected $documents; + protected array $documents; - /** - * @var bool - */ - protected $mustContactFirstSigner; - - /** - * @var bool - */ - protected $finalDocSent; + protected bool $mustContactFirstSigner; - /** - * @var bool - */ - protected $finalDocRequesterSent; + protected bool $finalDocSent; - /** - * @var bool - */ - protected $finalDocObserverSent; + protected bool $finalDocRequesterSent; - /** - * @var string - */ - protected $description; + protected bool $finalDocObserverSent; - /** - * @var string - */ - protected $certificateType; + protected ?string $description; - /** - * @var string - */ - protected $language; + protected string $certificateType; - /** - * @var int - */ - protected $handwrittenSignatureMode; + protected string $language; - /** - * @var string - */ - protected $chainingMode; + protected ?int $handwrittenSignatureMode; - /** - * @var array - */ - protected $finalDocCCeMails; + protected string $chainingMode; - /** - * @var RedirectionConfig - */ - protected $autoValidationRedirection; + protected ?array $finalDocCCeMails; - /** - * @var string - */ - protected $redirectPolicy; + protected ?RedirectionConfig $autoValidationRedirection; - /** - * @var int - */ - protected $redirectWait; + protected string $redirectPolicy; - /** - * @var bool - */ - protected $autoSendAgreements; + protected int $redirectWait; - /** - * @var string - */ - protected $operator; + protected ?bool $autoSendAgreements; - /** - * @var string - */ - protected $registrationCallbackURL; + protected ?string $operator; - /** - * @var RedirectionConfig - */ - protected $successRedirection; + protected ?string $registrationCallbackURL; - /** - * @var RedirectionConfig - */ - protected $failRedirection; + protected ?RedirectionConfig $successRedirection; - /** - * @var RedirectionConfig - */ - protected $cancelRedirection; + protected ?RedirectionConfig $failRedirection; - /** - * @var string - */ - protected $invitationMessage; + protected ?RedirectionConfig $cancelRedirection; - public function __construct() - { - $this->signers = []; - $this->documents = []; - } + protected ?string $invitationMessage; - /** - * @param OptionsResolver $resolver - */ - public static function configureData(OptionsResolver $resolver) + public static function configureData(OptionsResolver $resolver): void { $resolver ->setDefault('profile', null)->setAllowedTypes('profile', ['null', 'string']) @@ -205,10 +130,6 @@ public static function configureData(OptionsResolver $resolver) } /** - * @param array $options - * - * @return self - * * @throws UndefinedOptionsException If an option name is undefined * @throws InvalidOptionsException If an option doesn't fulfill the language specified validation rules * @throws MissingOptionsException If a required option is missing @@ -250,11 +171,6 @@ public static function createFromArray(array $options): self ; } - /** - * @param string|null $profile - * - * @return self - */ public function setProfile(?string $profile): self { $this->profile = $profile; @@ -262,19 +178,11 @@ public function setProfile(?string $profile): self return $this; } - /** - * @return string|null - */ public function getProfile(): ?string { return $this->profile; } - /** - * @param string|null $customId - * - * @return self - */ public function setCustomId(?string $customId): self { $this->customId = $customId; @@ -282,19 +190,11 @@ public function setCustomId(?string $customId): self return $this; } - /** - * @return string|null - */ public function getCustomId(): ?string { return $this->customId; } - /** - * @param Signer $signer - * - * @return self - */ public function addSigner(Signer $signer): self { $this->signers[] = $signer; @@ -304,8 +204,6 @@ public function addSigner(Signer $signer): self /** * @param array $signers - * - * @return self */ public function setSigners(array $signers): self { @@ -322,12 +220,6 @@ public function getSigners(): array return $this->signers; } - /** - * @param string $name - * @param Document $document - * - * @return self - */ public function addDocument(string $name, Document $document): self { $this->documents[$name] = $document; @@ -337,8 +229,6 @@ public function addDocument(string $name, Document $document): self /** * @param array $documents - * - * @return self */ public function setDocuments(array $documents): self { @@ -347,11 +237,6 @@ public function setDocuments(array $documents): self return $this; } - /** - * @param string $name - * - * @return Document - */ public function getDocument(string $name): Document { return $this->documents[$name]; @@ -365,89 +250,54 @@ public function getDocuments(): array return $this->documents; } - /** - * @param bool|null $mustContactFirstSigner - * - * @return self - */ - public function setMustContactFirstSigner(?bool $mustContactFirstSigner): self + public function setMustContactFirstSigner(bool $mustContactFirstSigner): self { $this->mustContactFirstSigner = $mustContactFirstSigner; return $this; } - /** - * @return bool|null - */ - public function getMustContactFirstSigner(): ?bool + public function getMustContactFirstSigner(): bool { return $this->mustContactFirstSigner; } - /** - * @param bool|null $finalDocSent - * - * @return self - */ - public function setFinalDocSent(?bool $finalDocSent): self + public function setFinalDocSent(bool $finalDocSent): self { $this->finalDocSent = $finalDocSent; return $this; } - /** - * @param bool|null - */ - public function getFinalDocSent(): ?bool + public function getFinalDocSent(): bool { return $this->finalDocSent; } - /** - * @param bool|null $finalDocRequesterSent - * - * @return self - */ - public function setFinalDocRequesterSent(?bool $finalDocRequesterSent): self + public function setFinalDocRequesterSent(bool $finalDocRequesterSent): self { $this->finalDocRequesterSent = $finalDocRequesterSent; return $this; } - /** - * @return bool|null - */ - public function getFinalDocRequesterSent(): ?bool + public function getFinalDocRequesterSent(): bool { return $this->finalDocRequesterSent; } - /** - * @param bool|null $finalDocObserverSent - * - * @return self - */ - public function setFinalDocObserverSent(?bool $finalDocObserverSent): self + public function setFinalDocObserverSent(bool $finalDocObserverSent): self { $this->finalDocObserverSent = $finalDocObserverSent; return $this; } - /** - * @return bool|null - */ - public function getFinalDocObserverSent(): ?bool + public function getFinalDocObserverSent(): bool { return $this->finalDocObserverSent; } - /** - * @param string|null $descripton - */ public function setDescription(?string $description): self { $this->description = $description; @@ -455,59 +305,35 @@ public function setDescription(?string $description): self return $this; } - /** - * @return string|null - */ public function getDescription(): ?string { return $this->description; } - /** - * @param string|null $certificateType - * - * @return self - */ - public function setCertificateType(?string $certificateType): self + public function setCertificateType(string $certificateType): self { $this->certificateType = $certificateType; return $this; } - /** - * @return string|null - */ - public function getCertificateType(): ?string + public function getCertificateType(): string { return $this->certificateType; } - /** - * @param string|null $language - * - * @return self - */ - public function setLanguage(?string $language): self + public function setLanguage(string $language): self { $this->language = $language; return $this; } - /** - * @return string|null - */ - public function getLanguage(): ?string + public function getLanguage(): string { return $this->language; } - /** - * @param int|null $handwrittenSignatureMode - * - * @return self - */ public function setHandwrittenSignatureMode(?int $handwrittenSignatureMode): self { $this->handwrittenSignatureMode = $handwrittenSignatureMode; @@ -515,39 +341,23 @@ public function setHandwrittenSignatureMode(?int $handwrittenSignatureMode): sel return $this; } - /** - * @return int|null - */ public function getHandwrittenSignatureMode(): ?int { return $this->handwrittenSignatureMode; } - /** - * @param string|null $chainingMode - * - * @return self - */ - public function setChainingMode(?string $chainingMode): self + public function setChainingMode(string $chainingMode): self { $this->chainingMode = $chainingMode; return $this; } - /** - * @return string|null - */ - public function getChainingMode(): ?string + public function getChainingMode(): string { return $this->chainingMode; } - /** - * @param array|null $finalDocCCeMails - * - * @return self - */ public function setFinalDocCCeMails(?array $finalDocCCeMails): self { $this->finalDocCCeMails = $finalDocCCeMails; @@ -555,19 +365,11 @@ public function setFinalDocCCeMails(?array $finalDocCCeMails): self return $this; } - /** - * @return array|null - */ public function getFinalDocCCemails(): ?array { return $this->finalDocCCeMails; } - /** - * @param RedirectionConfig|null $autoValidationRedirection - * - * @return self - */ public function setAutoValidationRedirection(?RedirectionConfig $autoValidationRedirection): self { $this->autoValidationRedirection = $autoValidationRedirection; @@ -575,59 +377,35 @@ public function setAutoValidationRedirection(?RedirectionConfig $autoValidationR return $this; } - /** - * @return RedirectionConfig|null - */ public function getAutoValidationRedirection(): ?RedirectionConfig { return $this->autoValidationRedirection; } - /** - * @param string|null $redirectPolicy - * - * @return self - */ - public function setRedirectPolicy(?string $redirectPolicy): self + public function setRedirectPolicy(string $redirectPolicy): self { $this->redirectPolicy = $redirectPolicy; return $this; } - /** - * @return string|null - */ - public function getRedirectPolicy(): ?string + public function getRedirectPolicy(): string { return $this->redirectPolicy; } - /** - * @param int|null $redirectWait - * - * @return self - */ - public function setRedirectWait(?int $redirectWait): self + public function setRedirectWait(int $redirectWait): self { $this->redirectWait = $redirectWait; return $this; } - /** - * @return int|null - */ - public function getRedirectWait(): ?int + public function getRedirectWait(): int { return $this->redirectWait; } - /** - * @param bool|null $autoSendAgreements - * - * @return self - */ public function setAutoSendAgreements(?bool $autoSendAgreements): self { $this->autoSendAgreements = $autoSendAgreements; @@ -635,19 +413,11 @@ public function setAutoSendAgreements(?bool $autoSendAgreements): self return $this; } - /** - * @return bool|null - */ public function getAutoSendAgreements(): ?bool { return $this->autoSendAgreements; } - /** - * @param string|null $operator - * - * @return self - */ public function setOperator(?string $operator): self { $this->operator = $operator; @@ -655,19 +425,11 @@ public function setOperator(?string $operator): self return $this; } - /** - * @return string|null - */ public function getOperator(): ?string { return $this->operator; } - /** - * @param string|null $registrationCallbackURL - * - * @return self - */ public function setRegistrationCallbackURL(?string $registrationCallbackURL): self { $this->registrationCallbackURL = $registrationCallbackURL; @@ -675,19 +437,11 @@ public function setRegistrationCallbackURL(?string $registrationCallbackURL): se return $this; } - /** - * @return string|null - */ public function getRegistrationCallbackURL(): ?string { return $this->registrationCallbackURL; } - /** - * @param RedirectionConfig|null $successRedirection - * - * @return self - */ public function setSuccessRedirection(?RedirectionConfig $successRedirection): self { $this->successRedirection = $successRedirection; @@ -695,19 +449,11 @@ public function setSuccessRedirection(?RedirectionConfig $successRedirection): s return $this; } - /** - * @return RedirectionConfig|null - */ public function getSuccessRedirection(): ?RedirectionConfig { return $this->successRedirection; } - /** - * @param RedirectionConfig|null $cancelRedirection - * - * @return self - */ public function setCancelRedirection(?RedirectionConfig $cancelRedirection): self { $this->cancelRedirection = $cancelRedirection; @@ -715,19 +461,11 @@ public function setCancelRedirection(?RedirectionConfig $cancelRedirection): sel return $this; } - /** - * @return RedirectionConfig|null - */ public function getCancelRedirection(): ?RedirectionConfig { return $this->cancelRedirection; } - /** - * @param RedirectionConfig|null $failRedirection - * - * @return self - */ public function setFailRedirection(?RedirectionConfig $failRedirection): self { $this->failRedirection = $failRedirection; @@ -735,19 +473,11 @@ public function setFailRedirection(?RedirectionConfig $failRedirection): self return $this; } - /** - * @return RedirectionConfig|null - */ public function getFailRedirection(): ?RedirectionConfig { return $this->failRedirection; } - /** - * @param string|null $invitationMessage - * - * @return self - */ public function setInvitationMessage(?string $invitationMessage): self { $this->invitationMessage = $invitationMessage; @@ -755,9 +485,6 @@ public function setInvitationMessage(?string $invitationMessage): self return $this; } - /** - * @return string|null - */ public function getInvitationMessage(): ?string { return $this->invitationMessage; diff --git a/Model/TransactionResponse.php b/Model/TransactionResponse.php index 7d5a82c..7a9a530 100644 --- a/Model/TransactionResponse.php +++ b/Model/TransactionResponse.php @@ -7,30 +7,15 @@ class TransactionResponse public const STATE_SUCCESS = 'SUCCESS'; public const STATE_ERROR = 'ERROR'; - /** - * @var string - */ - protected $id; - - /** - * @var string - */ - protected $url; - - /** - * @var string - */ - protected $state; - - /** - * @var string - */ - protected $errorCode; - - /** - * @var string - */ - protected $errorMessage; + protected ?string $id; + + protected ?string $url; + + protected ?string $state; + + protected ?string $errorCode; + + protected ?string $errorMessage; public function __construct() { @@ -41,11 +26,6 @@ public function __construct() $this->errorMessage = null; } - /** - * @param string|null $id - * - * @return self - */ public function setId(?string $id): self { $this->id = $id; @@ -53,19 +33,11 @@ public function setId(?string $id): self return $this; } - /** - * @return string|null - */ public function getId(): ?string { return $this->id; } - /** - * @param string|null $url - * - * @return self - */ public function setUrl(?string $url): self { $this->url = $url; @@ -73,19 +45,11 @@ public function setUrl(?string $url): self return $this; } - /** - * @return string|null - */ public function getUrl(): ?string { return $this->url; } - /** - * @param string|null - * - * @return self - */ public function setState(?string $state): self { $this->state = $state; @@ -93,19 +57,11 @@ public function setState(?string $state): self return $this; } - /** - * @return string|null - */ public function getState(): ?string { return $this->state; } - /** - * @param string|null - * - * @return self - */ public function setErrorCode(?string $errorCode): self { $this->errorCode = $errorCode; @@ -113,19 +69,11 @@ public function setErrorCode(?string $errorCode): self return $this; } - /** - * @return string|null - */ public function getErrorCode(): ?string { return $this->errorCode; } - /** - * @param string|null - * - * @return self - */ public function setErrorMessage(?string $errorMessage): self { $this->errorMessage = $errorMessage; @@ -133,9 +81,6 @@ public function setErrorMessage(?string $errorMessage): self return $this; } - /** - * @return string|null - */ public function getErrorMessage(): ?string { return $this->errorMessage; diff --git a/Model/ValidationRequest.php b/Model/ValidationRequest.php index 80072b7..a25d734 100644 --- a/Model/ValidationRequest.php +++ b/Model/ValidationRequest.php @@ -13,36 +13,15 @@ class ValidationRequest { - /** - * @var IdDocument - */ - protected $idDocument; + protected IdDocument $idDocument; - /** - * @var PersonalInfo - */ - protected $personalInfo; + protected PersonalInfo $personalInfo; - /** - * @var bool - */ - protected $allowManual; + protected bool $allowManual; - /** - * @var null|string - */ - protected $callbackURL; + protected ?string $callbackURL; - public function __construct() - { - $this->allowManual = false; - $this->callbackURL = null; - } - - /** - * @param OptionsResolver $resolver - */ - public static function configureData(OptionsResolver $resolver) + public static function configureData(OptionsResolver $resolver): void { $resolver ->setRequired('idDocument')->setAllowedTypes('idDocument', ['array', IdDocument::class])->setNormalizer('idDocument', function (Options $options, $value) { @@ -65,10 +44,6 @@ public static function configureData(OptionsResolver $resolver) } /** - * @param array $options - * - * @return self - * * @throws UndefinedOptionsException If an option name is undefined * @throws InvalidOptionsException If an option doesn't fulfill the language specified validation rules * @throws MissingOptionsException If a required option is missing @@ -90,19 +65,11 @@ public static function createFromArray(array $options): self ; } - /** - * @return IdDocument - */ public function getIdDocument(): IdDocument { return $this->idDocument; } - /** - * @param IdDocument $idDocument - * - * @return self - */ public function setIdDocument(IdDocument $idDocument): self { $this->idDocument = $idDocument; @@ -110,19 +77,11 @@ public function setIdDocument(IdDocument $idDocument): self return $this; } - /** - * @return PersonalInfo - */ public function getPersonalInfo(): PersonalInfo { return $this->personalInfo; } - /** - * @param PersonalInfo $personalInfo - * - * @return self - */ public function setPersonalInfo(PersonalInfo $personalInfo): self { $this->personalInfo = $personalInfo; @@ -130,19 +89,11 @@ public function setPersonalInfo(PersonalInfo $personalInfo): self return $this; } - /** - * @return bool - */ public function isAllowManual(): bool { return $this->allowManual; } - /** - * @param bool $allowManual - * - * @return self - */ public function setAllowManual(bool $allowManual): self { $this->allowManual = $allowManual; @@ -150,19 +101,11 @@ public function setAllowManual(bool $allowManual): self return $this; } - /** - * @return string|null - */ public function getCallbackURL(): ?string { return $this->callbackURL; } - /** - * @param string|null $callbackURL - * - * @return self - */ public function setCallbackURL(?string $callbackURL): self { $this->callbackURL = $callbackURL; diff --git a/Model/ValidatorResult.php b/Model/ValidatorResult.php index 9e0e3c8..4253724 100644 --- a/Model/ValidatorResult.php +++ b/Model/ValidatorResult.php @@ -17,42 +17,17 @@ class ValidatorResult public const STATUS_VALID = 1; public const STATUS_INVALID = 2; - /** - * @var string - */ - protected $id; + protected string $id; - /** - * @var int - */ - protected $status; + protected int $status; - /** - * @var null|int - */ - protected $reason; - - /** - * @var null|string - */ - protected $reasonMessage; + protected ?int $reason; - /** - * @var null|array - */ - protected $result; + protected ?string $reasonMessage; - public function __construct() - { - $this->reason = null; - $this->reasonMessage = null; - $this->result = null; - } + protected ?array $result; - /** - * @param OptionsResolver $resolver - */ - public static function configureData(OptionsResolver $resolver) + public static function configureData(OptionsResolver $resolver): void { $resolver ->setRequired('id')->setAllowedTypes('id', ['string']) @@ -64,10 +39,6 @@ public static function configureData(OptionsResolver $resolver) } /** - * @param array $options - * - * @return self - * * @throws UndefinedOptionsException If an option name is undefined * @throws InvalidOptionsException If an option doesn't fulfill the language specified validation rules * @throws MissingOptionsException If a required option is missing @@ -90,19 +61,11 @@ public static function createFromArray(array $options): self ; } - /** - * @return string - */ public function getId(): string { return $this->id; } - /** - * @param string $id - * - * @return self - */ public function setId(string $id): self { $this->id = $id; @@ -110,19 +73,11 @@ public function setId(string $id): self return $this; } - /** - * @return int - */ public function getStatus(): int { return $this->status; } - /** - * @param int $status - * - * @return self - */ public function setStatus(int $status): self { $this->status = $status; @@ -130,19 +85,11 @@ public function setStatus(int $status): self return $this; } - /** - * @return int|null - */ public function getReason(): ?int { return $this->reason; } - /** - * @param int|null $reason - * - * @return self - */ public function setReason(?int $reason): self { $this->reason = $reason; @@ -150,19 +97,11 @@ public function setReason(?int $reason): self return $this; } - /** - * @return string|null - */ public function getReasonMessage(): ?string { return $this->reasonMessage; } - /** - * @param string|null $reasonMessage - * - * @return self - */ public function setReasonMessage(?string $reasonMessage): self { $this->reasonMessage = $reasonMessage; @@ -170,19 +109,11 @@ public function setReasonMessage(?string $reasonMessage): self return $this; } - /** - * @return array|null - */ public function getResult(): ?array { return $this->result; } - /** - * @param array|null $result - * - * @return self - */ public function setResult(?array $result): self { $this->result = $result; diff --git a/Requester/RegistrationAuthority.php b/Requester/RegistrationAuthority.php index 67d673a..a984bec 100644 --- a/Requester/RegistrationAuthority.php +++ b/Requester/RegistrationAuthority.php @@ -14,20 +14,11 @@ class RegistrationAuthority extends XmlRpcRequester implements RegistrationAuthorityInterface { - /** - * @var LoggerInterface - */ - protected $logger; + protected LoggerInterface $logger; - /** - * @var array - */ - protected $entrypoint; + protected array $entrypoint; - /** - * @var Router - */ - protected $router; + protected Router $router; public function __construct( Encoder $encoder, @@ -42,15 +33,12 @@ public function __construct( parent::__construct($encoder, $clientOptions); } - /** - * @return string; - */ - public function getUrl() + public function getUrl(): string { return $this->entrypoint['ra']; } - private function call(string $method, $args) + private function call(string $method, $args): mixed { $response = null; @@ -88,17 +76,17 @@ public function matchAccount(MatchingFilter $matchingFilter): array return $results; } - public function getCertificateAgreement(string $email) + public function getCertificateAgreement(string $email): mixed { return $this->call('ra.getCertificateAgreement', $email); } - public function revokeCertificate(string $emailOrPhoneNumber) + public function revokeCertificate(string $emailOrPhoneNumber): mixed { return $this->call('ra.revokeCertificate', $emailOrPhoneNumber); } - public function revokeMyCertificate(string $emailOrPhoneNumber) + public function revokeMyCertificate(string $emailOrPhoneNumber): mixed { return $this->call('ra.revokeMyCertificate', $emailOrPhoneNumber); } diff --git a/Requester/RegistrationAuthorityInterface.php b/Requester/RegistrationAuthorityInterface.php index 8c4d595..0a8fb12 100644 --- a/Requester/RegistrationAuthorityInterface.php +++ b/Requester/RegistrationAuthorityInterface.php @@ -41,7 +41,7 @@ public function matchAccount(MatchingFilter $matchingFilter): array; * * @return byte[]|null Certificate */ - public function getCertificateAgreement(string $email); + public function getCertificateAgreement(string $email): mixed; /** * This service allows the admin of an organization to revoke a user’s certifi- @@ -49,14 +49,12 @@ public function getCertificateAgreement(string $email); * * @param string $emailOrPhoneNumber Email or Phone number of User */ - public function revokeCertificate(string $emailOrPhoneNumber); + public function revokeCertificate(string $emailOrPhoneNumber): mixed; /** * This service allows a user to revoke his own certificate. - * - * @param string $emailOrPhoneNumber */ - public function revokeMyCertificate(string $emailOrPhoneNumber); + public function revokeMyCertificate(string $emailOrPhoneNumber): mixed; /** * Sends a validation request in order to validate ID documents with the provided user info @@ -67,20 +65,12 @@ public function revokeMyCertificate(string $emailOrPhoneNumber); * * Optionnaly, a callback URL can be provided. This URL will be requested * when the validation session is completed (i.e. it ended with a final status). - * - * @param ValidationRequest $validationRequest - * - * @return ValidatorResult|null */ public function validate(ValidationRequest $validationRequest): ?ValidatorResult; /** * Retrieves the validation result of the validation session that matches the * given id. - * - * @param string $validationSessionId - * - * @return ValidatorResult|null */ public function getResult(string $validationSessionId): ?ValidatorResult; } diff --git a/Requester/Signer.php b/Requester/Signer.php index 7b4497d..5cd1334 100644 --- a/Requester/Signer.php +++ b/Requester/Signer.php @@ -18,25 +18,13 @@ class Signer extends XmlRpcRequester implements SignerInterface { - /** - * @var LoggerInterface - */ - protected $logger; - - /** - * @var Router - */ - protected $router; - - /** - * @var array - */ - protected $entrypoint; - - /** - * @var array - */ - protected $options; + protected LoggerInterface $logger; + + protected Router $router; + + protected array $entrypoint; + + protected array $options; public function __construct( Encoder $encoder, @@ -54,17 +42,11 @@ public function __construct( parent::__construct($encoder, $clientOptions); } - /** - * @return string; - */ - public function getUrl() + public function getUrl(): string { return $this->entrypoint['sign']; } - /** - * {@inheritdoc} - */ public function initiateTransactionRequest(array $options = []): TransactionRequest { $defaultOptions = []; @@ -125,9 +107,6 @@ public function initiateTransactionRequest(array $options = []): TransactionRequ return $transaction; } - /** - * {@inheritdoc} - */ public function requestTransaction(TransactionRequest $transactionRequest): TransactionResponse { $transactionResponse = new TransactionResponse(); @@ -158,9 +137,6 @@ public function requestTransaction(TransactionRequest $transactionRequest): Tran return $transactionResponse; } - /** - * {@inheritdoc} - */ public function getDocuments(string $documentId): array { $documents = []; @@ -177,9 +153,6 @@ public function getDocuments(string $documentId): array return $documents; } - /** - * {@inheritdoc} - */ public function getDocumentsByCustomId(string $customId): array { $documents = []; @@ -198,9 +171,6 @@ public function getDocumentsByCustomId(string $customId): array return $documents; } - /** - * {@inheritdoc} - */ public function getTransactionInfo(string $transactionId): TransactionInfo { $transactionInfo = new TransactionInfo(); @@ -239,9 +209,6 @@ public function getTransactionInfo(string $transactionId): TransactionInfo return $transactionInfo; } - /** - * {@inheritdoc} - */ public function getTransactionInfoByCustomId(string $customId): TransactionInfo { $transactionInfo = new TransactionInfo(); @@ -279,9 +246,6 @@ public function getTransactionInfoByCustomId(string $customId): TransactionInfo return $transactionInfo; } - /** - * {@inheritdoc} - */ public function relaunchTransaction(string $transactionId): TransactionInfo { $transactionInfo = new TransactionInfo(); @@ -307,9 +271,6 @@ public function relaunchTransaction(string $transactionId): TransactionInfo return $transactionInfo; } - /** - * {@inheritdoc} - */ public function cancelTransaction(string $transactionId): TransactionInfo { $transactionInfo = new TransactionInfo(); @@ -333,9 +294,6 @@ public function cancelTransaction(string $transactionId): TransactionInfo return $transactionInfo; } - /** - * {@inheritdoc} - */ public function sign(Base64 $document): ?string { $response = null; @@ -355,9 +313,6 @@ public function sign(Base64 $document): ?string return $response; } - /** - * {@inheritdoc} - */ public function signWithOptions(Base64 $document, SignOptions $options): ?string { $response = null; diff --git a/Requester/SignerInterface.php b/Requester/SignerInterface.php index f3adc87..5c0c5ce 100644 --- a/Requester/SignerInterface.php +++ b/Requester/SignerInterface.php @@ -11,74 +11,30 @@ interface SignerInterface { - /** - * @param array $options - * - * @return TransactionRequest - */ public function initiateTransactionRequest(array $options = []): TransactionRequest; - /** - * @param TransactionRequest $transactionRequest - * - * @return TransactionResponse - */ public function requestTransaction(TransactionRequest $transactionRequest): TransactionResponse; /** - * @param string $transactionId - * * @return array */ public function getDocuments(string $transactionId): array; /** - * @param string $customId - * * @return array */ public function getDocumentsByCustomId(string $customId): array; - /** - * @param string $transactionId - * - * @return TransactionInfo - */ public function getTransactionInfo(string $transactionId): TransactionInfo; - /** - * @param string $customId - * - * @return TransactionInfo - */ public function getTransactionInfoByCustomId(string $customId): TransactionInfo; - /** - * @param string $transactionId - * - * @return TransactionInfo - */ + public function relaunchTransaction(string $transactionId): TransactionInfo; - /** - * @param string $transactionId - * - * @return TransactionInfo - */ public function cancelTransaction(string $transactionId): TransactionInfo; - /** - * @param Base64 $document - * - * @return string|null - */ public function sign(Base64 $document): ?string; - /** - * @param Base64 $document - * @param SignOptions $options - * - * @return string|null - */ public function signWithOptions(Base64 $document, SignOptions $options): ?string; } diff --git a/Requester/XmlRpcRequester.php b/Requester/XmlRpcRequester.php index a670ea4..8d440cc 100644 --- a/Requester/XmlRpcRequester.php +++ b/Requester/XmlRpcRequester.php @@ -10,16 +10,9 @@ abstract class XmlRpcRequester { - /** - * @var Client - */ - protected $xmlRpcClient; - - /** - * @var Encoder - */ - protected $encoder; + protected Client $xmlRpcClient; + protected Encoder $encoder; public function __construct(Encoder $encoder, array $clientOptions = []) { @@ -31,18 +24,12 @@ public function __construct(Encoder $encoder, array $clientOptions = []) $this->xmlRpcClient->setOption(Client::OPT_RETURN_TYPE, XMLParser::RETURN_PHP); } - /** - * @return string; - */ - abstract public function getUrl(); + abstract public function getUrl(): string; /** - * @param mixed $data - * @param bool $skipNullValue - * * @return Value|array */ - public function flatten($data, bool $skipNullValue = true) + public function flatten(mixed $data, bool $skipNullValue = true): Value|array { $flattenedData = []; @@ -72,13 +59,7 @@ public function flatten($data, bool $skipNullValue = true) return $data; } - /** - * @param mixed $object - * @param bool $skipNullValue - * - * @return array - */ - public function dismount($object, bool $skipNullValue = true): array + public function dismount(mixed $object, bool $skipNullValue = true): array { $rc = new \ReflectionClass($object); $data = []; @@ -102,7 +83,7 @@ protected function send(string $method, $params): mixed return $response->value(); } - protected static function buildRequest(string $method, $params) + protected static function buildRequest(string $method, $params): Request { if (!is_array($params)) { $params = [$params]; From 732fd30ea1c3ae63d177c0ea45ccc8265b211226 Mon Sep 17 00:00:00 2001 From: "celine.c" Date: Mon, 2 Oct 2023 11:08:13 +0200 Subject: [PATCH 3/5] feat: do not autowire Encoder --- Requester/RegistrationAuthority.php | 3 +-- Requester/Signer.php | 3 +-- Requester/XmlRpcRequester.php | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Requester/RegistrationAuthority.php b/Requester/RegistrationAuthority.php index a984bec..a15b7fa 100644 --- a/Requester/RegistrationAuthority.php +++ b/Requester/RegistrationAuthority.php @@ -21,7 +21,6 @@ class RegistrationAuthority extends XmlRpcRequester implements RegistrationAutho protected Router $router; public function __construct( - Encoder $encoder, LoggerInterface $logger, Router $router, array $entrypoint, @@ -30,7 +29,7 @@ public function __construct( $this->logger = $logger; $this->router = $router; $this->entrypoint = $entrypoint; - parent::__construct($encoder, $clientOptions); + parent::__construct($clientOptions); } public function getUrl(): string diff --git a/Requester/Signer.php b/Requester/Signer.php index 5cd1334..bfb3e55 100644 --- a/Requester/Signer.php +++ b/Requester/Signer.php @@ -27,7 +27,6 @@ class Signer extends XmlRpcRequester implements SignerInterface protected array $options; public function __construct( - Encoder $encoder, LoggerInterface $logger, Router $router, array $entrypoint, @@ -39,7 +38,7 @@ public function __construct( $this->entrypoint = $entrypoint; $this->options = $options; - parent::__construct($encoder, $clientOptions); + parent::__construct($clientOptions); } public function getUrl(): string diff --git a/Requester/XmlRpcRequester.php b/Requester/XmlRpcRequester.php index 8d440cc..9340893 100644 --- a/Requester/XmlRpcRequester.php +++ b/Requester/XmlRpcRequester.php @@ -14,9 +14,9 @@ abstract class XmlRpcRequester protected Encoder $encoder; - public function __construct(Encoder $encoder, array $clientOptions = []) + public function __construct(array $clientOptions = []) { - $this->encoder = $encoder; + $this->encoder = new Encoder(); $this->xmlRpcClient = new Client($this->getUrl()); foreach ($clientOptions as $name => $value) { $this->xmlRpcClient->setOption($name, $value); From 6c6844fc37545cd8e6b2aacd07abccbb9367fde1 Mon Sep 17 00:00:00 2001 From: "celine.c" Date: Mon, 2 Oct 2023 12:34:27 +0200 Subject: [PATCH 4/5] refacto: add constructor to all models --- Model/CertificateInfo.php | 7 +++++++ Model/DocSignatureField.php | 7 +++++++ Model/Document.php | 20 +++++++++++++++--- Model/IdDocument.php | 17 ++++++++++++---- Model/InitiatorInfo.php | 7 +++++++ Model/MatchingFilter.php | 15 +++++++++++--- Model/MatchingResult.php | 12 +++++++++++ Model/PersonalInfo.php | 17 +++++++++++----- Model/RaCertificateInfo.php | 20 +++++++++++++----- Model/RedirectionConfig.php | 6 ++++++ Model/RegistrationRequest.php | 6 ++++++ Model/SepaData.php | 38 +++++++++++++++++++++++------------ Model/SepaThirdParty.php | 28 +++++++++++++++++++------- Model/SignOptions.php | 11 ++++++++++ Model/SignatureField.php | 20 ++++++++++++------ Model/Signer.php | 24 ++++++++++++++++++++++ Model/SignerInfo.php | 20 ++++++++++++++++++ Model/TransactionFilter.php | 15 ++++++++++++++ Model/TransactionRequest.php | 29 ++++++++++++++++++++++++++ Model/ValidationRequest.php | 18 ++++++++++++----- Model/ValidatorResult.php | 17 ++++++++++++---- Requester/XmlRpcRequester.php | 2 +- 22 files changed, 300 insertions(+), 56 deletions(-) diff --git a/Model/CertificateInfo.php b/Model/CertificateInfo.php index a8fcb6e..34a4af4 100644 --- a/Model/CertificateInfo.php +++ b/Model/CertificateInfo.php @@ -18,6 +18,13 @@ class CertificateInfo protected ?string $serial; + public function __construct() + { + $this->subject = null; + $this->issuer = null; + $this->serial = null; + } + public static function configureData(OptionsResolver $resolver): void { $resolver diff --git a/Model/DocSignatureField.php b/Model/DocSignatureField.php index 445c1a3..8a69b67 100644 --- a/Model/DocSignatureField.php +++ b/Model/DocSignatureField.php @@ -19,6 +19,13 @@ class DocSignatureField extends SignatureField protected ?Base64 $image; + public function __construct() + { + $this->patternName = null; + $this->label = null; + $this->image = null; + } + public static function configureData(OptionsResolver $resolver): void { parent::configureData($resolver); diff --git a/Model/Document.php b/Model/Document.php index bc872e6..62fc279 100644 --- a/Model/Document.php +++ b/Model/Document.php @@ -16,7 +16,7 @@ class Document { protected ?int $id; - protected ?string $documentType; + protected string $documentType; protected ?Base64 $content; @@ -37,6 +37,20 @@ class Document protected ?SepaData $sepaData; + public function __construct() + { + $this->id = null; + $this->documentType = 'pdf'; + $this->content = null; + $this->url = null; + $this->fileName = null; + $this->signatureFields = null; + $this->checkBoxTexts = null; + $this->metaData = null; + $this->title = null; + $this->sepaData = null; + } + public static function configureData(OptionsResolver $resolver): void { $resolver @@ -126,14 +140,14 @@ public function getId(): ?int return $this->id; } - public function setDocumentType(?string $documentType): self + public function setDocumentType(string $documentType): self { $this->documentType = $documentType; return $this; } - public function getDocumentType(): ?string + public function getDocumentType(): string { return $this->documentType; } diff --git a/Model/IdDocument.php b/Model/IdDocument.php index 31e6958..3e57543 100644 --- a/Model/IdDocument.php +++ b/Model/IdDocument.php @@ -26,6 +26,15 @@ class IdDocument protected int $type; + /** + * @param Base64[] $photos + */ + public function __construct(array $photos, int $type) + { + $this->photos = $photos; + $this->type = $type; + } + /** * @throws \UnexpectedValueException */ @@ -73,10 +82,10 @@ public static function createFromArray(array $options): IdDocument self::configureData($resolver); $resolvedOptions = $resolver->resolve($options); - return (new self()) - ->setPhotos($resolvedOptions['photos']) - ->setType($resolvedOptions['type']) - ; + return (new self( + $resolvedOptions['photos'], + $resolvedOptions['type'] + )); } /** diff --git a/Model/InitiatorInfo.php b/Model/InitiatorInfo.php index 051c6dc..4d76f23 100644 --- a/Model/InitiatorInfo.php +++ b/Model/InitiatorInfo.php @@ -18,6 +18,13 @@ class InitiatorInfo protected ?string $lastName; + public function __construct() + { + $this->email = null; + $this->firstName = null; + $this->lastName = null; + } + public static function configureData(OptionsResolver $resolver): void { $resolver diff --git a/Model/MatchingFilter.php b/Model/MatchingFilter.php index 070e98f..8af160d 100644 --- a/Model/MatchingFilter.php +++ b/Model/MatchingFilter.php @@ -20,6 +20,14 @@ class MatchingFilter protected ?string $email; + public function __construct(string $firstname, string $lastname) + { + $this->firstname = $firstname; + $this->lastname = $lastname; + $this->mobile = null; + $this->email = null; + } + public static function configureData(OptionsResolver $resolver): void { $resolver @@ -44,9 +52,10 @@ public static function createFromArray(array $options): self self::configureData($resolver); $resolvedOptions = $resolver->resolve($options); - return (new self()) - ->setFirstname($resolvedOptions['firstname']) - ->setLastname($resolvedOptions['lastname']) + return (new self( + $resolvedOptions['firstname'], + $resolvedOptions['lastname'], + )) ->setMobile($resolvedOptions['mobile']) ->setEmail($resolvedOptions['email']) ; diff --git a/Model/MatchingResult.php b/Model/MatchingResult.php index 1e25f9b..72bda49 100644 --- a/Model/MatchingResult.php +++ b/Model/MatchingResult.php @@ -37,6 +37,18 @@ class MatchingResult protected ?\DateTime $expirationDate; + public function __construct() + { + $this->firstname = null; + $this->lastname = null; + $this->mobile = null; + $this->email = null; + $this->certificateLevel = null; + $this->certificateStatus = null; + $this->certificateInfo = null; + $this->expirationDate = null; + } + public static function configureData(OptionsResolver $resolver): void { $resolver diff --git a/Model/PersonalInfo.php b/Model/PersonalInfo.php index af9207b..f8dfa37 100644 --- a/Model/PersonalInfo.php +++ b/Model/PersonalInfo.php @@ -18,6 +18,13 @@ class PersonalInfo protected \DateTimeInterface $birthDate; + public function __construct(string $firstname, string $lastname, \DateTimeInterface $birthDate) + { + $this->firstname = $firstname; + $this->lastname = $lastname; + $this->birthDate = $birthDate; + } + public static function configureData(OptionsResolver $resolver): void { $resolver @@ -41,11 +48,11 @@ public static function createFromArray(array $options): self self::configureData($resolver); $resolvedOptions = $resolver->resolve($options); - return (new self()) - ->setFirstname($resolvedOptions['firstname']) - ->setLastname($resolvedOptions['lastname']) - ->setBirthDate($resolvedOptions['birthDate']) - ; + return (new self( + $resolvedOptions['firstname'], + $resolvedOptions['lastname'], + $resolvedOptions['birthDate'], + )); } public function getFirstname(): string diff --git a/Model/RaCertificateInfo.php b/Model/RaCertificateInfo.php index fe2e5b8..a25093a 100644 --- a/Model/RaCertificateInfo.php +++ b/Model/RaCertificateInfo.php @@ -23,6 +23,16 @@ class RaCertificateInfo */ protected array $chain; + /** + * @param Base64[] $chain + */ + public function __construct(string $subjectDN, string $serialNumber, array $chain) + { + $this->subjectDN = $subjectDN; + $this->serialNumber = $serialNumber; + $this->chain = $chain; + } + /** * @throws \UnexpectedValueException */ @@ -62,11 +72,11 @@ public static function createFromArray(array $options): self $resolvedOptions = $resolver->resolve($options); - return (new self()) - ->setSubjectDN($resolvedOptions['subjectDN']) - ->setSerialNumber($resolvedOptions['serialNumber']) - ->setChain($resolvedOptions['chain']) - ; + return (new self( + $resolvedOptions['subjectDN'], + $resolvedOptions['serialNumber'], + $resolvedOptions['chain'], + )); } public function getSubjectDN(): string diff --git a/Model/RedirectionConfig.php b/Model/RedirectionConfig.php index 58f34a6..fd7cab7 100644 --- a/Model/RedirectionConfig.php +++ b/Model/RedirectionConfig.php @@ -16,6 +16,12 @@ class RedirectionConfig protected ?string $displayName; + public function __construct() + { + $this->URL = null; + $this->displayName = null; + } + /** * @param OptionsResolver */ diff --git a/Model/RegistrationRequest.php b/Model/RegistrationRequest.php index 188efb9..530f4f3 100644 --- a/Model/RegistrationRequest.php +++ b/Model/RegistrationRequest.php @@ -20,6 +20,12 @@ class RegistrationRequest protected ?string $type; + public function __construct() + { + $this->documents = []; + $this->type = null; + } + public static function configureData(OptionsResolver $resolver): void { $resolver diff --git a/Model/SepaData.php b/Model/SepaData.php index c9aa9b5..27ec6ac 100644 --- a/Model/SepaData.php +++ b/Model/SepaData.php @@ -27,10 +27,22 @@ class SepaData protected SepaThirdParty $creditor; - public function __construct() - { - $this->debtor = []; - $this->creditor = []; + public function __construct( + string $rum, + string $ics, + string $iban, + string $bic, + bool $recuring, + SepaThirdParty $debtor, + SepaThirdParty $creditor + ) { + $this->rum = $rum; + $this->ics = $ics; + $this->iban = $iban; + $this->bic = $bic; + $this->recuring = $recuring; + $this->debtor = $debtor; + $this->creditor = $creditor; } public static function configureData(OptionsResolver $resolver): void @@ -72,15 +84,15 @@ public static function createFromArray(array $options): self self::configureData($resolver); $resolvedOptions = $resolver->resolve($options); - return (new self()) - ->setRum($resolvedOptions['rum']) - ->setIcs($resolvedOptions['ics']) - ->setIban($resolvedOptions['iban']) - ->setBic($resolvedOptions['bic']) - ->setRecuring($resolvedOptions['recurring']) - ->setDebtor($resolvedOptions['debtor']) - ->setCreditor($resolvedOptions['creditor']) - ; + return (new self( + $resolvedOptions['rum'], + $resolvedOptions['ics'], + $resolvedOptions['iban'], + $resolvedOptions['bic'], + $resolvedOptions['recurring'], + $resolvedOptions['debtor'], + $resolvedOptions['creditor'], + )); } public function setRum(string $rum): self diff --git a/Model/SepaThirdParty.php b/Model/SepaThirdParty.php index 48dae7b..3174d27 100644 --- a/Model/SepaThirdParty.php +++ b/Model/SepaThirdParty.php @@ -22,6 +22,20 @@ class SepaThirdParty protected string $country; + public function __construct( + string $name, + string $address, + string $postalCode, + string $city, + string $country, + ) { + $this->name = $name; + $this->address = $address; + $this->postalCode = $postalCode; + $this->city = $city; + $this->country = $country; + } + public static function configureData(OptionsResolver $resolver): void { $resolver @@ -47,13 +61,13 @@ public static function createFromArray(array $options): SepaThirdParty self::configureData($resolver); $resolvedOptions = $resolver->resolve($options); - return (new self()) - ->setName($resolvedOptions['name']) - ->setAddress($resolvedOptions['address']) - ->setPostalCode($resolvedOptions['postalCode']) - ->setCity($resolvedOptions['city']) - ->setCountry($resolvedOptions['country']) - ; + return (new self( + $resolvedOptions['name'], + $resolvedOptions['address'], + $resolvedOptions['postalCode'], + $resolvedOptions['city'], + $resolvedOptions['country'] + )); } public function setName(string $name): self diff --git a/Model/SignOptions.php b/Model/SignOptions.php index aea2329..f9b2c0f 100644 --- a/Model/SignOptions.php +++ b/Model/SignOptions.php @@ -31,6 +31,17 @@ class SignOptions protected ?string $patternName; + public function __construct() + { + $this->profile = 'default'; + $this->signatureField = null; + $this->reason = null; + $this->location = null; + $this->signatureFormat = self::SINGNATURE_FORMAT_PADES; + $this->language = 'en'; + $this->patternName = null; + } + public static function configureData(OptionsResolver $resolver): void { $resolver diff --git a/Model/SignatureField.php b/Model/SignatureField.php index f15723f..2e712f6 100644 --- a/Model/SignatureField.php +++ b/Model/SignatureField.php @@ -14,7 +14,7 @@ class SignatureField { protected ?string $name; - protected ?int $page; + protected int $page; protected ?int $x; @@ -22,6 +22,15 @@ class SignatureField protected int $signerIndex; + public function __construct(int $signerIndex) + { + $this->signerIndex = $signerIndex; + $this->name = null; + $this->page = 1; + $this->x = null; + $this->y = null; + } + public static function configureData(OptionsResolver $resolver): void { $resolver @@ -29,7 +38,7 @@ public static function configureData(OptionsResolver $resolver): void ->setDefault('page', 1)->setAllowedTypes('page', ['int']) ->setDefault('x', null)->setAllowedTypes('x', ['null', 'int']) ->setDefault('y', null)->setAllowedTypes('y', ['null', 'int']) - ->setRequired('signerIndex')->setAllowedTypes('signerIndex', ['null', 'int']) + ->setRequired('signerIndex')->setAllowedTypes('signerIndex', ['int']) ; } @@ -47,12 +56,11 @@ public static function createFromArray(array $options): self self::configureData($resolver); $resolvedOptions = $resolver->resolve($options); - return (new self()) + return (new self($resolvedOptions['signerIndex'])) ->setName($resolvedOptions['name']) ->setPage($resolvedOptions['page']) ->setX($resolvedOptions['x']) ->setY($resolvedOptions['y']) - ->setSignerIndex($resolvedOptions['signerIndex']) ; } @@ -68,14 +76,14 @@ public function getName(): ?string return $this->name; } - public function setPage(?int $page): self + public function setPage(int $page): self { $this->page = $page; return $this; } - public function getPage(): ?int + public function getPage(): int { return $this->page; } diff --git a/Model/Signer.php b/Model/Signer.php index da9cef3..4ef60bc 100644 --- a/Model/Signer.php +++ b/Model/Signer.php @@ -56,6 +56,30 @@ class Signer protected ?string $invitationMessage; + public function __construct() + { + $this->firstname = null; + $this->lastname = null; + $this->organization = null; + $this->profile = null; + $this->emailAddress = null; + $this->phoneNum = null; + $this->language = 'en'; + $this->role = self::ROLE_SIGNER; + $this->birthDate = null; + $this->universignId = null; + $this->successRedirection = []; + $this->cancelRedirection = []; + $this->failRedirection = []; + $this->certificateType = null; + $this->idDocuments = null; + $this->validationSessionId = null; + $this->redirectPolicy = null; + $this->redirectWait = 5; + $this->autoSendAgreements = null; + $this->invitationMessage = null; + } + public static function configureData(OptionsResolver $resolver): void { $resolver diff --git a/Model/SignerInfo.php b/Model/SignerInfo.php index 37747c5..97b30b9 100644 --- a/Model/SignerInfo.php +++ b/Model/SignerInfo.php @@ -54,6 +54,26 @@ class SignerInfo protected ?array $idDocuments; + public function __construct() + { + $this->status = null; + $this->error = null; + $this->certificateInfo = null; + $this->url = null; + $this->id = null; + $this->email = null; + $this->firstName = null; + $this->lastName = null; + $this->actionDate = null; + $this->refusedDocs = []; + $this->refusalComment = null; + $this->redirectPolicy = null; + $this->redirectWait = null; + $this->redirectPolicy = null; + $this->redirectWait = null; + $this->idDocuments = null; + } + public static function configureData(OptionsResolver $resolver): void { $resolver diff --git a/Model/TransactionFilter.php b/Model/TransactionFilter.php index 87db6f4..874260d 100644 --- a/Model/TransactionFilter.php +++ b/Model/TransactionFilter.php @@ -34,6 +34,21 @@ class TransactionFilter protected ?bool $withAffiliated; + public function __construct() + { + $this->requesterEmail = null; + $this->profile = null; + $this->notBefore = null; + $this->notAfter = null; + $this->startRange = null; + $this->stopRange = null; + $this->signerId = null; + $this->notBeforeCompletion = null; + $this->notAfterCompletion = null; + $this->status = null; + $this->withAffiliated = null; + } + public static function configureData(OptionsResolver $resolver): void { $resolver diff --git a/Model/TransactionRequest.php b/Model/TransactionRequest.php index e008802..b643288 100644 --- a/Model/TransactionRequest.php +++ b/Model/TransactionRequest.php @@ -67,6 +67,35 @@ class TransactionRequest protected ?string $invitationMessage; + public function __construct() + { + $this->profile = null; + $this->customId = null; + $this->signers = []; + $this->documents = []; + $this->mustContactFirstSigner = false; + $this->finalDocSent = false; + $this->finalDocRequesterSent = false; + $this->finalDocObserverSent = false; + $this->description = null; + $this->certificateType = CertificateType::SIMPLE; + $this->language = 'en'; + $this->handwrittenSignatureMode = null; + $this->chainingMode = 'email'; + $this->finalDocCCeMails = null; + $this->autoValidationRedirection = null; + $this->redirectPolicy = 'dashboard'; + $this->redirectWait = 5; + $this->autoSendAgreements = null; + $this->operator = null; + $this->autoSendAgreements = null; + $this->registrationCallbackURL = null; + $this->successRedirection = null; + $this->cancelRedirection = null; + $this->failRedirection = null; + $this->invitationMessage = null; + } + public static function configureData(OptionsResolver $resolver): void { $resolver diff --git a/Model/ValidationRequest.php b/Model/ValidationRequest.php index a25d734..0262000 100644 --- a/Model/ValidationRequest.php +++ b/Model/ValidationRequest.php @@ -21,6 +21,14 @@ class ValidationRequest protected ?string $callbackURL; + public function __construct(IdDocument $idDocument, PersonalInfo $personalInfo, bool $allowManual) + { + $this->idDocument = $idDocument; + $this->personalInfo = $personalInfo; + $this->allowManual = $allowManual; + $this->callbackURL = null; + } + public static function configureData(OptionsResolver $resolver): void { $resolver @@ -57,11 +65,11 @@ public static function createFromArray(array $options): self self::configureData($resolver); $resolvedOptions = $resolver->resolve($options); - return (new self()) - ->setIdDocument($resolvedOptions['idDocument']) - ->setPersonalInfo($resolvedOptions['personalInfo']) - ->setAllowManual($resolvedOptions['allowManual']) - ->setCallbackURL($resolvedOptions['callbackUrl']) + return (new self( + $resolvedOptions['idDocument'], + $resolvedOptions['personalInfo'], + $resolvedOptions['allowManual'], + ))->setCallbackURL($resolvedOptions['callbackUrl']) ; } diff --git a/Model/ValidatorResult.php b/Model/ValidatorResult.php index 4253724..0e79047 100644 --- a/Model/ValidatorResult.php +++ b/Model/ValidatorResult.php @@ -8,7 +8,6 @@ use Symfony\Component\OptionsResolver\Exception\NoSuchOptionException; use Symfony\Component\OptionsResolver\Exception\OptionDefinitionException; use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException; -use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; class ValidatorResult @@ -27,6 +26,15 @@ class ValidatorResult protected ?array $result; + public function __construct(string $id, int $status) + { + $this->id = $id; + $this->status = $status; + $this->reason = null; + $this->reasonMessage = null; + $this->result = null; + } + public static function configureData(OptionsResolver $resolver): void { $resolver @@ -52,9 +60,10 @@ public static function createFromArray(array $options): self self::configureData($resolver); $resolvedOptions = $resolver->resolve($options); - return (new self()) - ->setId($resolvedOptions['id']) - ->setStatus($resolvedOptions['status']) + return (new self( + $resolvedOptions['id'], + $resolvedOptions['status'], + )) ->setReason($resolvedOptions['reason']) ->setReasonMessage($resolvedOptions['reasonMessage']) ->setResult($resolvedOptions['result']) diff --git a/Requester/XmlRpcRequester.php b/Requester/XmlRpcRequester.php index 9340893..86fb97e 100644 --- a/Requester/XmlRpcRequester.php +++ b/Requester/XmlRpcRequester.php @@ -33,7 +33,7 @@ public function flatten(mixed $data, bool $skipNullValue = true): Value|array { $flattenedData = []; - if (is_object($data) && !$data instanceof Value && !$data instanceof \DateTime) { + if (is_object($data) && !$data instanceof Value && !$data instanceof \DateTimeInterface) { return $this->dismount($data, $skipNullValue); } From 64dedc6a27deea9b64ef586e81675c4099965072 Mon Sep 17 00:00:00 2001 From: "celine.c" Date: Mon, 2 Oct 2023 12:37:10 +0200 Subject: [PATCH 5/5] fix: composer.json --- composer.json | 73 ++++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/composer.json b/composer.json index 5143f16..dfe4da8 100644 --- a/composer.json +++ b/composer.json @@ -1,40 +1,41 @@ { - "name": "mpp/universign-bundle", - "type": "symfony-bundle", - "description": "Symfony Universign Bundle", - "keywords": ["json", "yaml", "api", "xmlrpc"], - "license": "MIT", - "authors": [ - { - "name": "Gabriel BONDAZ", - "email": "gabriel.bondaz@idci-consulting.fr", - "homepage": "https://www.idci-consulting.fr" - }, - { - "name": "Louis-Arnaud CATOIRE", - "email": "la.catoire@itefficience.com", - "homepage": "https://www.itefficience.com" - } - ], - "require": { - "php": ">=7.4", - "symfony/dependency-injection": "^4.0 | ^5.0 | ^6.0", - "symfony/event-dispatcher": "*", - "symfony/framework-bundle": "^4.0 | ^5.0 | ^6.0", - "symfony/monolog-bundle": "*", - "ext-json": "*", - "phpxmlrpc/phpxmlrpc": "^4.9" + "name": "mpp/universign-bundle", + "type": "symfony-bundle", + "description": "Symfony Universign Bundle", + "keywords": ["json", "yaml", "api", "xmlrpc"], + "license": "MIT", + "authors": [ + { + "name": "Gabriel BONDAZ", + "email": "gabriel.bondaz@idci-consulting.fr", + "homepage": "https://www.idci-consulting.fr" }, - "autoload":{ - "psr-4":{ - "Mpp\\UniversignBundle\\": "" - }, - "exclude-from-classmap": [ - "Resources/", - "Tests/" - ] - }, - "require-dev": { - "phpunit/phpunit": "^9.5" + { + "name": "Louis-Arnaud CATOIRE", + "email": "la.catoire@itefficience.com", + "homepage": "https://www.itefficience.com" } + ], + "require": { + "php": ">=7.4", + "symfony/dependency-injection": "^4.0 | ^5.0 | ^6.0", + "symfony/event-dispatcher": "*", + "symfony/framework-bundle": "^4.0 | ^5.0 | ^6.0", + "symfony/monolog-bundle": "*", + "ext-json": "*", + "phpxmlrpc/phpxmlrpc": "^4.9", + "symfony/options-resolver": "^6.3" + }, + "autoload":{ + "psr-4":{ + "Mpp\\UniversignBundle\\": "" + }, + "exclude-from-classmap": [ + "Resources/", + "Tests/" + ] + }, + "require-dev": { + "phpunit/phpunit": "^9.5" } +}