Skip to content

Commit

Permalink
Merge pull request #11 from Setono/allow-php74
Browse files Browse the repository at this point in the history
Allow PHP 7.4
  • Loading branch information
loevgaard authored May 19, 2023
2 parents 515940d + b752774 commit 966b81a
Show file tree
Hide file tree
Showing 18 changed files with 106 additions and 39 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
php-version:
- "8.1"
- "7.4"

dependencies:
- "highest"
Expand Down Expand Up @@ -53,6 +53,7 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.1"
- "8.2"

Expand All @@ -62,6 +63,10 @@ jobs:
symfony:
- "^5.4"
- "^6.0"

exclude:
- php-version: "7.4"
symfony: "^6.0"

steps:
- name: "Checkout"
Expand Down Expand Up @@ -96,6 +101,7 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.1"
- "8.2"

Expand All @@ -105,6 +111,10 @@ jobs:
symfony:
- "^5.4"
- "^6.0"

exclude:
- php-version: "7.4"
symfony: "^6.0"

steps:
- name: "Checkout"
Expand Down Expand Up @@ -136,6 +146,7 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.1"
- "8.2"

Expand All @@ -146,6 +157,10 @@ jobs:
symfony:
- "^5.4"
- "^6.0"

exclude:
- php-version: "7.4"
symfony: "^6.0"

steps:
- name: "Checkout"
Expand Down
1 change: 1 addition & 0 deletions composer-require-checker.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"string",
"true",
"void",
"str_starts_with",
"Setono\\Consent\\Consents",
"Setono\\ConsentBundle\\SetonoConsentBundle",
"Setono\\Consent\\ConsentCheckerInterface"
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
16 changes: 9 additions & 7 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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/**',
]);
};
2 changes: 1 addition & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
]);

$rectorConfig->sets([
LevelSetList::UP_TO_PHP_81
LevelSetList::UP_TO_PHP_74
]);
};
2 changes: 1 addition & 1 deletion src/ConsentChecker/ConsentContractsBasedConsentChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
final class ConsentContractsBasedConsentChecker implements ConsentCheckerInterface
{
private readonly BaseConsentCheckerInterface $consentChecker;
private BaseConsentCheckerInterface $consentChecker;

public function __construct(?BaseConsentCheckerInterface $consentChecker)
{
Expand Down
12 changes: 10 additions & 2 deletions src/Context/GaBasedClientIdContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 4 additions & 1 deletion src/Cookie/Ga.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
5 changes: 4 additions & 1 deletion src/Event/ClientSideEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
18 changes: 11 additions & 7 deletions src/Event/ServerSideEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
12 changes: 8 additions & 4 deletions src/EventSubscriber/HandleServerSideEventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/EventSubscriber/PopulateClientIdSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/EventSubscriber/Tag/EventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 12 additions & 3 deletions src/EventSubscriber/Tag/LibrarySubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/Message/Command/SendRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
5 changes: 4 additions & 1 deletion src/Message/Handler/SendRequestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 9 additions & 4 deletions src/Property/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
2 changes: 1 addition & 1 deletion src/Provider/ConfigurationBasedPropertyProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
final class ConfigurationBasedPropertyProvider implements PropertyProviderInterface
{
/** @var list<array{api_secret: string, measurement_id: string}> */
private readonly array $properties;
private array $properties;

/**
* @param list<array{api_secret: string, measurement_id: string}> $properties
Expand Down

0 comments on commit 966b81a

Please sign in to comment.