Skip to content

Commit

Permalink
Laravel 11 support (#56)
Browse files Browse the repository at this point in the history
* Added Laravel 11 support

* Pint

* Fix styling

* Update workflows and drop Laravel 9 support

* Use testbench 9 for Laravel 11

* Update phpunit

* Updated collision

* update composer dependencies, pint

* update composer dependencies, pint

* Fix styling

* update to non-static reference in test files

* Fix styling

* Use deprecated analytics client and add laravel 10 + php8.1 support

* Updated actions versions

* Using pint 1.18.1

* Improved typehinting

* Fix styling

* Trigger CI

* Trigger CI

---------

Co-authored-by: Plytas <[email protected]>
Co-authored-by: Garrett Massey <[email protected]>
Co-authored-by: gtmassey <[email protected]>
  • Loading branch information
4 people authored Nov 13, 2024
1 parent 1cdbc19 commit 58b9fa2
Show file tree
Hide file tree
Showing 44 changed files with 184 additions and 154 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/PHPStan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: phpstan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/laravel-pint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Fix PHP code style issues
uses: aglipanci/laravel-pint-action@2.0.0
uses: aglipanci/laravel-pint-action@latest
with:
pintVersion: 1.6.0
pintVersion: 1.18.1

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,23 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.1, 8.2]
laravel: [9.*, 10.*]
php: [8.1, 8.2, 8.3]
laravel: [10.*, 11.*]
stability: [prefer-stable]
exclude:
- php: 8.1
laravel: 11.*
include:
- laravel: 9.*
testbench: 7.*
- laravel: 10.*
testbench: 8.*
- laravel: 11.*
testbench: 9.*

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: main

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ phpunit.xml
/vendor/
.idea
.phpunit.result.cache
.phpunit.cache
/build
/coverage
24 changes: 14 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,37 @@
"name": "Garrett Massey",
"email": "[email protected]",
"role": "Creator"
},
{
"name": "Vytautas Smilingis",
"role": "Contributor"
}
],
"homepage": "https://github.com/gtmassey/laravel-analytics/",
"keywords": [
"Laravel",
"Analytics",
"Google Analytics"
"Google Analytics"
],
"require": {
"php": "^8.1",
"google/analytics-data": "^0.9.0",
"gtmassey/period": "^1.0",
"illuminate/support": "^9.0|^10.0",
"php": "^8.1|^8.2|^8.3",
"google/analytics-data": "^v0.9.0",
"gtmassey/period": "^1.2.0",
"illuminate/support": "^10.0|^11.0",
"nesbot/carbon": "^2.63",
"spatie/laravel-data": "^2.0",
"spatie/laravel-data": "^3.12",
"spatie/laravel-package-tools": "^1.13"
},
"require-dev": {
"larastan/larastan": "^2.9",
"laravel/pint": "^1.6",
"nunomaduro/collision": "^6.4",
"nunomaduro/larastan": "^2.4.1",
"orchestra/testbench": "^7.15|^8.0.3",
"nunomaduro/collision": "^7.11.0|^v8.5.0",
"orchestra/testbench": "^v8.27.2|^9.5",
"phpstan/extension-installer": "^1.2",
"phpstan/phpstan-deprecation-rules": "^1.1.2",
"phpstan/phpstan-mockery": "^1.1.1",
"phpstan/phpstan-phpunit": "^1.3.7",
"phpunit/phpunit": "^9.6.3",
"phpunit/phpunit": "^10",
"rregeer/phpunit-coverage-check": "^0.3.1"
},
"autoload": {
Expand Down
1 change: 0 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ parameters:

checkOctaneCompatibility: true
checkModelProperties: true
checkMissingIterableValueType: false
52 changes: 18 additions & 34 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,36 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
executionOrder="random"
failOnWarning="true"
failOnRisky="true"
failOnEmptyTestSuite="true"
beStrictAboutOutputDuringTests="true"
verbose="true"
>
<testsuites>
<testsuite name="Analytics Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" executionOrder="random" failOnWarning="true" failOnRisky="true" failOnEmptyTestSuite="true" beStrictAboutOutputDuringTests="true" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Analytics Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
36 changes: 36 additions & 0 deletions phpunit.xml.dist.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
executionOrder="random"
failOnWarning="true"
failOnRisky="true"
failOnEmptyTestSuite="true"
beStrictAboutOutputDuringTests="true"
verbose="true"
>
<testsuites>
<testsuite name="Analytics Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
</phpunit>
4 changes: 2 additions & 2 deletions src/Analytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function setDimensions(Closure $callback): static
*/
public function dimensionFilter(Closure $callback): static
{
$this->requestData->dimensionFilter = $callback(new FilterExpression());
$this->requestData->dimensionFilter = $callback(new FilterExpression);

return $this;
}
Expand All @@ -93,7 +93,7 @@ public function dimensionFilter(Closure $callback): static
*/
public function metricFilter(Closure $callback): static
{
$this->requestData->metricFilter = $callback(new FilterExpression());
$this->requestData->metricFilter = $callback(new FilterExpression);

return $this;
}
Expand Down
8 changes: 8 additions & 0 deletions src/Credentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
class Credentials
{
/**
* @return array<string, string>|null
*
* @throws InvalidCredentialsJsonStringException
* @throws InvalidCredentialsFileException
* @throws InvalidCredentialsArrayException
Expand All @@ -33,6 +35,8 @@ public function parse(): ?array
}

/**
* @return array<string, string>
*
* @throws InvalidCredentialsFileException
*/
private function credentialsFile(mixed $file): array
Expand All @@ -57,6 +61,8 @@ private function credentialsFile(mixed $file): array
}

/**
* @return array<string, string>
*
* @throws InvalidCredentialsJsonStringException
*/
private function credentialsJson(mixed $json): array
Expand All @@ -75,6 +81,8 @@ private function credentialsJson(mixed $json): array
}

/**
* @return array<string, string>
*
* @throws InvalidCredentialsArrayException
*/
private function credentialsArray(): array
Expand Down
2 changes: 1 addition & 1 deletion src/Request/Dimensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Dimensions

public function __construct()
{
$this->dimensions = new Collection();
$this->dimensions = new Collection;
}

public function count(): int
Expand Down
2 changes: 1 addition & 1 deletion src/Request/Filters/AndGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function __construct(
Closure $expression,
private readonly FilterExpressionField $field = FilterExpressionField::AND_GROUP,
) {
$this->expression = $expression(new FilterExpressionList());
$this->expression = $expression(new FilterExpressionList);
}

public function toRequest(): BaseFilterExpressionList
Expand Down
3 changes: 1 addition & 2 deletions src/Request/Filters/BetweenFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ public function __construct(
private readonly float|int $max = 0,
private readonly NumericValueType $valueType = NumericValueType::INTEGER,
private readonly FilterField $field = FilterField::BETWEEN_FILTER,
) {
}
) {}

public function toRequest(): BaseBetweenFilter
{
Expand Down
3 changes: 3 additions & 0 deletions src/Request/Filters/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ public function partialRegexp(string $value, bool $caseSensitive = false): stati
return $this;
}

/**
* @param list<string> $values
*/
public function inList(array $values, bool $caseSensitive = false): static
{
$this->expression = new InListFilter(
Expand Down
17 changes: 8 additions & 9 deletions src/Request/Filters/FilterExpressionList.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ class FilterExpressionList
{
public function __construct(
/** @var Collection<int, FilterExpression> */
private readonly Collection $expressions = new Collection(),
) {
}
private readonly Collection $expressions = new Collection,
) {}

/**
* @param Closure(FilterExpressionList): FilterExpressionList $filterExpressionList
*/
public function andGroup(Closure $filterExpressionList): static
{
$this->expressions->push((new FilterExpression())->andGroup($filterExpressionList));
$this->expressions->push((new FilterExpression)->andGroup($filterExpressionList));

return $this;
}
Expand All @@ -30,7 +29,7 @@ public function andGroup(Closure $filterExpressionList): static
*/
public function orGroup(Closure $filterExpressionList): static
{
$this->expressions->push((new FilterExpression())->orGroup($filterExpressionList));
$this->expressions->push((new FilterExpression)->orGroup($filterExpressionList));

return $this;
}
Expand All @@ -40,7 +39,7 @@ public function orGroup(Closure $filterExpressionList): static
*/
public function not(Closure $filterExpression): static
{
$this->expressions->push((new FilterExpression())->not($filterExpression));
$this->expressions->push((new FilterExpression)->not($filterExpression));

return $this;
}
Expand All @@ -50,7 +49,7 @@ public function not(Closure $filterExpression): static
*/
public function filter(string $dimension, Closure $filter): static
{
$this->expressions->push((new FilterExpression())->filter($dimension, $filter));
$this->expressions->push((new FilterExpression)->filter($dimension, $filter));

return $this;
}
Expand All @@ -62,7 +61,7 @@ public function filter(string $dimension, Closure $filter): static
*/
public function filterDimension(Closure $dimensionsCallback, Closure $filter): static
{
$this->expressions->push((new FilterExpression())->filterDimension($dimensionsCallback, $filter));
$this->expressions->push((new FilterExpression)->filterDimension($dimensionsCallback, $filter));

return $this;
}
Expand All @@ -74,7 +73,7 @@ public function filterDimension(Closure $dimensionsCallback, Closure $filter): s
*/
public function filterMetric(Closure $metricsCallback, Closure $filter): static
{
$this->expressions->push((new FilterExpression())->filterMetric($metricsCallback, $filter));
$this->expressions->push((new FilterExpression)->filterMetric($metricsCallback, $filter));

return $this;
}
Expand Down
6 changes: 4 additions & 2 deletions src/Request/Filters/InListFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@

class InListFilter implements FilterContract
{
/**
* @param list<string> $values
*/
public function __construct(
public array $values = [],
public bool $caseSensitive = false,
private readonly FilterField $field = FilterField::IN_LIST_FILTER,
) {
}
) {}

public function field(): FilterField
{
Expand Down
2 changes: 1 addition & 1 deletion src/Request/Filters/NotExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function __construct(
Closure $expression,
private readonly FilterExpressionField $field = FilterExpressionField::NOT_EXPRESSION,
) {
$this->expression = $expression(new FilterExpression());
$this->expression = $expression(new FilterExpression);
}

public function toRequest(): BaseFilterExpression
Expand Down
Loading

0 comments on commit 58b9fa2

Please sign in to comment.