diff --git a/src/Composer/Advisory/PartialSecurityAdvisory.php b/src/Composer/Advisory/PartialSecurityAdvisory.php index c5234591b..28dbdc4f4 100644 --- a/src/Composer/Advisory/PartialSecurityAdvisory.php +++ b/src/Composer/Advisory/PartialSecurityAdvisory.php @@ -14,8 +14,9 @@ namespace Composer\Advisory; use Composer\Semver\Constraint\ConstraintInterface; use Composer\Semver\VersionParser; +use JsonSerializable; -class PartialSecurityAdvisory +class PartialSecurityAdvisory implements JsonSerializable { /** * @var string @@ -55,4 +56,16 @@ class PartialSecurityAdvisory $this->packageName = $packageName; $this->affectedVersions = $affectedVersions; } + + /** + * @return mixed + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = (array) $this; + $data['affectedVersions'] = $data['affectedVersions']->getPrettyString(); + + return $data; + } } diff --git a/src/Composer/Advisory/SecurityAdvisory.php b/src/Composer/Advisory/SecurityAdvisory.php index a574ed4b0..8fdf4dd55 100644 --- a/src/Composer/Advisory/SecurityAdvisory.php +++ b/src/Composer/Advisory/SecurityAdvisory.php @@ -61,4 +61,16 @@ class SecurityAdvisory extends PartialSecurityAdvisory $this->cve = $cve; $this->link = $link; } + + /** + * @return mixed + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = parent::jsonSerialize(); + $data['reportedAt'] = $data['reportedAt']->format(DATE_RFC3339); + + return $data; + } }