From 255265e7d00a21b7ea48292d1f0da325dac18140 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Mon, 4 Dec 2023 10:30:25 -0800 Subject: [PATCH] Unknown properties from the Packagist API are no longer set on AbstractResult If you find a property is missing, please file a bug report on GitHub and we can get it added. --- spec/Packagist/Api/Result/PackageSpec.php | 2 ++ src/Packagist/Api/Result/AbstractResult.php | 3 +++ 2 files changed, 5 insertions(+) diff --git a/spec/Packagist/Api/Result/PackageSpec.php b/spec/Packagist/Api/Result/PackageSpec.php index 7746267..089b09f 100644 --- a/spec/Packagist/Api/Result/PackageSpec.php +++ b/spec/Packagist/Api/Result/PackageSpec.php @@ -29,6 +29,8 @@ public function let(Maintainer $maintainer, Version $version, Downloads $downloa 'dependents' => 42, 'github_stars' => 3086, 'github_forks' => 1124, + // A dynamic property, causes deprecation warnings in PHP 8.2+ and is now ignored in AbstractResult + 'supports_cheese' => true, ]); } diff --git a/src/Packagist/Api/Result/AbstractResult.php b/src/Packagist/Api/Result/AbstractResult.php index c51c5b9..58fdceb 100644 --- a/src/Packagist/Api/Result/AbstractResult.php +++ b/src/Packagist/Api/Result/AbstractResult.php @@ -16,6 +16,9 @@ public function fromArray(array $data): void if (null === $value && !$this->isNullable($property)) { continue; } + if (!property_exists($this, $property)) { + continue; + } $this->$property = $value; } }