Skip to content

Commit 08641d4

Browse files
committed
Fix psalm issues
1 parent 8de1de7 commit 08641d4

File tree

3 files changed

+47
-24
lines changed

3 files changed

+47
-24
lines changed

tests/Integration/Symfony/OtelSdkBundle/DependencyInjection/OtelSdkExtensionTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ public function testAlwaysOffRootSamplerRegression(): void
170170

171171
/**
172172
* @throws Exception
173+
* @psalm-suppress PossiblyNullArrayAccess
173174
*/
174175
public function testSpanLimits(): void
175176
{
@@ -260,6 +261,13 @@ public function testSpanProcessors(): void
260261
}
261262
}
262263

264+
/**
265+
* @psalm-suppress PossiblyInvalidCast
266+
* @psalm-suppress RedundantCondition
267+
* @psalm-suppress InvalidArrayOffset
268+
* @psalm-suppress PossiblyNullArrayAccess
269+
* @psalm-suppress PossiblyNullArgument
270+
*/
263271
public function testSpanExporters(): void
264272
{
265273
$data = $this->loadTestData('exporters')['trace']['exporters'];
@@ -336,6 +344,9 @@ public function testSpanExporters(): void
336344

337345
// HELPER METHODS
338346

347+
/**
348+
* @psalm-suppress PossiblyInvalidCast
349+
*/
339350
private function assertReference(string $class, ?object $reference, ?string $idSuffix = null): void
340351
{
341352
$this->assertIsReference(
@@ -372,6 +383,10 @@ private function assertIsReference(?object $reference): void
372383
);
373384
}
374385

386+
/**
387+
* @psalm-suppress NullableReturnStatement
388+
* @psalm-suppress InvalidNullableReturnType
389+
*/
375390
private function getClassFromReference(Reference $reference): string
376391
{
377392
return $this->getContainer()

tests/Integration/Symfony/OtelSdkBundle/OtelSdkBundleTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,9 @@ public function testExporterWithSimpleConfig(): void
179179
}
180180

181181
/**
182-
* @test
183182
* @depends testExporterWithSimpleConfig
184183
* @throws Exception
184+
* @psalm-suppress PossiblyUndefinedMethod
185185
*/
186186
public function testTracingWithSimpleConfig(): void
187187
{
@@ -207,6 +207,7 @@ public function testTracingWithSimpleConfig(): void
207207
/**
208208
* @depends testExporterWithSimpleConfig
209209
* @throws Exception
210+
* @psalm-suppress PossiblyUndefinedMethod
210211
*/
211212
public function testTracingWithAlwaysOffSampler(): void
212213
{
@@ -270,6 +271,7 @@ private function getTracerProviderId(): string
270271

271272
/**
272273
* @return MockObject|ClientInterface
274+
* @psalm-suppress MismatchingDocblockReturnType
273275
*/
274276
private function registerHttpClientMock(): ClientInterface
275277
{

tests/Unit/Symfony/OtelSdkBundle/Factory/GenericFactoryTraitTest.php

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,21 @@ public function setUp(): void
4646
BypassFinals::enable();
4747
}
4848

49-
private function init()
49+
private function init(): void
5050
{
5151
$this->initResolver();
5252
$this->initFactory();
5353
}
5454

55-
private function initResolver()
55+
private function initResolver(): void
5656
{
5757
$this->resolver = $this->createOptionsResolverMock();
5858
}
5959

60-
private function initFactory(string $class = TestedClass::class)
60+
/**
61+
* @psalm-suppress PossiblyInvalidArgument
62+
*/
63+
private function initFactory(string $class = TestedClass::class): void
6164
{
6265
$this->factory = GenericFactoryImplementation::create(
6366
$class,
@@ -66,7 +69,7 @@ private function initFactory(string $class = TestedClass::class)
6669
}
6770

6871
// TESTS
69-
public function testCreate()
72+
public function testCreate(): void
7073
{
7174
$this->init();
7275

@@ -76,7 +79,10 @@ public function testCreate()
7679
);
7780
}
7881

79-
public function testCreateWithNonExistingClass()
82+
/**
83+
* @psalm-suppress PossiblyInvalidArgument
84+
*/
85+
public function testCreateWithNonExistingClass(): void
8086
{
8187
$this->initResolver();
8288
$class = 'NonExistingClass';
@@ -91,7 +97,8 @@ class_exists($class)
9197
);
9298
}
9399

94-
public function testGetOptionsResolver()
100+
/** @noinspection UnnecessaryAssertionInspection */
101+
public function testGetOptionsResolver(): void
95102
{
96103
$this->init();
97104

@@ -101,22 +108,17 @@ public function testGetOptionsResolver()
101108
);
102109
}
103110

104-
public function testGetReflectionClass()
111+
public function testGetReflectionClass(): void
105112
{
106113
$this->init();
107114

108-
$this->assertInstanceOf(
109-
ReflectionClass::class,
110-
$this->factory->getReflectionClass()
111-
);
112-
113115
$this->assertSame(
114116
TestedClass::class,
115117
$this->factory->getReflectionClass()->getName()
116118
);
117119
}
118120

119-
public function testGetClass()
121+
public function testGetClass(): void
120122
{
121123
$this->init();
122124

@@ -126,7 +128,7 @@ public function testGetClass()
126128
);
127129
}
128130

