Skip to content

Commit 727236e

Browse files
authored
fix failing psr3 tests (#281)
- yii built-in fields have moved around - whether to use autoload in class_exists was always false, so remove param
1 parent 6de2265 commit 727236e

File tree

6 files changed

+15
-31
lines changed

6 files changed

+15
-31
lines changed

src/Instrumentation/Psr3/psalm.xml.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<psalm
33
errorLevel="3"
44
cacheDirectory="var/cache/psalm"
5+
findUnusedBaselineEntry="false"
6+
findUnusedCode="false"
57
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
68
xmlns="https://getpsalm.org/schema/config"
79
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd">

src/Instrumentation/Psr3/src/Psr3Instrumentation.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,25 +107,25 @@ private static function getMode(): string
107107
/**
108108
* @see https://www.php.net/manual/en/function.class-uses.php#112671
109109
*/
110-
private static function class_uses_deep(object $class, bool $autoload = false): array
110+
private static function class_uses_deep(object $class): array
111111
{
112112
$traits = [];
113113

114114
// Get traits of all parent classes
115115
do {
116-
$traits = array_merge(class_uses($class, $autoload), $traits);
116+
$traits = array_merge(class_uses($class, false), $traits);
117117
} while ($class = get_parent_class($class));
118118

119119
// Get traits of all parent traits
120120
$traitsToSearch = $traits;
121121
while (!empty($traitsToSearch)) {
122-
$newTraits = class_uses(array_pop($traitsToSearch), $autoload);
122+
$newTraits = class_uses(array_pop($traitsToSearch), false);
123123
$traits = array_merge($newTraits, $traits);
124124
$traitsToSearch = array_merge($newTraits, $traitsToSearch);
125125
};
126126

127127
foreach ($traits as $trait => $same) {
128-
$traits = array_merge(class_uses($trait, $autoload), $traits);
128+
$traits = array_merge(class_uses($trait, false), $traits);
129129
}
130130

131131
return array_unique($traits);

src/Instrumentation/Psr3/tests/Integration/Psr3InstrumentationTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,19 @@ class Psr3InstrumentationTest extends TestCase
1919
{
2020
private ScopeInterface $scope;
2121
private SpanInterface $span;
22-
private TracerProvider $tracerProvider;
2322
/** @var LoggerInterface&MockObject */
2423
private LoggerInterface $logger;
2524

2625
public function setUp(): void
2726
{
2827
$this->logger = $this->createMock(LoggerInterface::class);
29-
$this->tracerProvider = new TracerProvider(
28+
$tracerProvider = new TracerProvider(
3029
new SimpleSpanProcessor(
3130
new InMemoryExporter(new ArrayObject())
3231
)
3332
);
3433

35-
$this->span = $this->tracerProvider
34+
$this->span = $tracerProvider
3635
->getTracer('phpunit')
3736
->spanBuilder('root')
3837
->startSpan();

src/Instrumentation/Psr3/tests/phpt/export_multi.phpt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ $span->end();
4141

4242
Message context:
4343

44-
time: %d.%d
45-
memory: %d
46-
category: '%s'
44+
%A
4745

4846
{
4947
"resource": {

src/Instrumentation/Psr3/tests/phpt/export_yii.phpt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ $span->end();
3636
%s [info][%s] hello world
3737

3838
Message context:
39-
39+
%A
4040
foo: 'bar'
4141
exception: RuntimeException: kablam in %s
4242
Stack trace:
@@ -47,10 +47,7 @@ Next Exception: kaboom in %s
4747
Stack trace:
4848
#0 %s
4949
#1 {main}
50-
time: %d.%d
51-
memory: %d
52-
category: '%s'
53-
50+
%A
5451
{
5552
"resource": {
5653
"attributes": [],

src/Instrumentation/Psr3/tests/phpt/inject_yii.phpt

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
Test inject context to symfony logger
2+
Test inject context to yii logger
33
--FILE--
44

55
<?php
@@ -31,19 +31,7 @@ $span->end();
3131
%s [warning][%s] hello world traceId=%s spanId=%s
3232

3333
Message context:
34-
35-
foo: 'bar'
36-
exception: RuntimeException: kablam in %s
37-
Stack trace:
38-
#0 %s
39-
#1 %s
40-
41-
Next Exception: kaboom in %s
42-
Stack trace:
43-
#0 %s
44-
#1 %s
34+
%A
35+
foo: 'bar'%A
4536
traceId: '%s'
46-
spanId: '%s'
47-
time: %d.%d
48-
memory: %d
49-
category: '%s'
37+
spanId: '%s'%A

0 commit comments

Comments
 (0)