Skip to content

Commit 569a3ec

Browse files
authored
Merge pull request #7 from andrew-demb/patch-1
Reuse phpunit `@require` to enable php 7.4 tests. Suppress less psalm issues
2 parents 3664426 + 543378c commit 569a3ec

File tree

3 files changed

+34
-32
lines changed

3 files changed

+34
-32
lines changed

psalm.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
</projectFiles>
2020

2121
<issueHandlers>
22-
<PropertyNotSetInConstructor errorLevel="suppress"/>
22+
<PropertyNotSetInConstructor>
23+
<errorLevel type="suppress">
24+
<referencedProperty name="Symfony\Component\Serializer\SerializerAwareTrait::$serializer"/>
25+
</errorLevel>
26+
</PropertyNotSetInConstructor>
2327
</issueHandlers>
2428
</psalm>

src/Symfony/Extensions/PropertyNameConverter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ final class PropertyNameConverter implements NameConverterInterface
2424
*
2525
* @psalm-var array<string, string>
2626
*/
27-
private $localStorage;
27+
private $localStorage = [];
2828

2929
/**
3030
* {@inheritdoc}

tests/Symfony/SymfonyMessageSerializerTest.php

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -244,48 +244,46 @@ static function (Author $author): string
244244
/**
245245
* @test
246246
*
247+
* @requires PHP >= 7.4
248+
*
247249
* @throws \Throwable
248250
*/
249251
public function legacyPropertiesSupport(): void
250252
{
251-
if (\PHP_VERSION_ID >= 70400)
252-
{
253-
$serializer = new SymfonyMessageSerializer();
254-
255-
$object = new MixedWithLegacy(
256-
'qwerty',
257-
new \DateTimeImmutable('2019-01-01', new \DateTimeZone('UTC')),
258-
100500
259-
);
260-
261-
/** @var MixedWithLegacy $unserialized */
262-
$unserialized = $serializer->decode($serializer->encode($object));
263-
264-
static::assertSame($object->string, $unserialized->string);
265-
static::assertSame($object->dateTime->getTimestamp(), $unserialized->dateTime->getTimestamp());
266-
static::assertSame($object->long, $unserialized->long);
267-
}
253+
$serializer = new SymfonyMessageSerializer();
254+
255+
$object = new MixedWithLegacy(
256+
'qwerty',
257+
new \DateTimeImmutable('2019-01-01', new \DateTimeZone('UTC')),
258+
100500
259+
);
260+
261+
/** @var MixedWithLegacy $unserialized */
262+
$unserialized = $serializer->decode($serializer->encode($object));
263+
264+
static::assertSame($object->string, $unserialized->string);
265+
static::assertSame($object->dateTime->getTimestamp(), $unserialized->dateTime->getTimestamp());
266+
static::assertSame($object->long, $unserialized->long);
268267
}
269268

270269
/**
271270
* @test
272271
*
272+
* @requires PHP >= 7.4
273+
*
273274
* @throws \Throwable
274275
*/
275276
public function privateMixedPropertiesSupport(): void
276277
{
277-
if (\PHP_VERSION_ID >= 70400)
278-
{
279-
$serializer = new SymfonyMessageSerializer();
280-
281-
$object = new WithPrivateProperties(
282-
'Some string',
283-
100500,
284-
now()
285-
);
286-
287-
/** @var WithPrivateProperties $unserialized */
288-
$unserialized = $serializer->decode($serializer->encode($object));
289-
}
278+
$serializer = new SymfonyMessageSerializer();
279+
280+
$object = new WithPrivateProperties(
281+
'Some string',
282+
100500,
283+
now()
284+
);
285+
286+
/** @var WithPrivateProperties $unserialized */
287+
$unserialized = $serializer->decode($serializer->encode($object));
290288
}
291289
}

0 commit comments

Comments
 (0)