File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change 2323 "php" : " ^7.3|^7.4|^8.0" ,
2424 "ext-dom" : " *" ,
2525 "ext-json" : " *" ,
26+ "composer-runtime-api" : " ^2.0" ,
2627 "phpunit/phpunit" : " ^8.3|^9.0" ,
2728 "symfony/property-access" : " ^4.0|^5.0|^6.0" ,
2829 "symfony/serializer" : " ^4.0|^5.0|^6.0" ,
Original file line number Diff line number Diff line change 22
33namespace Spatie \Snapshots \Drivers ;
44
5+ use Composer \InstalledVersions ;
56use PHPUnit \Framework \Assert ;
67use Spatie \Snapshots \Driver ;
78use Symfony \Component \Serializer \Encoder \YamlEncoder ;
@@ -25,10 +26,13 @@ public function serialize($data): string
2526
2627 $ serializer = new Serializer ($ normalizers , $ encoders );
2728
28- // The Symfony serialized doesn't support `stdClass` yet.
29- // This may be removed when Symfony 5.1 is released.
3029 if ($ data instanceof \stdClass) {
31- $ data = (array ) $ data ;
30+ $ serializerVersion = InstalledVersions::getVersion ('symfony/serializer ' );
31+
32+ if (version_compare ($ serializerVersion , '5.1.0.0 ' ) < 0 ) {
33+ // The Symfony serializer (before 5.1 version) doesn't support `stdClass`.
34+ $ data = (array ) $ data ;
35+ }
3236 }
3337
3438 return $ this ->dedent (
You can’t perform that action at this time.
0 commit comments