129-
public function testGetOptions()
131+
public function testGetOptions(): void
130132
{
131133
$this->init();
132134

@@ -136,7 +138,7 @@ public function testGetOptions()
136138
);
137139
}
138140

139-
public function testGetRequiredOptions()
141+
public function testGetRequiredOptions(): void
140142
{
141143
$this->init();
142144

@@ -146,7 +148,7 @@ public function testGetRequiredOptions()
146148
);
147149
}
148150

149-
public function testGetDefaults()
151+
public function testGetDefaults(): void
150152
{
151153
$this->init();
152154

@@ -156,7 +158,7 @@ public function testGetDefaults()
156158
);
157159
}
158160

159-
public function testSetDefault()
161+
public function testSetDefault(): void
160162
{
161163
$this->init();
162164

@@ -173,7 +175,7 @@ public function testSetDefault()
173175
);
174176
}
175177

176-
public function testSetDefaults()
178+
public function testSetDefaults(): void
177179
{
178180
$this->init();
179181

@@ -190,7 +192,7 @@ public function testSetDefaults()
190192
);
191193
}
192194

193-
public function testBuildWithDefaults()
195+
public function testBuildWithDefaults(): void
194196
{
195197
$option = 'foo_bar';
196198
$value = 'foo';
@@ -231,7 +233,7 @@ public function testBuildWithDefaults()
231233
);
232234
}
233235

234-
public function testBuildWithOptions()
236+
public function testBuildWithOptions(): void
235237
{
236238
$options = [
237239
'foo_bar' => 'baz',
@@ -272,7 +274,10 @@ public function testBuildWithOptions()
272274
);
273275
}
274276

275-
public function testBuildClassWithoutConstructor()
277+
/**
278+
* @psalm-suppress PossiblyInvalidArgument
279+
*/
280+
public function testBuildClassWithoutConstructor(): void
276281
{
277282
$this->initResolver();
278283

@@ -287,7 +292,7 @@ public function testBuildClassWithoutConstructor()
287292
);
288293
}
289294

290-
public function testBuildWithDefaultNull()
295+
public function testBuildWithDefaultNull(): void
291296
{
292297
$options = ['foo_bar' => 'baz'];
293298

@@ -312,9 +317,10 @@ public function testBuildWithDefaultNull()
312317

313318
// UTIL
314319

315-
// /** @psalm-suppress PossiblyUndefinedMethod **/
316320
/**
317321
* @return OptionsResolver|MockObject
322+
* @psalm-suppress PossiblyInvalidArgument
323+
* @psalm-suppress MismatchingDocblockReturnType
318324
*/
319325
private function createOptionsResolverMock(): OptionsResolver
320326
{

0 commit comments

Comments
 (0)