diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 1ed8f7f..ac22b45 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -9,14 +9,12 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest] - php: [8.1, 8.2] - laravel: [9.*, 10.*] + php: [8.3] + laravel: [11.*] stability: [prefer-stable] include: - - laravel: 9.* - testbench: 7.* - - laravel: 10.* - testbench: 8.* + - laravel: 11.* + testbench: 9.* name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} diff --git a/.gitignore b/.gitignore index 7f670fa..f0efa70 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ /composer.lock /build /.php_cs.cache +/.phpunit.cache diff --git a/composer.json b/composer.json index 8afb495..4ebdddb 100644 --- a/composer.json +++ b/composer.json @@ -22,10 +22,9 @@ "laravel/pint": "^1.10", "mockery/mockery": "^1.4", "nunomaduro/larastan": "^2.0", - "orchestra/testbench": "^7.25|^8.5", - "pestphp/pest": "^1.0", - "phpunit/phpunit": "^9.3", - "vimeo/psalm": "^4.6" + "orchestra/testbench": "^7.25|^8.5|^9.0", + "pestphp/pest": "^2.0", + "vimeo/psalm": "^5.24" }, "autoload": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 6dc15fa..e78ba27 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,39 +1,23 @@ - - - - tests - - - - - ./src - - - - - - - - - - + + + + tests + + + + + + + + + + + + + + + ./src + + diff --git a/phpunit.xml.dist.bak b/phpunit.xml.dist.bak new file mode 100644 index 0000000..6dc15fa --- /dev/null +++ b/phpunit.xml.dist.bak @@ -0,0 +1,39 @@ + + + + + tests + + + + + ./src + + + + + + + + + + + diff --git a/src/Contracts/SegmentServiceContract.php b/src/Contracts/SegmentServiceContract.php index 7872145..cb2dacb 100644 --- a/src/Contracts/SegmentServiceContract.php +++ b/src/Contracts/SegmentServiceContract.php @@ -16,12 +16,12 @@ public function setGlobalContext(array $globalContext): void; /** * @param array $eventData */ - public function track(string $event, array $eventData = null): void; + public function track(string $event, ?array $eventData = null): void; /** * @param array $identifyData */ - public function identify(array $identifyData = null): void; + public function identify(?array $identifyData = null): void; public function forUser(CanBeIdentifiedForSegment $user): PendingUserSegment; diff --git a/src/Facades/Fakes/SegmentFake.php b/src/Facades/Fakes/SegmentFake.php index 041be66..2570f84 100644 --- a/src/Facades/Fakes/SegmentFake.php +++ b/src/Facades/Fakes/SegmentFake.php @@ -49,7 +49,7 @@ public function identify(?array $identifyData = []): void /** * @param array $eventData */ - public function track(string $event, array $eventData = null): void + public function track(string $event, ?array $eventData = null): void { $this->events[] = new SimpleSegmentEvent($this->user, $event, $eventData); } @@ -76,7 +76,7 @@ public function terminate(): void { } - public function assertIdentified(Closure|int $callback = null): void + public function assertIdentified(Closure|int|null $callback = null): void { if (is_numeric($callback)) { $this->assertIdentifiedTimes($callback); @@ -100,7 +100,7 @@ public function assertIdentifiedTimes(int $times = 1): void ); } - public function assertNotIdentified(Closure $callback = null): void + public function assertNotIdentified(?Closure $callback = null): void { PHPUnit::assertCount( 0, $this->identities($callback), @@ -115,7 +115,7 @@ public function assertNothingIdentified(): void PHPUnit::assertEmpty($identities, $identities->count().' events were found unexpectedly.'); } - public function assertTracked(Closure|int $callback = null): void + public function assertTracked(Closure|int|null $callback = null): void { if (is_numeric($callback)) { $this->assertTrackedTimes($callback); @@ -139,7 +139,7 @@ public function assertTrackedTimes(int $times = 1): void ); } - public function assertEventTracked(string $event, Closure|int $callback = null): void + public function assertEventTracked(string $event, Closure|int|null $callback = null): void { PHPUnit::assertTrue( $this->events($callback, $event)->count() > 0, @@ -147,7 +147,7 @@ public function assertEventTracked(string $event, Closure|int $callback = null): ); } - public function assertNotTracked(Closure $callback = null): void + public function assertNotTracked(?Closure $callback = null): void { PHPUnit::assertCount( 0, $this->events($callback), @@ -155,7 +155,7 @@ public function assertNotTracked(Closure $callback = null): void ); } - public function assertEventNotTracked(string $event, Closure|int $callback = null): void + public function assertEventNotTracked(string $event, Closure|int|null $callback = null): void { PHPUnit::assertCount( 0, $this->events($callback, $event), @@ -178,7 +178,7 @@ public function getContext(): ?array return $this->context; } - private function identities(Closure $callback = null): Collection + private function identities(?Closure $callback = null): Collection { $identities = collect($this->identities); @@ -191,7 +191,7 @@ private function identities(Closure $callback = null): Collection return $identities->filter(fn (SimpleSegmentIdentify $identity) => $callback($identity)); } - private function events(Closure $callback = null, string $event = null): Collection + private function events(?Closure $callback = null, ?string $event = null): Collection { $events = collect($this->events); diff --git a/src/PendingUserSegment.php b/src/PendingUserSegment.php index 356ce01..76a82e6 100644 --- a/src/PendingUserSegment.php +++ b/src/PendingUserSegment.php @@ -20,7 +20,7 @@ public function __construct(SegmentServiceContract $service, CanBeIdentifiedForS /** * @param array|null $eventData */ - public function track(string $event, array $eventData = null): void + public function track(string $event, ?array $eventData = null): void { $this->service->push( new SimpleSegmentEvent($this->user, $event, $eventData) @@ -30,7 +30,7 @@ public function track(string $event, array $eventData = null): void /** * @param array|null $identifyData */ - public function identify(array $identifyData = null): void + public function identify(?array $identifyData = null): void { $this->service->push( new SimpleSegmentIdentify($this->user, $identifyData) diff --git a/src/SegmentService.php b/src/SegmentService.php index bcb0071..2c5cd17 100644 --- a/src/SegmentService.php +++ b/src/SegmentService.php @@ -47,7 +47,7 @@ public function setGlobalContext(array $globalContext): void /** * @param array $eventData */ - public function track(string $event, array $eventData = null): void + public function track(string $event, ?array $eventData = null): void { $this->push( new SimpleSegmentEvent($this->globalUser, $event, $eventData) @@ -57,7 +57,7 @@ public function track(string $event, array $eventData = null): void /** * @param array $identifyData */ - public function identify(array $identifyData = null): void + public function identify(?array $identifyData = null): void { $this->push( new SimpleSegmentIdentify($this->globalUser, $identifyData) diff --git a/src/ValueObjects/SegmentPayload.php b/src/ValueObjects/SegmentPayload.php index f07d425..ab98fec 100644 --- a/src/ValueObjects/SegmentPayload.php +++ b/src/ValueObjects/SegmentPayload.php @@ -19,7 +19,7 @@ public function __construct( public readonly SegmentPayloadType $type, public readonly ?string $event = null, public readonly array $data = [], - DateTime $timestamp = null + ?DateTime $timestamp = null ) { $this->timestamp = $timestamp ?: new DateTime(); $this->timestamp->setTimezone(new DateTimeZone('UTC'));