Skip to content

Commit bad09ac

Browse files
wesolydexterdmajka
andauthored
fix: resolve deprecations for implicitly nullable parameters in PHP 8.4 (#231)
* fix: resolve deprecations for implicitly nullable parameters in PHP 8.4 * Update actions/cache from v2 to v3 * Update workflows to use the latest output method * Fix composer cache directory setup * Fix composer cache directory output in CI * Fix mysqli connection test. * Renamed abstract test classes to avoid warnings * Fix namespace issue in MysqliTest * Update CI to upload coverage report for PHP 8.1 * Revert version number in Docker Compose file. * Use `docker compose` instead of `docker-compose`. * Skip testing mysql connection on non-Linux systems * Disable Codecov coverage upload in the CI workflow * Remove code coverage in CI --------- Co-authored-by: dmajka <dawid.majka@verestro.com>
1 parent e2809f8 commit bad09ac

33 files changed

+83
-78
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
operating-system: [ubuntu-latest, windows-latest, macos-latest]
18-
php-versions: ["7.4", "8.0", "8.1"]
18+
php-versions: ["7.4", "8.0", "8.1", "8.2", "8.3", "8.4"]
1919
steps:
2020
- name: Checkout
2121
uses: actions/checkout@v2
@@ -27,9 +27,9 @@ jobs:
2727
extensions: mysql
2828
- name: Get composer cache directory
2929
id: composer-cache
30-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
30+
run: echo "dir=$(composer config cache-files-dir | tr -d '\n' | tr -d '\r')" >> $GITHUB_OUTPUT
3131
- name: Cache composer dependencies
32-
uses: actions/cache@v2
32+
uses: actions/cache@v3
3333
with:
3434
path: ${{ steps.composer-cache.outputs.dir }}
3535
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
@@ -44,17 +44,3 @@ jobs:
4444
run: composer static-check
4545
- name: Run tests
4646
run: composer test -- --coverage-clover=build/logs/clover.xml
47-
- name: Upload coverage report to codecov service
48-
if: ${{ matrix.operating-system == 'ubuntu-latest' && matrix.php-versions == '8.0' }}
49-
run: |
50-
wget -c -nc --retry-connrefused --tries=0 https://github.com/satooshi/php-coveralls/releases/download/v2.4.3/php-coveralls.phar
51-
chmod +x php-coveralls.phar
52-
php php-coveralls.phar --version
53-
mkdir -p build/logs
54-
php php-coveralls.phar -v
55-
bash <(curl -s https://codecov.io/bash)
56-
env:
57-
# Running coveralls with default config did not work so followed the workaround below:
58-
# https://github.com/php-coveralls/php-coveralls/issues/273#issuecomment-537473525
59-
COVERALLS_RUN_LOCALLY: 1
60-
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ composer.phar
22
composer.lock
33
/vendor/
44
.phpunit.result.cache
5+
.php-cs-fixer.cache

.php-cs-fixer.dist.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
4+
5+
$finder = PhpCsFixer\Finder::create()
6+
->in('src')
7+
->in('tests')
8+
;
9+
10+
return (new PhpCsFixer\Config())
11+
->setParallelConfig(ParallelConfigFactory::detect())
12+
->setRules(
13+
[
14+
'nullable_type_declaration_for_default_null_value' => true,
15+
]
16+
)
17+
->setFinder($finder)
18+
;

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
![CI](https://github.com/openzipkin/zipkin-php/workflows/CI/badge.svg)
44
[![Latest Stable Version](https://poser.pugx.org/openzipkin/zipkin/v/stable)](https://packagist.org/packages/openzipkin/zipkin)
5-
[![Coverage Status](https://coveralls.io/repos/github/openzipkin/zipkin-php/badge.svg)](https://coveralls.io/github/openzipkin/zipkin-php)
65
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.4-8892BF.svg)](https://php.net/)
76
[![Total Downloads](https://poser.pugx.org/openzipkin/zipkin/downloads)](https://packagist.org/packages/openzipkin/zipkin)
87
[![License](https://img.shields.io/packagist/l/openzipkin/zipkin.svg)](https://github.com/openzipkin/zipkin-php/blob/master/LICENSE)

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
},
2828
"require-dev": {
2929
"ext-mysqli": "*",
30+
"friendsofphp/php-cs-fixer": "^3.75",
3031
"jcchavezs/httptest": "~0.2",
3132
"middlewares/fast-route": "^2.0",
3233
"middlewares/request-handler": "^2.0",

src/Zipkin/Instrumentation/Http/Client/HttpClientTracing.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class HttpClientTracing
2727

2828
public function __construct(
2929
Tracing $tracing,
30-
HttpClientParser $parser = null,
31-
callable $requestSampler = null
30+
?HttpClientParser $parser = null,
31+
?callable $requestSampler = null
3232
) {
3333
$this->tracing = $tracing;
3434
$this->parser = $parser ?? new DefaultHttpClientParser();

src/Zipkin/Instrumentation/Http/Server/HttpServerTracing.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class HttpServerTracing
2626

2727
public function __construct(
2828
Tracing $tracing,
29-
HttpServerParser $parser = null,
30-
callable $requestSampler = null
29+
?HttpServerParser $parser = null,
30+
?callable $requestSampler = null
3131
) {
3232
$this->tracing = $tracing;
3333
$this->parser = $parser ?? new DefaultHttpServerParser();

src/Zipkin/Instrumentation/Mysqli/Mysqli.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ final class Mysqli extends \Mysqli
3030
public function __construct(
3131
Tracer $tracer,
3232
array $options = [],
33-
string $host = null,
34-
string $user = null,
35-
string $password = null,
33+
?string $host = null,
34+
?string $user = null,
35+
?string $password = null,
3636
string $database = '',
37-
int $port = null,
38-
string $socket = null
37+
?int $port = null,
38+
?string $socket = null
3939
) {
4040
self::validateOptions($options);
4141
$this->tracer = $tracer;
@@ -65,7 +65,7 @@ private static function validateOptions(array $opts): void
6565
}
6666
}
6767

68-
private function addsTagsAndRemoteEndpoint(Span $span, string $query = null): void
68+
private function addsTagsAndRemoteEndpoint(Span $span, ?string $query = null): void
6969
{
7070
if ($query !== null && $this->options['tag_query']) {
7171
$span->tag('sql.query', $query);

src/Zipkin/NoopSpan.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function getContext(): TraceContext
3737
* Spans can be modified before calling start. For example, you can add tags to the span and
3838
* set its name without lock contention.
3939
*/
40-
public function start(int $timestamp = null): void
40+
public function start(?int $timestamp = null): void
4141
{
4242
}
4343

@@ -87,7 +87,7 @@ public function setError(Throwable $e): void
8787
* @return void
8888
* @see Annotations
8989
*/
90-
public function annotate(string $value, int $timestamp = null): void
90+
public function annotate(string $value, ?int $timestamp = null): void
9191
{
9292
}
9393

@@ -113,7 +113,7 @@ public function abandon(): void
113113
* {@link zipkin.Span#duration Zipkin's span duration} is derived by subtracting the start
114114
* timestamp from this, and set when appropriate.
115115
*/
116-
public function finish(int $timestamp = null): void
116+
public function finish(?int $timestamp = null): void
117117
{
118118
}
119119

src/Zipkin/NoopSpanCustomizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function tag(string $key, string $value): void
2323
/**
2424
* {@inheritdoc}
2525
*/
26-
public function annotate(string $value, int $timestamp = null): void
26+
public function annotate(string $value, ?int $timestamp = null): void
2727
{
2828
}
2929
}

0 commit comments

Comments
 (0)