mollie / mollie-api-php

Mollie API client for PHP
http://www.mollie.com
BSD 2-Clause "Simplified" License
552 stars 191 forks source link

Code ResourceFactory.php not compatible with PHP 8.2 or higher #711

Closed bsconnect-nl closed 6 months ago

bsconnect-nl commented 7 months ago

https://github.com/mollie/mollie-api-php/blob/d7d09ac62a565e818bf49d04acb2f0432da758a9/src/Resources/ResourceFactory.php#L21C1-L22C1

Creation of dynamic property Mollie\Api\Resources\Method::$resource is deprecated

sandervanhooft commented 7 months ago

Hi @bsconnect-nl ,

Thanks for reporting this. Can you please share:

Looking at the GitHub test action running on php 8.2 I wouldn't expect this to happen, so your input would help us pinpoint the issue.

bsconnect-nl commented 7 months ago

Hi @sandervanhooft,

Thank you for your quick response!

The class BaseResource only knows these properties: $client and $resource. When trying to define a different value for $property in ResourceFactory line number 21, the error will occur.

Naoray commented 7 months ago

Hi @bsconnect-nl,

You are right that the BaseResource only has a few defined properties. However, by using the #[\AllowDynamicProperties] we are able to bypass the limitation that all properties need to be defined before runtime.

I have quickly run a test by using the orders endpoint $client->orders->page()[0]) which uses exactly the ResourceFactory@createFromApiResult() method where the line is defined that you mention as problematic.

I used php 8.2.16 and mollie-api-php version of 2.66.0 and I didn't receive any errors.

What was the exact code you executed when this error occurred?