Skip to content

Commit ff554e6

Browse files
authored
Restrict support for PHP 7.4 (#211)
* chore: removes coveralls from fork. (#207) * chore(perf): replacement of array_merge into spread operator as in PHP 7.4. * chore: uses Null Coalescing Assignment Operator as per PHP 7.4. * chore: uses typed properties as in PHP 7.4. * chore: adds return type covariance to the http messages. * chore: adds missing typehint to DefaultTracing.
1 parent e5a0a94 commit ff554e6

36 files changed

+174
-537
lines changed

.github/workflows/ci.yml

+4-2
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.3", "7.4", "8.0"]
18+
php-versions: ["7.4", "8.0"]
1919
steps:
2020
- name: Checkout
2121
uses: actions/checkout@v2
@@ -51,7 +51,9 @@ jobs:
5151
- name: Run tests
5252
run: composer test -- --coverage-clover=build/logs/clover.xml
5353
- name: Upload coverage report to codecov service
54-
if: matrix.operating-system == 'ubuntu-latest'
54+
if: |
55+
matrix.operating-system == 'ubuntu-latest' ||
56+
env.GITHUB_REPOSITORY == 'openzipkin/zipkin-php'
5557
run: |
5658
php php-coveralls.phar -v
5759
bash <(curl -s https://codecov.io/bash)

src/Zipkin/DefaultTracing.php

+7-31
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,24 @@
44

55
namespace Zipkin;
66

7-
use Zipkin\Propagation\B3;
8-
use Zipkin\Propagation\CurrentTraceContext;
9-
use Zipkin\Propagation\Propagation;
107
use Zipkin\Reporter;
8+
use Zipkin\Propagation\Propagation;
9+
use Zipkin\Propagation\CurrentTraceContext;
10+
use Zipkin\Propagation\B3;
1111

1212
final class DefaultTracing implements Tracing
1313
{
14-
/**
15-
* @var Tracer
16-
*/
17-
private $tracer;
14+
private Tracer $tracer;
1815

19-
/**
20-
* @var Propagation
21-
*/
22-
private $propagation;
16+
private Propagation $propagation;
2317

24-
/**
25-
* @var bool
26-
*/
27-
private $isNoop;
18+
private bool $isNoop;
2819

29-
/**
30-
* @param Endpoint $localEndpoint
31-
* @param Reporter $reporter
32-
* @param Sampler $sampler
33-
* @param bool $usesTraceId128bits
34-
* @param CurrentTraceContext $currentTraceContext
35-
* @param bool $isNoop
36-
*/
3720
public function __construct(
3821
Endpoint $localEndpoint,
3922
Reporter $reporter,
4023
Sampler $sampler,
41-
$usesTraceId128bits,
24+
bool $usesTraceId128bits,
4225
CurrentTraceContext $currentTraceContext,
4326
bool $isNoop,
4427
Propagation $propagation,
@@ -60,17 +43,11 @@ public function __construct(
6043
$this->isNoop = $isNoop;
6144
}
6245

63-
/**
64-
* @return Tracer
65-
*/
6646
public function getTracer(): Tracer
6747
{
6848
return $this->tracer;
6949
}
7050

71-
/**
72-
* @return Propagation
73-
*/
7451
public function getPropagation(): Propagation
7552
{
7653
return $this->propagation;
@@ -80,7 +57,6 @@ public function getPropagation(): Propagation
8057
* When true, no recording is done and nothing is reported to zipkin. However, trace context is
8158
* still injected into outgoing requests.
8259
*
83-
* @return bool
8460
* @see Span#isNoop()
8561
*/
8662
public function isNoop(): bool

src/Zipkin/Endpoint.php

+7-45
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,24 @@
66

77
use InvalidArgumentException;
88

9-
class Endpoint
9+
final class Endpoint
1010
{
11-
const DEFAULT_SERVICE_NAME = 'unknown';
11+
public const DEFAULT_SERVICE_NAME = 'unknown';
1212

1313
/**
1414
* Service name in lowercase, such as "memcache" or "zipkin-web"
1515
* Conventionally, when the service name isn't known, service_name = "unknown".
16-
*
17-
* @var string
1816
*/
19-
private $serviceName;
17+
private string $serviceName;
2018

2119
/**
22-
* @var string|null host address packed into 4 bytes.
20+
* Host address packed into 4 bytes.
2321
*/
24-
private $ipv4;
22+
private ?string $ipv4;
2523

26-
/**
27-
* @var string|null
28-
*/
29-
private $ipv6;
24+
private ?string $ipv6;
3025

31-
/**
32-
* @var int|null
33-
*/
34-
private $port;
26+
private ?int $port;
3527

3628
private function __construct(string $serviceName, ?string $ipv4, ?string $ipv6, ?int $port)
3729
{
@@ -41,14 +33,6 @@ private function __construct(string $serviceName, ?string $ipv4, ?string $ipv6,
4133
$this->port = $port;
4234
}
4335

44-
/**
45-
* @param string $serviceName
46-
* @param string|null $ipv4
47-
* @param string|null $ipv6
48-
* @param int|null $port
49-
* @return Endpoint
50-
* @throws \InvalidArgumentException
51-
*/
5236
public static function create(
5337
string $serviceName,
5438
?string $ipv4 = null,
@@ -78,9 +62,6 @@ public static function create(
7862
return new self($serviceName, $ipv4, $ipv6, $port);
7963
}
8064

81-
/**
82-
* @return Endpoint
83-
*/
8465
public static function createFromGlobals(): self
8566
{
8667
return new self(
@@ -91,50 +72,31 @@ public static function createFromGlobals(): self
9172
);
9273
}
9374

94-
/**
95-
* @return Endpoint
96-
*/
9775
public static function createAsEmpty(): self
9876
{
9977
return new self('', null, null, null);
10078
}
10179

102-
/**
103-
* @return string
104-
*/
10580
public function getServiceName(): string
10681
{
10782
return $this->serviceName;
10883
}
10984

110-
/**
111-
* @return string|null
112-
*/
11385
public function getIpv4(): ?string
11486
{
11587
return $this->ipv4;
11688
}
11789

118-
/**
119-
* @return string|null
120-
*/
12190
public function getIpv6(): ?string
12291
{
12392
return $this->ipv6;
12493
}
12594

126-
/**
127-
* @return int|null
128-
*/
12995
public function getPort(): ?int
13096
{
13197
return $this->port;
13298
}
13399

134-
/**
135-
* @param string $serviceName
136-
* @return Endpoint
137-
*/
138100
public function withServiceName(string $serviceName): Endpoint
139101
{
140102
return new self($serviceName, $this->ipv4, $this->ipv6, $this->port);

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

+3-9
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,9 @@
1313
*/
1414
class HttpClientTracing
1515
{
16-
/**
17-
* @var Tracing
18-
*/
19-
private $tracing;
16+
private Tracing $tracing;
2017

21-
/**
22-
* @var HttpClientParser
23-
*/
24-
private $parser;
18+
private HttpClientParser $parser;
2519

2620
/**
2721
* function that decides to sample or not an unsampled
@@ -37,7 +31,7 @@ public function __construct(
3731
callable $requestSampler = null
3832
) {
3933
$this->tracing = $tracing;
40-
$this->parser = $parser ?? new DefaultHttpClientParser;
34+
$this->parser = $parser ?? new DefaultHttpClientParser();
4135
$this->requestSampler = $requestSampler;
4236
}
4337

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

+4-13
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,25 @@
99
use Zipkin\Propagation\TraceContext;
1010
use Zipkin\Kind;
1111
use Zipkin\Instrumentation\Http\Client\Psr18\Propagation\RequestHeaders;
12-
use Zipkin\Instrumentation\Http\Client\HttpClientParser;
1312
use Zipkin\Instrumentation\Http\Client\HttpClientTracing;
13+
use Zipkin\Instrumentation\Http\Client\HttpClientParser;
1414
use Throwable;
1515
use Psr\Http\Message\ResponseInterface;
1616
use Psr\Http\Message\RequestInterface;
1717
use Psr\Http\Client\ClientInterface;
1818

1919
final class Client implements ClientInterface
2020
{
21-
/**
22-
* @var ClientInterface
23-
*/
24-
private $delegate;
21+
private ClientInterface $delegate;
2522

2623
/**
2724
* @var callable(TraceContext,mixed):void
2825
*/
2926
private $injector;
3027

31-
/**
32-
* @var Tracer
33-
*/
34-
private $tracer;
28+
private Tracer $tracer;
3529

36-
/**
37-
* @var HttpClientParser
38-
*/
39-
private $parser;
30+
private HttpClientParser $parser;
4031

4132
/**
4233
* @var (callable(Request):?bool)|null

src/Zipkin/Instrumentation/Http/Client/Psr18/Request.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@
99

1010
final class Request extends ClientRequest
1111
{
12-
/**
13-
* @var RequestInterface
14-
*/
15-
private $delegate;
12+
private RequestInterface $delegate;
1613

1714
public function __construct(RequestInterface $delegate)
1815
{

src/Zipkin/Instrumentation/Http/Client/Psr18/Response.php

+2-8
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,9 @@
1010

1111
final class Response extends ClientResponse
1212
{
13-
/**
14-
* @var ResponseInterface
15-
*/
16-
private $delegate;
13+
private ResponseInterface $delegate;
1714

18-
/**
19-
* @var Request|null
20-
*/
21-
private $request;
15+
private ?Request $request;
2216

2317
public function __construct(
2418
ResponseInterface $delegate,

src/Zipkin/Instrumentation/Http/Request.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
namespace Zipkin\Instrumentation\Http;
66

7-
use const Zipkin\Tags\HTTP_METHOD;
8-
use const Zipkin\Tags\HTTP_PATH;
97
use const Zipkin\Tags\HTTP_URL;
8+
use const Zipkin\Tags\HTTP_PATH;
9+
use const Zipkin\Tags\HTTP_METHOD;
1010

1111
/**
1212
* Abstract request type used for parsing and sampling of http clients and servers.
@@ -60,7 +60,7 @@ abstract public function getUrl(): string;
6060
abstract public function getHeader(string $name): ?string;
6161

6262
/**
63-
* @return mixed the underlying request object or {@code null} if there is none.
63+
* @return object|null the underlying request object or {@code null} if there is none.
6464
*/
65-
abstract public function unwrap();
65+
abstract public function unwrap(): ?object;
6666
}

src/Zipkin/Instrumentation/Http/Response.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ abstract public function getRequest();
2727
abstract public function getStatusCode(): int;
2828

2929
/**
30-
* @return mixed the underlying response object or {@code null} if there is none.
30+
* @return object|null the underlying response object or {@code null} if there is none.
3131
*/
32-
abstract public function unwrap();
32+
abstract public function unwrap(): ?object;
3333
}

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

+3-9
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,9 @@
1212
*/
1313
class HttpServerTracing
1414
{
15-
/**
16-
* @var Tracing
17-
*/
18-
private $tracing;
15+
private Tracing $tracing;
1916

20-
/**
21-
* @var HttpServerParser
22-
*/
23-
private $parser;
17+
private HttpServerParser $parser;
2418

2519
/**
2620
* function that decides to sample or not an unsampled
@@ -36,7 +30,7 @@ public function __construct(
3630
callable $requestSampler = null
3731
) {
3832
$this->tracing = $tracing;
39-
$this->parser = $parser ?? new DefaultHttpServerParser;
33+
$this->parser = $parser ?? new DefaultHttpServerParser();
4034
$this->requestSampler = $requestSampler;
4135
}
4236

0 commit comments

Comments
 (0)