diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b0fb9c3..e097ee1 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -15,7 +15,7 @@ jobs: strategy: matrix: php-version: - - "8.1" + - "7.4" dependencies: - "highest" @@ -53,6 +53,7 @@ jobs: strategy: matrix: php-version: + - "7.4" - "8.1" - "8.2" @@ -62,6 +63,10 @@ jobs: symfony: - "^5.4" - "^6.0" + + exclude: + - php-version: "7.4" + symfony: "^6.0" steps: - name: "Checkout" @@ -96,6 +101,7 @@ jobs: strategy: matrix: php-version: + - "7.4" - "8.1" - "8.2" @@ -105,6 +111,10 @@ jobs: symfony: - "^5.4" - "^6.0" + + exclude: + - php-version: "7.4" + symfony: "^6.0" steps: - name: "Checkout" @@ -136,6 +146,7 @@ jobs: strategy: matrix: php-version: + - "7.4" - "8.1" - "8.2" @@ -146,6 +157,10 @@ jobs: symfony: - "^5.4" - "^6.0" + + exclude: + - php-version: "7.4" + symfony: "^6.0" steps: - name: "Checkout" diff --git a/composer-require-checker.json b/composer-require-checker.json index 21fa35f..507ee90 100644 --- a/composer-require-checker.json +++ b/composer-require-checker.json @@ -15,6 +15,7 @@ "string", "true", "void", + "str_starts_with", "Setono\\Consent\\Consents", "Setono\\ConsentBundle\\SetonoConsentBundle", "Setono\\Consent\\ConsentCheckerInterface" diff --git a/composer.json b/composer.json index 0d35b4b..b4cf957 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,8 @@ } ], "require": { - "php": ">=8.1", + "php": ">=7.4", + "ext-json": "*", "psr/event-dispatcher": "^1.0", "psr/log": "^1.1 || ^2.0 || ^3.0", "setono/google-analytics-measurement-protocol": "^1.0@alpha", @@ -19,7 +20,7 @@ "symfony/config": "^5.4 || ^6.0", "symfony/dependency-injection": "^5.4 || ^6.0", "symfony/event-dispatcher": "^5.4 || ^6.0", - "symfony/event-dispatcher-contracts": "^3.2", + "symfony/event-dispatcher-contracts": "^2.5 || ^3.2", "symfony/http-foundation": "^5.4 || ^6.0", "symfony/http-kernel": "^5.4 || ^6.0", "symfony/messenger": "^5.4 || ^6.0", diff --git a/ecs.php b/ecs.php index b7a347d..782a8ea 100644 --- a/ecs.php +++ b/ecs.php @@ -2,15 +2,17 @@ declare(strict_types=1); -use Symplify\EasyCodingStandard\Config\ECSConfig; +use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use Symplify\EasyCodingStandard\ValueObject\Option; -return static function (ECSConfig $config): void { +return static function (ContainerConfigurator $config): void { $config->import('vendor/sylius-labs/coding-standard/ecs.php'); - $config->paths([ - 'src', 'tests' + $config->parameters()->set(Option::PATHS, [ + 'src', + 'tests', ]); - $config->skip([ - 'tests/Application/var', - 'tests/Application/vendor', + $config->parameters()->set(Option::SKIP, [ + 'tests/Application/var/**', + 'tests/Application/vendor/**', ]); }; diff --git a/rector.php b/rector.php index 5881dc8..b8f240b 100644 --- a/rector.php +++ b/rector.php @@ -12,6 +12,6 @@ ]); $rectorConfig->sets([ - LevelSetList::UP_TO_PHP_81 + LevelSetList::UP_TO_PHP_74 ]); }; diff --git a/src/ConsentChecker/ConsentContractsBasedConsentChecker.php b/src/ConsentChecker/ConsentContractsBasedConsentChecker.php index e241782..8a5102d 100644 --- a/src/ConsentChecker/ConsentContractsBasedConsentChecker.php +++ b/src/ConsentChecker/ConsentContractsBasedConsentChecker.php @@ -11,7 +11,7 @@ */ final class ConsentContractsBasedConsentChecker implements ConsentCheckerInterface { - private readonly BaseConsentCheckerInterface $consentChecker; + private BaseConsentCheckerInterface $consentChecker; public function __construct(?BaseConsentCheckerInterface $consentChecker) { diff --git a/src/Context/GaBasedClientIdContext.php b/src/Context/GaBasedClientIdContext.php index 19b08dd..0fb2cba 100644 --- a/src/Context/GaBasedClientIdContext.php +++ b/src/Context/GaBasedClientIdContext.php @@ -9,13 +9,21 @@ final class GaBasedClientIdContext implements ClientIdContextInterface { - public function __construct(private readonly RequestStack $requestStack) + private RequestStack $requestStack; + + public function __construct(RequestStack $requestStack) { + $this->requestStack = $requestStack; } public function getClientId(): ?string { - $cookieValue = $this->requestStack->getMainRequest()?->cookies->get('_ga'); + $request = $this->requestStack->getMainRequest(); + if (null === $request) { + return null; + } + + $cookieValue = $request->cookies->get('_ga'); if (!is_string($cookieValue)) { return null; } diff --git a/src/Cookie/Ga.php b/src/Cookie/Ga.php index fe4e76c..f576546 100644 --- a/src/Cookie/Ga.php +++ b/src/Cookie/Ga.php @@ -6,8 +6,11 @@ final class Ga { - private function __construct(public readonly string $clientId) + public string $clientId; + + private function __construct(string $clientId) { + $this->clientId = $clientId; } /** diff --git a/src/Event/ClientSideEvent.php b/src/Event/ClientSideEvent.php index 22d8011..5b1b3f2 100644 --- a/src/Event/ClientSideEvent.php +++ b/src/Event/ClientSideEvent.php @@ -12,7 +12,10 @@ */ final class ClientSideEvent extends StoppableEvent { - public function __construct(public readonly Event $event) + public Event $event; + + public function __construct(Event $event) { + $this->event = $event; } } diff --git a/src/Event/ServerSideEvent.php b/src/Event/ServerSideEvent.php index c60ebca..acf0990 100644 --- a/src/Event/ServerSideEvent.php +++ b/src/Event/ServerSideEvent.php @@ -12,12 +12,16 @@ */ final class ServerSideEvent extends StoppableEvent { - public function __construct( - public readonly Event $event, - /** - * If you do not provide a client id, the client id from the _ga cookie will be used - */ - public ?string $clientId = null, - ) { + public Event $event; + + public ?string $clientId = null; + + /** + * @param string|null $clientId If you do not provide a client id, the client id from the _ga cookie will be used + */ + public function __construct(Event $event, string $clientId = null) + { + $this->event = $event; + $this->clientId = $clientId; } } diff --git a/src/EventSubscriber/HandleServerSideEventSubscriber.php b/src/EventSubscriber/HandleServerSideEventSubscriber.php index 983b313..f8cd0a2 100644 --- a/src/EventSubscriber/HandleServerSideEventSubscriber.php +++ b/src/EventSubscriber/HandleServerSideEventSubscriber.php @@ -22,11 +22,15 @@ final class HandleServerSideEventSubscriber implements EventSubscriberInterface, { private LoggerInterface $logger; - public function __construct( - private readonly MessageBusInterface $commandBus, - private readonly PropertyProviderInterface $propertyProvider, - ) { + private MessageBusInterface $commandBus; + + private PropertyProviderInterface $propertyProvider; + + public function __construct(MessageBusInterface $commandBus, PropertyProviderInterface $propertyProvider) + { $this->logger = new NullLogger(); + $this->commandBus = $commandBus; + $this->propertyProvider = $propertyProvider; } public static function getSubscribedEvents(): array diff --git a/src/EventSubscriber/PopulateClientIdSubscriber.php b/src/EventSubscriber/PopulateClientIdSubscriber.php index cb65d1e..25694bc 100644 --- a/src/EventSubscriber/PopulateClientIdSubscriber.php +++ b/src/EventSubscriber/PopulateClientIdSubscriber.php @@ -10,8 +10,11 @@ final class PopulateClientIdSubscriber implements EventSubscriberInterface { - public function __construct(private readonly ClientIdContextInterface $clientIdContext) + private ClientIdContextInterface $clientIdContext; + + public function __construct(ClientIdContextInterface $clientIdContext) { + $this->clientIdContext = $clientIdContext; } public static function getSubscribedEvents(): array diff --git a/src/EventSubscriber/Tag/EventSubscriber.php b/src/EventSubscriber/Tag/EventSubscriber.php index cf079e1..30035d6 100644 --- a/src/EventSubscriber/Tag/EventSubscriber.php +++ b/src/EventSubscriber/Tag/EventSubscriber.php @@ -19,9 +19,12 @@ final class EventSubscriber implements EventSubscriberInterface, LoggerAwareInte { private LoggerInterface $logger; - public function __construct(private readonly TagBagInterface $tagBag) + private TagBagInterface $tagBag; + + public function __construct(TagBagInterface $tagBag) { $this->logger = new NullLogger(); + $this->tagBag = $tagBag; } public static function getSubscribedEvents(): array diff --git a/src/EventSubscriber/Tag/LibrarySubscriber.php b/src/EventSubscriber/Tag/LibrarySubscriber.php index a59ee21..ed09eae 100644 --- a/src/EventSubscriber/Tag/LibrarySubscriber.php +++ b/src/EventSubscriber/Tag/LibrarySubscriber.php @@ -18,11 +18,20 @@ final class LibrarySubscriber implements EventSubscriberInterface { + private TagBagInterface $tagBag; + + private PropertyProviderInterface $propertyProvider; + + private ConsentCheckerInterface $consentChecker; + public function __construct( - private readonly TagBagInterface $tagBag, - private readonly PropertyProviderInterface $propertyProvider, - private readonly ConsentCheckerInterface $consentChecker, + TagBagInterface $tagBag, + PropertyProviderInterface $propertyProvider, + ConsentCheckerInterface $consentChecker ) { + $this->tagBag = $tagBag; + $this->propertyProvider = $propertyProvider; + $this->consentChecker = $consentChecker; } public static function getSubscribedEvents(): array diff --git a/src/Message/Command/SendRequest.php b/src/Message/Command/SendRequest.php index e56e088..380b580 100644 --- a/src/Message/Command/SendRequest.php +++ b/src/Message/Command/SendRequest.php @@ -8,7 +8,10 @@ final class SendRequest implements CommandInterface { - public function __construct(public readonly Request $request) + public Request $request; + + public function __construct(Request $request) { + $this->request = $request; } } diff --git a/src/Message/Handler/SendRequestHandler.php b/src/Message/Handler/SendRequestHandler.php index ca2c6a9..63bbfcb 100644 --- a/src/Message/Handler/SendRequestHandler.php +++ b/src/Message/Handler/SendRequestHandler.php @@ -9,8 +9,11 @@ final class SendRequestHandler { - public function __construct(private readonly ClientInterface $client) + private ClientInterface $client; + + public function __construct(ClientInterface $client) { + $this->client = $client; } public function __invoke(SendRequest $message): void diff --git a/src/Property/Property.php b/src/Property/Property.php index 039d99d..a889010 100644 --- a/src/Property/Property.php +++ b/src/Property/Property.php @@ -8,13 +8,18 @@ final class Property { - public function __construct( - public readonly string $apiSecret, - public readonly string $measurementId, - ) { + public string $apiSecret; + + public string $measurementId; + + public function __construct(string $apiSecret, string $measurementId) + { Assert::true( str_starts_with($measurementId, 'G-'), sprintf('The measurement id does not start with "G-". The given input was: "%s"', $measurementId), ); + + $this->apiSecret = $apiSecret; + $this->measurementId = $measurementId; } } diff --git a/src/Provider/ConfigurationBasedPropertyProvider.php b/src/Provider/ConfigurationBasedPropertyProvider.php index 195f338..cac6f73 100644 --- a/src/Provider/ConfigurationBasedPropertyProvider.php +++ b/src/Provider/ConfigurationBasedPropertyProvider.php @@ -9,7 +9,7 @@ final class ConfigurationBasedPropertyProvider implements PropertyProviderInterface { /** @var list */ - private readonly array $properties; + private array $properties; /** * @param list $properties