Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creation of dynamic property Fastly\Configuration::$apiKeys is deprecated #51

Open
lucasfilippi opened this issue Jan 14, 2025 · 0 comments

Comments

@lucasfilippi
Copy link

With PHP 8.2 , dynamic properties are deprecated so your exact snippet is not working anymore :

$config = Fastly\Configuration::getDefaultConfiguration()->setApiToken('YOUR_API_TOKEN');

Resulting in my unit test

ErrorException: Creation of dynamic property Fastly\Configuration::$apiKeys is deprecated in /usr/src/app/vendor/fastly/fastly/lib/Configuration.php:193
Stack trace:
#0 /usr/src/app/vendor/fastly/fastly/lib/Configuration.php(193): custom_error_handler()
#1 /usr/src/app/app/common/services/v1/FastlyService.php(30): Fastly\Configuration->setApiToken()
#2 /usr/src/app/app/common/library/Traits/Singleton.php(27): Services\v1\FastlyService->__construct()
#3 /usr/src/app/app/common/library/Helper/Cache.php(186): Services\v1\FastlyService::getInstance()
#4 /usr/src/app/app/common/library/PubSub/ArticleHandler.php(580): LeMonde\Helper\Cache::uncacheArticle()
#5 /usr/src/app/app/common/library/PubSub/ArticleHandler.php(116): LeMonde\PubSub\ArticleHandler->deleteCache()
#6 /usr/src/app/tests/php/common/library/PubSub/AbstractHandlerTester.php(47): LeMonde\PubSub\ArticleHandler->handleRaw()
#7 /usr/src/app/vendor/phpunit/phpunit/src/Framework/TestCase.php(1234): LeMonde\PubSub\AbstractHandlerTester->testHandleRaw()
#8 /usr/src/app/vendor/phpunit/phpunit/src/Framework/TestCase.php(515): PHPUnit\Framework\TestCase->runTest()
#9 /usr/src/app/vendor/phpunit/phpunit/src/Framework/TestRunner/TestRunner.php(86): PHPUnit\Framework\TestCase->runBare()
#10 /usr/src/app/vendor/phpunit/phpunit/src/Framework/TestCase.php(362): PHPUnit\Framework\TestRunner->run()
#11 /usr/src/app/vendor/phpunit/phpunit/src/Framework/TestSuite.php(369): PHPUnit\Framework\TestCase->run()
#12 /usr/src/app/vendor/phpunit/phpunit/src/Framework/TestSuite.php(369): PHPUnit\Framework\TestSuite->run()
#13 /usr/src/app/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(64): PHPUnit\Framework\TestSuite->run()
#14 /usr/src/app/vendor/phpunit/phpunit/src/TextUI/Application.php(210): PHPUnit\TextUI\TestRunner->run()
#15 /usr/src/app/vendor/phpunit/phpunit/phpunit(104): PHPUnit\TextUI\Application->run()
#16 /usr/src/app/vendor/bin/phpunit(122): include('...')
#17 {main}

You have to either use #[\AllowDynamicProperties] on your class or declare the property private array $apiKeys = [];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant