Skip to content

Commit

Permalink
Merge pull request #55 from pj8/drop-php74-php80
Browse files Browse the repository at this point in the history
Drop PHP7.4 & PHP8.0
  • Loading branch information
momospnr authored Nov 28, 2024
2 parents 81594dc + 7df64b1 commit 6adeeb0
Show file tree
Hide file tree
Showing 30 changed files with 928 additions and 703 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -27,7 +27,7 @@ jobs:
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
Expand All @@ -40,4 +40,4 @@ jobs:
run: composer validate --strict

- name: Run PHP_CodeSniffer
run: ./vendor/bin/phpcs -q --no-colors --report=checkstyle src tests | cs2pr
run: ./vendor/bin/phpcs -q --no-colors --report=checkstyle src tests | cs2pr
8 changes: 4 additions & 4 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ jobs:
operating-system:
- ubuntu-latest
php-version:
- '7.4'
- '8.0'
- '8.1'
- '8.2'
- '8.3'
dependencies:
- lowest
- highest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
Expand All @@ -39,7 +39,7 @@ jobs:
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/static-analytics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -27,7 +27,7 @@ jobs:
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
Expand All @@ -44,7 +44,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -68,19 +68,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: 8.1

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
Expand All @@ -97,7 +97,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -120,7 +120,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
27 changes: 16 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@
}
],
"require": {
"php": "^7.4 || ^8.0",
"php": "^8.1",
"ext-json": "*",
"http-interop/http-factory-guzzle": "^1.0",
"ray/aop": "^2.10",
"ray/di": "^2.12",
"sentry/sdk": "^3.2.0",
"sentry/sentry": "^3.6.1",
"sentry/sdk": "^4.0",
"sentry/sentry": "^4.10",
"symfony/http-client": "^4.3|^5.0|^6.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.5",
"bear/package": "^1.10",
"bear/resource": "^1.16.1",
"bear/sunday": "^1.5.4",
"phpunit/phpunit": "^9.5",
"bear/package": "^1.17",
"bear/resource": "^1.23",
"bear/sunday": "^1.7",
"phpunit/phpunit": "^10.5",
"roave/security-advisories": "dev-master",
"symfony/options-resolver": "^5.4.0"
"symfony/options-resolver": "^5.4"
},
"autoload": {
"psr-4": {
Expand All @@ -50,17 +50,22 @@
"cs-fix": ["./vendor/bin/phpcbf src tests"],
"clean": ["./vendor/bin/phpstan clear-result-cache", "./vendor/bin/psalm --clear-cache"],
"sa": [
"phpstan analyse -c phpstan.neon",
"psalm --show-info=true",
"phpstan analyse -c phpstan.neon --memory-limit=-1",
"psalm --show-info=true --no-cache",
"phpmd --exclude src/Annotation src text ./phpmd.xml"
],
"baseline": [
"phpstan analyse -configuration -c phpstan.neon --generate-baseline",
"psalm --set-baseline=psalm-baseline.xml"
],
"phpmd": ["./vendor/bin/phpmd src text ./phpmd.xml"],
"build": ["@cs", "@sa", "@pcov"]
},
"config": {
"sort-packages": true,
"allow-plugins": {
"bamarni/composer-bin-plugin": true
"bamarni/composer-bin-plugin": true,
"php-http/discovery": true
}
}
}
79 changes: 79 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
parameters:
ignoreErrors:
-
message: '#^Method Pj8\\SentryModule\\ResourceSpanFactory\:\:__invoke\(\) has parameter \$invocation with generic interface Ray\\Aop\\MethodInvocation but does not specify its types\: T$#'
identifier: missingType.generics
count: 1
path: src/ResourceSpanFactory.php

-
message: '#^Method Pj8\\SentryModule\\ResourceTrace\:\:start\(\) has parameter \$invocation with generic interface Ray\\Aop\\MethodInvocation but does not specify its types\: T$#'
identifier: missingType.generics
count: 1
path: src/ResourceTrace.php

-
message: '#^PHPDoc tag @SuppressWarnings has invalid value \(\(PHPMD\.StaticAccess\)\)\: Unexpected token "\.StaticAccess\)", expected ''\)'' at offset 27 on line 1$#'
identifier: phpDoc.parseError
count: 1
path: src/ResourceTrace.php

-
message: '#^Method Pj8\\SentryModule\\ResourceTraceInterface\:\:start\(\) has parameter \$invocation with generic interface Ray\\Aop\\MethodInvocation but does not specify its types\: T$#'
identifier: missingType.generics
count: 1
path: src/ResourceTraceInterface.php

-
message: '#^PHPDoc tag @SuppressWarnings has invalid value \(\(PHPMD\.CouplingBetweenObjects\)\)\: Unexpected token "\.CouplingBetweenObjects\)", expected ''\)'' at offset 27 on line 1$#'
identifier: phpDoc.parseError
count: 1
path: src/SentryModule.php

-
message: '#^Method Pj8\\SentryModule\\SpanContextFactory\:\:__invoke\(\) has parameter \$invocation with generic interface Ray\\Aop\\MethodInvocation but does not specify its types\: T$#'
identifier: missingType.generics
count: 1
path: src/SpanContextFactory.php

