laravel / forge-sdk

The official Laravel Forge PHP SDK.
https://forge.laravel.com
MIT License
528 stars 89 forks source link

Deprecated Properties in PHP 8.2 #158

Closed AntonCooper closed 1 year ago

AntonCooper commented 1 year ago

Forge SDK Version

3.13.3

Laravel Version

9.52.6

PHP Version

8.2.5

Database Driver & Version

No response

Description

I'm getting a lot of deprecation errors relating to dynamic properties when using PHP 8.2.

PHP Deprecated:  Creation of dynamic property Laravel\Forge\Resources\Server::$provider is deprecated in /Users/Code/vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
PHP Deprecated:  Creation of dynamic property Laravel\Forge\Resources\Server::$providerId is deprecated in /Users/Code/vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
PHP Deprecated:  Creation of dynamic property Laravel\Forge\Resources\Server::$ubuntuVersion is deprecated in /Users/Code/vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
PHP Deprecated:  Creation of dynamic property Laravel\Forge\Resources\Server::$dbStatus is deprecated in /Users/Code/vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
PHP Deprecated:  Creation of dynamic property Laravel\Forge\Resources\Server::$redisStatus is deprecated in /Users/Code/vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
PHP Deprecated:  Creation of dynamic property Laravel\Forge\Resources\Server::$phpCliVersion is deprecated in /Users/Code/vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
PHP Deprecated:  Creation of dynamic property Laravel\Forge\Resources\Server::$opcacheStatus is deprecated in /Users/Code/vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
PHP Deprecated:  Creation of dynamic property Laravel\Forge\Resources\Server::$databaseType is deprecated in /Users/Code/vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
PHP Deprecated:  Creation of dynamic property Laravel\Forge\Resources\Server::$sshPort is deprecated in /Users/Code/vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
PHP Deprecated:  Creation of dynamic property Laravel\Forge\Resources\Server::$localPublicKey is deprecated in /Users/Code/vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
PHP Deprecated:  Creation of dynamic property Laravel\Forge\Resources\Server::$phpVersions is deprecated in /Users/Code/vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48

Steps To Reproduce

use Laravel\Forge\Forge;

$api = new Forge(env('FORGE_API_KEY'));
$api->server(env('FORGE_SERVER_ID'));
driesvints commented 1 year ago

Afaik these are BC properties which aren't used anymore. See https://forge.laravel.com/api-documentation#get-server for a full Server object statement.

We cannot remove assignment for these in a current release as that would be a breaking change. We also can't add those properties since we don't want to advertise those any longer.

Since these are deprecation notices and no real errors we're going to let this one be for now. We can remove dynamic assignment in a next major release.

AntonCooper commented 1 year ago

You can't add the properties with a @deprecated annotation? That seems a better way to handle this rather than just saying anyone running the code on 8.2 needs to suppress/ignore these warnings. Alternatively a __set/__get solution might be appropriate. Maybe even a release for php ^8.0 which uses #[\AllowDynamicProperties] on the Resource class?

Since updating to 8.2 all of our Forge scripts for site provisioning are unreadable now. I could suppress deprecation warnings in the output but that would hide any other issues in other libraries which we use.

Below is a typical output from our script to provision a staging site to give you an idea of how noisy this is.


Creation of dynamic property Laravel\Forge\Resources\Server::$provider is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Server::$providerId is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Server::$ubuntuVersion is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Server::$dbStatus is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Server::$redisStatus is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Server::$phpCliVersion is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Server::$opcacheStatus is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Server::$databaseType is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Server::$sshPort is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Server::$localPublicKey is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Server::$phpVersions is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$phpVersion is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$telegramSecret is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$phpVersion is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$telegramSecret is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$phpVersion is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$telegramSecret is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$phpVersion is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$telegramSecret is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$phpVersion is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$telegramSecret is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$phpVersion is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$telegramSecret is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$phpVersion is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$telegramSecret is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$phpVersion is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$telegramSecret is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$phpVersion is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$telegramSecret is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$phpVersion is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$telegramSecret is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creating the new site in Forge...
Creation of dynamic property Laravel\Forge\Resources\Site::$phpVersion is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$telegramSecret is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$phpVersion is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$telegramSecret is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$phpVersion is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$telegramSecret is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$phpVersion is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$telegramSecret is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$phpVersion is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$telegramSecret is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$phpVersion is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$telegramSecret is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$phpVersion is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Site::$telegramSecret is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creating the .env file...
Setting up the deploy script...
Running the deploy script...
Creation of dynamic property Laravel\Forge\Resources\Site::$site is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
The deployment has been triggered and will run in the background. database setup may take a few minutes.
Setting up the schedule run...
Creation of dynamic property Laravel\Forge\Resources\Job::$nextRunTime is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Job::$nextRunTime is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Setting up the daemon...
Creation of dynamic property Laravel\Forge\Resources\Daemon::$directory is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Daemon::$processes is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Daemon::$startsecs is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Daemon::$stopwaitsecs is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Daemon::$stopsignal is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Daemon::$directory is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Daemon::$processes is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Daemon::$startsecs is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Daemon::$stopwaitsecs is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
Creation of dynamic property Laravel\Forge\Resources\Daemon::$stopsignal is deprecated in /home/runner/work/.../vendor/laravel/forge-sdk/src/Resources/Resource.php on line 48
The site has been successfully setup! Visit https://--- to access it.
driesvints commented 1 year ago

Using #[\AllowDynamicProperties] is a good idea. I've sent in a PR for that: https://github.com/laravel/forge-sdk/pull/159. Can you try that out to see if that works? I'm doubting a bit if it needs to be applied to each resource class. If so then we can do that as well. Then we'll remove it again in 4.x along with all dynamic property assignments.

AntonCooper commented 1 year ago

Yep, that works nicely for me. Not sure if it causes any issues for PHP 7.x though as attributes were not available before 8.0. The composer file allows installation on 7.2

driesvints commented 1 year ago

Normally it's just a comment for those https://3v4l.org/raheU#v7.4.33

driesvints commented 1 year ago

I released v3.13.4 with that change and the new PHP 8.2 install version.

AntonCooper commented 1 year ago

Amazing, thank you! Appreciate the quick turn around