Skip to content

Commit bc169e2

Browse files
committed
phpstan with stubs
1 parent 4b89e74 commit bc169e2

File tree

5 files changed

+90
-0
lines changed

5 files changed

+90
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: CI
2+
3+
on:
4+
push: ~
5+
pull_request: ~
6+
workflow_dispatch: ~
7+
8+
jobs:
9+
tests:
10+
runs-on: ubuntu-latest
11+
name: CI - PHP ${{ matrix.php }}, Dependencies ${{ matrix.dependencies }}
12+
env:
13+
ASYNCAPI_VERSION: ${{ matrix.schema }}
14+
strategy:
15+
matrix:
16+
php: [8.4]
17+
dependencies: [lowest, highest]
18+
19+
steps:
20+
- # Copies the repository files to the Action Runner
21+
name: Checkout Repository
22+
uses: actions/checkout@v4
23+
24+
- # Installs PHP and other necessary tools
25+
name: Setup PHP
26+
uses: shivammathur/[email protected]
27+
with:
28+
php-version: ${{ matrix.php }}
29+
30+
- # Installs and caches PHP dependencies
31+
name: Install Dependencies
32+
uses: ramsey/[email protected]
33+
with:
34+
dependency-versions: ${{ matrix.dependencies }}
35+
36+
- # Validates composer.json structure and required fields
37+
name: Validate composer.json
38+
run: composer validate --ansi --strict --no-check-publish
39+
40+
-
41+
name: phpstan
42+
run: vendor/bin/phpstan

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/vendor/
2+
/composer.lock

composer.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "ferror/phpstan-datadog-env",
3+
"autoload": {
4+
"psr-4": {
5+
"Ferror\\": "src/"
6+
}
7+
},
8+
"require": {
9+
"php": ">=8.3",
10+
"datadog/dd-trace": "^1.6"
11+
},
12+
"require-dev": {
13+
"phpstan/phpstan": "^2.1"
14+
}
15+
}

phpstan.neon

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# phpstan.neon
2+
parameters:
3+
level: max
4+
paths:
5+
- src
6+
bootstrapFiles:
7+
- vendor/autoload.php
8+
9+
# Include stubs for Datadog Trace Stubs
10+
scanFiles:
11+
- vendor/datadog/dd-trace/src/ddtrace_php_api.stubs.php

src/ExampleClass.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Ferror;
6+
7+
use DDTrace\Contracts\Span;
8+
use DDTrace\ScopeManager;
9+
10+
final readonly class ExampleClass
11+
{
12+
public function __construct(private Span $span)
13+
{
14+
}
15+
16+
public function test(ScopeManager $scopeManager): void
17+
{
18+
$scopeManager->activate($this->span);
19+
}
20+
}

0 commit comments

Comments
 (0)