10up / wp_mock

WordPress API Mocking Framework
https://wp-mock.gitbook.io
Other
676 stars 70 forks source link

PHP 8.2 Dynamic Property Deprecation #204

Closed rneudorf-godaddy closed 1 year ago

rneudorf-godaddy commented 1 year ago

Bug report

In PHP 8.2 dynamic property declaring is deprecated (doc).

When Mocking classes that are unavailable (ex. WP, WP_Post) PHP 8.2 will throw a "Creation of dynamic property...is deprecated" error, causing tests to fail.

Related

Replication steps

Run vendor/bin/phpunit under PHP 8.2.

The following tests fail:

There were 2 errors:

1) WP_Mock\Tests\Unit\WP_Mock\Traits\MockWordPressObjectsTraitTest::testCanMockWordPressPost
Creation of dynamic property Mockery_2__WP_Post::$ID is deprecated

/Users/rneudorf/Projects/godaddy/wp_mock/php/WP_Mock/Traits/MockWordPressObjectsTrait.php:45
/Users/rneudorf/Projects/godaddy/wp_mock/php/WP_Mock/Traits/MockWordPressObjectsTrait.php:43
/Users/rneudorf/Projects/godaddy/wp_mock/tests/Unit/WP_Mock/Traits/MockWordPressObjectsTraitTest.php:50

2) WP_Mock\Tests\Unit\WP_Mock\Traits\MockWordPressObjectsTraitTest::testCanMockWordPressInstance
Creation of dynamic property Mockery_3__WP::$query_vars is deprecated

/Users/rneudorf/Projects/godaddy/wp_mock/php/WP_Mock/Traits/MockWordPressObjectsTrait.php:61
/Users/rneudorf/Projects/godaddy/wp_mock/tests/Unit/WP_Mock/Traits/MockWordPressObjectsTraitTest.php:73

Expected behavior

All tests pass.

rneudorf-godaddy commented 1 year ago

This should be resolved by https://github.com/mockery/mockery/pull/1210