diff --git a/src/Bundle/ChillDocStoreBundle/Controller/SignatureRequestController.php b/src/Bundle/ChillDocStoreBundle/Controller/SignatureRequestController.php index 363ecafd4..70d126f78 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/SignatureRequestController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/SignatureRequestController.php @@ -25,9 +25,9 @@ use Symfony\Component\Routing\Annotation\Route; class SignatureRequestController { public function __construct( - private MessageBusInterface $messageBus, - private StoredObjectManagerInterface $storedObjectManager, - private EntityWorkflowManager $entityWorkflowManager, + private readonly MessageBusInterface $messageBus, + private readonly StoredObjectManagerInterface $storedObjectManager, + private readonly EntityWorkflowManager $entityWorkflowManager, ) {} #[Route('/api/1.0/document/workflow/{id}/signature-request', name: 'chill_docstore_signature_request')] diff --git a/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoter.php b/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoter.php index 17ba1f59d..da5e4118b 100644 --- a/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoter.php +++ b/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoter.php @@ -45,7 +45,7 @@ class StoredObjectVoter extends Voter $grant = $storedObjectVoter->voteOnAttribute($attributeAsEnum, $subject, $token); if (false === $grant) { - $this->logger->debug(self::LOG_PREFIX.'deny access by storedObjectVoter', ['stored_object_voter' => get_class($storedObjectVoter)]); + $this->logger->debug(self::LOG_PREFIX.'deny access by storedObjectVoter', ['stored_object_voter' => $storedObjectVoter::class]); } return $grant; diff --git a/src/Bundle/ChillDocStoreBundle/Service/Signature/Driver/BaseSigner/PdfSignedMessageSerializer.php b/src/Bundle/ChillDocStoreBundle/Service/Signature/Driver/BaseSigner/PdfSignedMessageSerializer.php index 082b9b83c..4af4a9504 100644 --- a/src/Bundle/ChillDocStoreBundle/Service/Signature/Driver/BaseSigner/PdfSignedMessageSerializer.php +++ b/src/Bundle/ChillDocStoreBundle/Service/Signature/Driver/BaseSigner/PdfSignedMessageSerializer.php @@ -25,7 +25,7 @@ final readonly class PdfSignedMessageSerializer implements SerializerInterface $body = $encodedEnvelope['body']; try { - $decoded = json_decode($body, true, 512, JSON_THROW_ON_ERROR); + $decoded = json_decode((string) $body, true, 512, JSON_THROW_ON_ERROR); } catch (\JsonException $e) { throw new MessageDecodingFailedException('Could not deserialize message', previous: $e); } @@ -34,7 +34,7 @@ final readonly class PdfSignedMessageSerializer implements SerializerInterface throw new MessageDecodingFailedException('Could not find expected keys: signatureId or content'); } - $content = base64_decode($decoded['content'], true); + $content = base64_decode((string) $decoded['content'], true); if (false === $content) { throw new MessageDecodingFailedException('Invalid character found in the base64 encoded content'); diff --git a/src/Bundle/ChillDocStoreBundle/Service/Signature/Driver/BaseSigner/RequestPdfSignMessageSerializer.php b/src/Bundle/ChillDocStoreBundle/Service/Signature/Driver/BaseSigner/RequestPdfSignMessageSerializer.php index 57314a109..f67cdafcf 100644 --- a/src/Bundle/ChillDocStoreBundle/Service/Signature/Driver/BaseSigner/RequestPdfSignMessageSerializer.php +++ b/src/Bundle/ChillDocStoreBundle/Service/Signature/Driver/BaseSigner/RequestPdfSignMessageSerializer.php @@ -39,13 +39,13 @@ final readonly class RequestPdfSignMessageSerializer implements SerializerInterf throw new MessageDecodingFailedException('serializer does not support this message'); } - $data = json_decode($body, true); + $data = json_decode((string) $body, true); $zoneSignature = $this->denormalizer->denormalize($data['signatureZone'], PDFSignatureZone::class, 'json', [ AbstractNormalizer::GROUPS => ['write'], ]); - $content = base64_decode($data['content'], true); + $content = base64_decode((string) $data['content'], true); if (false === $content) { throw new MessageDecodingFailedException('the content could not be converted from base64 encoding'); diff --git a/src/Bundle/ChillDocStoreBundle/Service/Signature/PDFSignatureZoneParser.php b/src/Bundle/ChillDocStoreBundle/Service/Signature/PDFSignatureZoneParser.php index 082d1afa2..a2526a109 100644 --- a/src/Bundle/ChillDocStoreBundle/Service/Signature/PDFSignatureZoneParser.php +++ b/src/Bundle/ChillDocStoreBundle/Service/Signature/PDFSignatureZoneParser.php @@ -17,7 +17,7 @@ class PDFSignatureZoneParser { public const ZONE_SIGNATURE_START = 'signature_zone'; - private Parser $parser; + private readonly Parser $parser; public function __construct( public float $defaultHeight = 90.0, @@ -48,7 +48,7 @@ class PDFSignatureZoneParser ); foreach ($page->getDataTm() as $dataTm) { - if (str_starts_with($dataTm[1], self::ZONE_SIGNATURE_START)) { + if (str_starts_with((string) $dataTm[1], self::ZONE_SIGNATURE_START)) { $zones[] = new PDFSignatureZone($zoneIndex, (float) $dataTm[0][4], (float) $dataTm[0][5], $this->defaultHeight, $this->defaultWidth, $pdfPage); ++$zoneIndex; } diff --git a/src/Bundle/ChillDocStoreBundle/Tests/Security/Authorization/AbstractStoredObjectVoterTest.php b/src/Bundle/ChillDocStoreBundle/Tests/Security/Authorization/AbstractStoredObjectVoterTest.php index 3f6a5538d..645509439 100644 --- a/src/Bundle/ChillDocStoreBundle/Tests/Security/Authorization/AbstractStoredObjectVoterTest.php +++ b/src/Bundle/ChillDocStoreBundle/Tests/Security/Authorization/AbstractStoredObjectVoterTest.php @@ -44,8 +44,8 @@ class AbstractStoredObjectVoterTest extends TestCase // Anonymous class extending the abstract class return new class ($canBeAssociatedWithWorkflow, $repository, $security, $workflowDocumentService) extends AbstractStoredObjectVoter { public function __construct( - private bool $canBeAssociatedWithWorkflow, - private AssociatedEntityToStoredObjectInterface $repository, + private readonly bool $canBeAssociatedWithWorkflow, + private readonly AssociatedEntityToStoredObjectInterface $repository, Security $security, ?WorkflowStoredObjectPermissionHelper $workflowDocumentService = null ) { @@ -101,7 +101,7 @@ class AbstractStoredObjectVoterTest extends TestCase public function testSupportsOnAttribute(): void { - list($user, $token, $subject, $entity) = $this->setupMockObjects(); + [$user, $token, $subject, $entity] = $this->setupMockObjects(); // Setup mocks for voteOnAttribute method $this->setupMocksForVoteOnAttribute($user, $token, true, $entity, true); @@ -112,7 +112,7 @@ class AbstractStoredObjectVoterTest extends TestCase public function testVoteOnAttributeAllowedAndWorkflowAllowed(): void { - list($user, $token, $subject, $entity) = $this->setupMockObjects(); + [$user, $token, $subject, $entity] = $this->setupMockObjects(); // Setup mocks for voteOnAttribute method $this->setupMocksForVoteOnAttribute($user, $token, true, $entity, true); @@ -124,7 +124,7 @@ class AbstractStoredObjectVoterTest extends TestCase public function testVoteOnAttributeNotAllowed(): void { - list($user, $token, $subject, $entity) = $this->setupMockObjects(); + [$user, $token, $subject, $entity] = $this->setupMockObjects(); // Setup mocks for voteOnAttribute method where isGranted() returns false $this->setupMocksForVoteOnAttribute($user, $token, false, $entity, true); @@ -136,7 +136,7 @@ class AbstractStoredObjectVoterTest extends TestCase public function testVoteOnAttributeAllowedWorkflowNotAllowed(): void { - list($user, $token, $subject, $entity) = $this->setupMockObjects(); + [$user, $token, $subject, $entity] = $this->setupMockObjects(); // Setup mocks for voteOnAttribute method $this->setupMocksForVoteOnAttribute($user, $token, true, $entity, false); @@ -152,7 +152,7 @@ class AbstractStoredObjectVoterTest extends TestCase public function testVoteOnAttributeAllowedWorkflowAllowedToSeeDocument(): void { - list($user, $token, $subject, $entity) = $this->setupMockObjects(); + [$user, $token, $subject, $entity] = $this->setupMockObjects(); // Setup mocks for voteOnAttribute method $this->setupMocksForVoteOnAttribute($user, $token, true, $entity, false); diff --git a/src/Bundle/ChillEventBundle/Security/Authorization/EventStoredObjectVoter.php b/src/Bundle/ChillEventBundle/Security/Authorization/EventStoredObjectVoter.php index 66f54bc6d..16c8caa01 100644 --- a/src/Bundle/ChillEventBundle/Security/Authorization/EventStoredObjectVoter.php +++ b/src/Bundle/ChillEventBundle/Security/Authorization/EventStoredObjectVoter.php @@ -17,6 +17,7 @@ use Chill\DocStoreBundle\Security\Authorization\StoredObjectVoter\AbstractStored use Chill\DocStoreBundle\Service\WorkflowStoredObjectPermissionHelper; use Chill\EventBundle\Entity\Event; use Chill\EventBundle\Repository\EventRepository; +use Chill\EventBundle\Security\EventVoter; use Symfony\Component\Security\Core\Security; class EventStoredObjectVoter extends AbstractStoredObjectVoter diff --git a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php index dde204a85..953fb31b1 100644 --- a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php +++ b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php @@ -161,8 +161,6 @@ class EntityWorkflowStep $this->signatures->removeElement($signature); } - $signature->detachEntityWorkflowStep(); - return $this; } diff --git a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStepSignature.php b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStepSignature.php index 25babc3c6..46c8bb04d 100644 --- a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStepSignature.php +++ b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStepSignature.php @@ -51,16 +51,12 @@ class EntityWorkflowStepSignature implements TrackCreationInterface, TrackUpdate #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER, nullable: true, options: ['default' => null])] private ?int $zoneSignatureIndex = null; - #[ORM\ManyToOne(targetEntity: EntityWorkflowStep::class, inversedBy: 'signatures')] - #[ORM\JoinColumn(nullable: false)] - private ?EntityWorkflowStep $step = null; - public function __construct( - EntityWorkflowStep $step, + #[ORM\ManyToOne(targetEntity: EntityWorkflowStep::class, inversedBy: 'signatures')] + private EntityWorkflowStep $step, User|Person $signer, ) { - $this->step = $step; - $step->addSignature($this); + $this->step->addSignature($this); $this->setSigner($signer); } @@ -139,18 +135,4 @@ class EntityWorkflowStepSignature implements TrackCreationInterface, TrackUpdate return $this; } - - /** - * Detach from the @see{EntityWorkflowStep}. - * - * @internal used internally to remove the current signature - * - * @return $this - */ - public function detachEntityWorkflowStep(): self - { - $this->step = null; - - return $this; - } } diff --git a/src/Bundle/ChillMainBundle/Repository/Workflow/EntityWorkflowStepSignatureRepository.php b/src/Bundle/ChillMainBundle/Repository/Workflow/EntityWorkflowStepSignatureRepository.php index 0e1393242..a057c1660 100644 --- a/src/Bundle/ChillMainBundle/Repository/Workflow/EntityWorkflowStepSignatureRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/Workflow/EntityWorkflowStepSignatureRepository.php @@ -20,7 +20,7 @@ use Doctrine\Persistence\ObjectRepository; */ class EntityWorkflowStepSignatureRepository implements ObjectRepository { - private \Doctrine\ORM\EntityRepository $repository; + private readonly \Doctrine\ORM\EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) {