update code style after upgrade rector and phpstan

This commit is contained in:
Julien Fastré 2024-08-28 14:03:26 +02:00
parent bb848746d5
commit 8a374864fa
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
10 changed files with 22 additions and 41 deletions

View File

@ -25,9 +25,9 @@ use Symfony\Component\Routing\Annotation\Route;
class SignatureRequestController class SignatureRequestController
{ {
public function __construct( public function __construct(
private MessageBusInterface $messageBus, private readonly MessageBusInterface $messageBus,
private StoredObjectManagerInterface $storedObjectManager, private readonly StoredObjectManagerInterface $storedObjectManager,
private EntityWorkflowManager $entityWorkflowManager, private readonly EntityWorkflowManager $entityWorkflowManager,
) {} ) {}
#[Route('/api/1.0/document/workflow/{id}/signature-request', name: 'chill_docstore_signature_request')] #[Route('/api/1.0/document/workflow/{id}/signature-request', name: 'chill_docstore_signature_request')]

View File

@ -45,7 +45,7 @@ class StoredObjectVoter extends Voter
$grant = $storedObjectVoter->voteOnAttribute($attributeAsEnum, $subject, $token); $grant = $storedObjectVoter->voteOnAttribute($attributeAsEnum, $subject, $token);
if (false === $grant) { 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; return $grant;

View File

@ -25,7 +25,7 @@ final readonly class PdfSignedMessageSerializer implements SerializerInterface
$body = $encodedEnvelope['body']; $body = $encodedEnvelope['body'];
try { 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) { } catch (\JsonException $e) {
throw new MessageDecodingFailedException('Could not deserialize message', previous: $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'); 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) { if (false === $content) {
throw new MessageDecodingFailedException('Invalid character found in the base64 encoded content'); throw new MessageDecodingFailedException('Invalid character found in the base64 encoded content');

View File

@ -39,13 +39,13 @@ final readonly class RequestPdfSignMessageSerializer implements SerializerInterf
throw new MessageDecodingFailedException('serializer does not support this message'); 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', [ $zoneSignature = $this->denormalizer->denormalize($data['signatureZone'], PDFSignatureZone::class, 'json', [
AbstractNormalizer::GROUPS => ['write'], AbstractNormalizer::GROUPS => ['write'],
]); ]);
$content = base64_decode($data['content'], true); $content = base64_decode((string) $data['content'], true);
if (false === $content) { if (false === $content) {
throw new MessageDecodingFailedException('the content could not be converted from base64 encoding'); throw new MessageDecodingFailedException('the content could not be converted from base64 encoding');

View File

@ -17,7 +17,7 @@ class PDFSignatureZoneParser
{ {
public const ZONE_SIGNATURE_START = 'signature_zone'; public const ZONE_SIGNATURE_START = 'signature_zone';
private Parser $parser; private readonly Parser $parser;
public function __construct( public function __construct(
public float $defaultHeight = 90.0, public float $defaultHeight = 90.0,
@ -48,7 +48,7 @@ class PDFSignatureZoneParser
); );
foreach ($page->getDataTm() as $dataTm) { 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); $zones[] = new PDFSignatureZone($zoneIndex, (float) $dataTm[0][4], (float) $dataTm[0][5], $this->defaultHeight, $this->defaultWidth, $pdfPage);
++$zoneIndex; ++$zoneIndex;
} }

View File

@ -44,8 +44,8 @@ class AbstractStoredObjectVoterTest extends TestCase
// Anonymous class extending the abstract class // Anonymous class extending the abstract class
return new class ($canBeAssociatedWithWorkflow, $repository, $security, $workflowDocumentService) extends AbstractStoredObjectVoter { return new class ($canBeAssociatedWithWorkflow, $repository, $security, $workflowDocumentService) extends AbstractStoredObjectVoter {
public function __construct( public function __construct(
private bool $canBeAssociatedWithWorkflow, private readonly bool $canBeAssociatedWithWorkflow,
private AssociatedEntityToStoredObjectInterface $repository, private readonly AssociatedEntityToStoredObjectInterface $repository,
Security $security, Security $security,
?WorkflowStoredObjectPermissionHelper $workflowDocumentService = null ?WorkflowStoredObjectPermissionHelper $workflowDocumentService = null
) { ) {
@ -101,7 +101,7 @@ class AbstractStoredObjectVoterTest extends TestCase
public function testSupportsOnAttribute(): void public function testSupportsOnAttribute(): void
{ {
list($user, $token, $subject, $entity) = $this->setupMockObjects(); [$user, $token, $subject, $entity] = $this->setupMockObjects();
// Setup mocks for voteOnAttribute method // Setup mocks for voteOnAttribute method
$this->setupMocksForVoteOnAttribute($user, $token, true, $entity, true); $this->setupMocksForVoteOnAttribute($user, $token, true, $entity, true);
@ -112,7 +112,7 @@ class AbstractStoredObjectVoterTest extends TestCase
public function testVoteOnAttributeAllowedAndWorkflowAllowed(): void public function testVoteOnAttributeAllowedAndWorkflowAllowed(): void
{ {
list($user, $token, $subject, $entity) = $this->setupMockObjects(); [$user, $token, $subject, $entity] = $this->setupMockObjects();
// Setup mocks for voteOnAttribute method // Setup mocks for voteOnAttribute method
$this->setupMocksForVoteOnAttribute($user, $token, true, $entity, true); $this->setupMocksForVoteOnAttribute($user, $token, true, $entity, true);
@ -124,7 +124,7 @@ class AbstractStoredObjectVoterTest extends TestCase
public function testVoteOnAttributeNotAllowed(): void 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 // Setup mocks for voteOnAttribute method where isGranted() returns false
$this->setupMocksForVoteOnAttribute($user, $token, false, $entity, true); $this->setupMocksForVoteOnAttribute($user, $token, false, $entity, true);
@ -136,7 +136,7 @@ class AbstractStoredObjectVoterTest extends TestCase
public function testVoteOnAttributeAllowedWorkflowNotAllowed(): void public function testVoteOnAttributeAllowedWorkflowNotAllowed(): void
{ {
list($user, $token, $subject, $entity) = $this->setupMockObjects(); [$user, $token, $subject, $entity] = $this->setupMockObjects();
// Setup mocks for voteOnAttribute method // Setup mocks for voteOnAttribute method
$this->setupMocksForVoteOnAttribute($user, $token, true, $entity, false); $this->setupMocksForVoteOnAttribute($user, $token, true, $entity, false);
@ -152,7 +152,7 @@ class AbstractStoredObjectVoterTest extends TestCase
public function testVoteOnAttributeAllowedWorkflowAllowedToSeeDocument(): void public function testVoteOnAttributeAllowedWorkflowAllowedToSeeDocument(): void
{ {
list($user, $token, $subject, $entity) = $this->setupMockObjects(); [$user, $token, $subject, $entity] = $this->setupMockObjects();
// Setup mocks for voteOnAttribute method // Setup mocks for voteOnAttribute method
$this->setupMocksForVoteOnAttribute($user, $token, true, $entity, false); $this->setupMocksForVoteOnAttribute($user, $token, true, $entity, false);

View File

@ -17,6 +17,7 @@ use Chill\DocStoreBundle\Security\Authorization\StoredObjectVoter\AbstractStored
use Chill\DocStoreBundle\Service\WorkflowStoredObjectPermissionHelper; use Chill\DocStoreBundle\Service\WorkflowStoredObjectPermissionHelper;
use Chill\EventBundle\Entity\Event; use Chill\EventBundle\Entity\Event;
use Chill\EventBundle\Repository\EventRepository; use Chill\EventBundle\Repository\EventRepository;
use Chill\EventBundle\Security\EventVoter;
use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\Security;
class EventStoredObjectVoter extends AbstractStoredObjectVoter class EventStoredObjectVoter extends AbstractStoredObjectVoter

View File

@ -161,8 +161,6 @@ class EntityWorkflowStep
$this->signatures->removeElement($signature); $this->signatures->removeElement($signature);
} }
$signature->detachEntityWorkflowStep();
return $this; return $this;
} }

View File

@ -51,16 +51,12 @@ class EntityWorkflowStepSignature implements TrackCreationInterface, TrackUpdate
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER, nullable: true, options: ['default' => null])] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER, nullable: true, options: ['default' => null])]
private ?int $zoneSignatureIndex = null; private ?int $zoneSignatureIndex = null;
#[ORM\ManyToOne(targetEntity: EntityWorkflowStep::class, inversedBy: 'signatures')]
#[ORM\JoinColumn(nullable: false)]
private ?EntityWorkflowStep $step = null;
public function __construct( public function __construct(
EntityWorkflowStep $step, #[ORM\ManyToOne(targetEntity: EntityWorkflowStep::class, inversedBy: 'signatures')]
private EntityWorkflowStep $step,
User|Person $signer, User|Person $signer,
) { ) {
$this->step = $step; $this->step->addSignature($this);
$step->addSignature($this);
$this->setSigner($signer); $this->setSigner($signer);
} }
@ -139,18 +135,4 @@ class EntityWorkflowStepSignature implements TrackCreationInterface, TrackUpdate
return $this; 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;
}
} }

View File

@ -20,7 +20,7 @@ use Doctrine\Persistence\ObjectRepository;
*/ */
class EntityWorkflowStepSignatureRepository implements ObjectRepository class EntityWorkflowStepSignatureRepository implements ObjectRepository
{ {
private \Doctrine\ORM\EntityRepository $repository; private readonly \Doctrine\ORM\EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager) public function __construct(EntityManagerInterface $entityManager)
{ {