KnpLabs / packagist-api

PHP API for Packagist
MIT License
182 stars 46 forks source link

Add `AllowDynamicProperties` annotation #93

Closed GrahamCampbell closed 11 months ago

GrahamCampbell commented 11 months ago

Maybe fixes #92. I'm not going to have time to confirm right now,.

robbieaverill commented 11 months ago

Hey @GrahamCampbell, thanks for the pull request. Since dynamic properties are deprecated from 8.2, I think the best way forwards is to ensure we aren't using any in this library. The aim of this library (more recently) is to have stronger typing, so dynamic properties that come up over time (new additions to Packagist's API) would cause a deprecation warning for consumers, as they have done for you, and provide us an opportunity to update this library to suit.

From some quick testing on 8.2 I see there are a few properties that need to be added, which I've done locally, but I haven't found a package with avatarUrl in it as you've noted in #92. Do you have an example package name handy?

GrahamCampbell commented 11 months ago

There are actually many such errors. This was just the first one. We should probably skip setting these rather than setting them dynamically, since adding new fields on the server side is not considered a breaking change.

PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Maintainer::$avatarUrl is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Maintainer::$avatarUrl is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Maintainer::$avatarUrl is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Maintainer::$avatarUrl is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Version::$defaultBranch is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Version::$defaultBranch is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package\Version::$support is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package::$githubWatchers is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package::$githubWatchers is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package::$githubOpenIssues is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package::$githubOpenIssues is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
PHP Deprecated:  Creation of dynamic property Packagist\Api\Result\Package::$language is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19

Deprecated: Creation of dynamic property Packagist\Api\Result\Package::$language is deprecated in phar:///Users/graham/GitHub/GrahamCampbell/Packagist-Stats/bin/stats.phar/vendor/knplabs/packagist-api/src/Packagist/Api/Result/AbstractResult.php on line 19
GrahamCampbell commented 11 months ago

This error happens when looking at any package.

robbieaverill commented 11 months ago

We should probably skip setting these rather than setting them dynamically, since adding new fields on the server side is not considered a breaking change.

A reasonable suggestion!

I can see many of the warnings you've shown locally with the example scripts in this library, but avatarUrl is one I can't see. If you could share the package name that contains that property, that would be lovely. I haven't been able to find any examples that contain it in the Packagist API examples.

GrahamCampbell commented 11 months ago

Interesting. It has been there for 7 years. https://github.com/composer/packagist/commit/a6273428fc21a4bcfae081938092a9b90d25b5bd

robbieaverill commented 11 months ago

I've created a patch for the assignment of dynamic properties (treated as a bug now, in the past this was intended behaviour) at #96, and a new issue to add support for the new properties at #97. Thanks for the discussion @GrahamCampbell!