-
message: '#^Method Pj8\\SentryModule\\SpanContextFactory\:\:getGenericContext\(\) has parameter \$invocation with generic interface Ray\\Aop\\MethodInvocation but does not specify its types\: T$#'
identifier: missingType.generics
count: 1
path: src/SpanContextFactory.php

-
message: '#^Method Pj8\\SentryModule\\SpanContextFactoryInterface\:\:__invoke\(\) has parameter \$invocation with generic interface Ray\\Aop\\MethodInvocation but does not specify its types\: T$#'
identifier: missingType.generics
count: 1
path: src/SpanContextFactoryInterface.php

-
message: '#^Class Pj8\\SentryModule\\TransactionNameProvider implements generic interface Ray\\Di\\ProviderInterface but does not specify its types\: T$#'
identifier: missingType.generics
count: 1
path: src/TransactionNameProvider.php

-
message: '#^PHPDoc tag @SuppressWarnings has invalid value \(\(PHPMD\.Superglobals\)\)\: Unexpected token "\.Superglobals\)", expected ''\)'' at offset 27 on line 1$#'
identifier: phpDoc.parseError
count: 1
path: src/TransactionNameProvider.php

-
message: '#^Comparison operation "\<" between int\<80100, 80499\> and 80100 is always false\.$#'
identifier: smaller.alwaysFalse
count: 1
path: tests/ResourceInterceptorTest.php

-
message: '#^Property Pj8\\SentryModule\\ResourceInterceptorTest\:\:\$trace \(Pj8\\SentryModule\\ResourceTrace\|null\) is never assigned null so it can be removed from the property type\.$#'
identifier: property.unusedType
count: 1
path: tests/ResourceInterceptorTest.php

-
message: '#^Property Pj8\\SentryModule\\ResourceInterceptorTest\:\:\$transaction \(Pj8\\SentryModule\\Transaction\|null\) is never assigned null so it can be removed from the property type\.$#'
identifier: property.unusedType
count: 1
path: tests/ResourceInterceptorTest.php
4 changes: 3 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
includes:
- phpstan-baseline.neon

parameters:
level: 6
paths:
- src
- tests
checkGenericClassInNonGenericObjectType: false
25 changes: 25 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0">
<file src="src/TransactionNameProvider.php">
<MissingTemplateParam>
<code><![CDATA[ProviderInterface]]></code>
</MissingTemplateParam>
</file>
<file src="tests/MonitorInterceptorTest.php">
<InvalidArgument>
<code><![CDATA[$invocation]]></code>
</InvalidArgument>
</file>
<file src="tests/ResourceInterceptorTest.php">
<InvalidArgument>
<code><![CDATA[$invocation]]></code>
<code><![CDATA[$invocation]]></code>
</InvalidArgument>
</file>
<file src="tests/ResourceTraceTest.php">
<InvalidArgument>
<code><![CDATA[$invocation]]></code>
<code><![CDATA[$invocation]]></code>
</InvalidArgument>
</file>
</files>
3 changes: 3 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor-bin/tools/vendor/vimeo/psalm/config.xsd"
errorBaseline="psalm-baseline.xml"
findUnusedBaselineEntry="true"
findUnusedCode="false"
>
<projectFiles>
<directory name="src"/>
Expand Down
24 changes: 24 additions & 0 deletions src/BeforeSend.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace Pj8\SentryModule;

use Sentry\Event;

final class BeforeSend implements BeforeSendInterface
{
/** @param array<string, string> $tags セットしたいタグの配列(オプション) */
public function __construct(private readonly array $tags = [])
{
}

public function __invoke(Event $event): Event
{
if ($this->tags !== []) {
$event->setTags($this->tags);
}

return $event;
}
}
12 changes: 12 additions & 0 deletions src/BeforeSendInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace Pj8\SentryModule;

use Sentry\Event;

interface BeforeSendInterface
{
public function __invoke(Event $event): Event|null;
}
6 changes: 1 addition & 5 deletions src/ExcludeSampler.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,13 @@ final class ExcludeSampler implements TracesSamplerInterface
{
private float $defaultRate;

/** @var string[] */
private array $excludeNames;

/**
* @param float $default トレース計測レートのデフォルト値
* @param array<string> $excludeNames トレース計測から常に除外したいトランザクション名の配列オプション
*/
public function __construct(float $default, array $excludeNames = [])
public function __construct(float $default, private array $excludeNames = [])
{
$this->defaultRate = $default;
$this->excludeNames = $excludeNames;
}

public function __invoke(SamplingContext $context): float
Expand Down
8 changes: 3 additions & 5 deletions src/IncludesMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ class IncludesMatcher extends AbstractMatcher
/** @var string[] 同値判定対象 */
private array $values;

/**
* @param string|string[] $values 同値判定対象
*/
/** @param string|string[] $values 同値判定対象 */
public function __construct($values)
{
parent::__construct();
Expand All @@ -28,15 +26,15 @@ public function __construct($values)
}

/**
* {@inheritdoc}
* {@inheritDoc}
*/
public function matchesClass(ReflectionClass $class, array $arguments): bool
{
return in_array(strtolower($class->getName()), array_map('strtolower', $this->values));
}

/**
* {@inheritdoc}
* {@inheritDoc}
*/
public function matchesMethod(ReflectionMethod $method, array $arguments): bool
{
Expand Down
Loading

0 comments on commit 6adeeb0

Please sign in to comment.