Skip to content

Commit cf6d6ad

Browse files
committed
PHP5 Compliance
1 parent a5fba8a commit cf6d6ad

File tree

6 files changed

+51
-24
lines changed

6 files changed

+51
-24
lines changed

src/Bridge/ContextInjector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static function getSubscribedEvents()
2929
];
3030
}
3131

32-
public function inject(): ContextInjector
32+
public function inject()
3333
{
3434
if (null === ($context = $this->extractor->extract())) {
3535
return $this;

src/Context/Extractor/ContextExtractorChain.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<?php
2-
declare(strict_types=1);
3-
42
namespace Jaeger\Symfony\Context\Extractor;
53

64
use Jaeger\Span\Context\SpanContext;
@@ -14,14 +12,23 @@ public function __construct(\SplPriorityQueue $queue)
1412
$this->queue = $queue;
1513
}
1614

17-
public function add(ContextExtractorInterface $extractor, int $priority = 0): ContextExtractorChain
15+
/**
16+
* @param ContextExtractorInterface $extractor
17+
* @param int $priority
18+
*
19+
* @return ContextExtractorChain
20+
*/
21+
public function add(ContextExtractorInterface $extractor, $priority = 0)
1822
{
19-
$this->queue->insert($extractor, $priority);
23+
$this->queue->insert($extractor, (int)$priority);
2024

2125
return $this;
2226
}
2327

24-
public function extract(): ?SpanContext
28+
/**
29+
* @return SpanContext|null
30+
*/
31+
public function extract()
2532
{
2633
$queue = clone $this->queue;
2734
while (false === $queue->isEmpty()) {
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<?php
2-
declare(strict_types=1);
3-
42
namespace Jaeger\Symfony\Context\Extractor;
53

64
use Jaeger\Span\Context\SpanContext;
75

86
interface ContextExtractorInterface
97
{
10-
public function extract() : ?SpanContext;
8+
/**
9+
* @return SpanContext|null
10+
*/
11+
public function extract();
1112
}

src/Context/Extractor/EnvContextExtractor.php

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?php
2-
declare(strict_types=1);
32

43
namespace Jaeger\Symfony\Context\Extractor;
54

@@ -21,14 +20,24 @@ class EnvContextExtractor implements ContextExtractorInterface
2120

2221
private $context;
2322

24-
public function __construct(CodecRegistry $registry, string $format, string $envName)
23+
/**
24+
* EnvContextExtractor constructor.
25+
*
26+
* @param CodecRegistry $registry
27+
* @param string $format
28+
* @param string $envName
29+
*/
30+
public function __construct(CodecRegistry $registry, $format, $envName)
2531
{
2632
$this->registry = $registry;
27-
$this->format = $format;
28-
$this->envName = $envName;
33+
$this->format = (string)$format;
34+
$this->envName = (string)$envName;
2935
}
3036

31-
public function extract(): ?SpanContext
37+
/**
38+
* @return SpanContext|null
39+
*/
40+
public function extract()
3241
{
3342
return $this->context;
3443
}
@@ -42,7 +51,11 @@ public static function getSubscribedEvents()
4251

4352
public function onCommand()
4453
{
45-
if (null === ($data = $_ENV[$this->envName] ?? null)) {
54+
if (false === array_key_exists($this->envName, $_ENV)) {
55+
return $this;
56+
}
57+
58+
if (null === ($data = $_ENV[$this->envName])) {
4659
return $this;
4760
}
4861

src/Context/Extractor/HeaderContextExtractor.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<?php
2-
declare(strict_types=1);
3-
42
namespace Jaeger\Symfony\Context\Extractor;
53

64
use Jaeger\Codec\CodecInterface;
@@ -23,14 +21,24 @@ class HeaderContextExtractor implements ContextExtractorInterface
2321

2422
private $context;
2523

26-
public function __construct(CodecRegistry $registry, string $format, string $headerName)
24+
/**
25+
* HeaderContextExtractor constructor.
26+
*
27+
* @param CodecRegistry $registry
28+
* @param string $format
29+
* @param string $headerName
30+
*/
31+
public function __construct(CodecRegistry $registry, $format, $headerName)
2732
{
2833
$this->registry = $registry;
29-
$this->format = $format;
30-
$this->headerName = $headerName;
34+
$this->format = (string)$format;
35+
$this->headerName = (string)$headerName;
3136
}
3237

33-
public function extract(): ?SpanContext
38+
/**
39+
* @return SpanContext|null
40+
*/
41+
public function extract()
3442
{
3543
return $this->context;
3644
}

src/Resources/DependencyInjection/ExtractorChainCompilerPass.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<?php
2-
declare(strict_types=1);
3-
42
namespace Jaeger\Symfony\Resources\DependencyInjection;
53

64
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
@@ -25,7 +23,7 @@ public function process(ContainerBuilder $container)
2523
sprintf('Required tag field %s is missing from definition', 'alias')
2624
);
2725
}
28-
$priority = $tag['priority'] ?? 0;
26+
$priority = array_key_exists('priority', $tag) ? $tag['priority'] : 0;
2927
$definition->addMethodCall('add', [new Reference($id), $priority]);
3028
}
3129
}

0 commit comments

Comments
 (0)