From 0c12a338c0cfa9f030fcb0208e17d4f8719786fd Mon Sep 17 00:00:00 2001 From: Nikolaos Dimopoulos Date: Mon, 17 Jul 2023 12:27:40 -0400 Subject: [PATCH 1/3] Added stdClass to Injectable --- phalcon/Di/Injectable.zep | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phalcon/Di/Injectable.zep b/phalcon/Di/Injectable.zep index 51a262c463e..fdca331f6ab 100644 --- a/phalcon/Di/Injectable.zep +++ b/phalcon/Di/Injectable.zep @@ -10,6 +10,7 @@ namespace Phalcon\Di; +use stdClass; use Phalcon\Di\Di; use Phalcon\Session\BagInterface; @@ -42,7 +43,7 @@ use Phalcon\Session\BagInterface; * @property \Phalcon\Session\Bag|\Phalcon\Session\BagInterface $persistent * @property \Phalcon\Mvc\View|\Phalcon\Mvc\ViewInterface $view */ -abstract class Injectable implements InjectionAwareInterface +abstract class Injectable extends stdClass implements InjectionAwareInterface { /** * Dependency Injector From 064ccd37bc3915d0fde6f87a358f72fe85d4da70 Mon Sep 17 00:00:00 2001 From: Nikolaos Dimopoulos Date: Mon, 17 Jul 2023 12:27:52 -0400 Subject: [PATCH 2/3] Adding test for php 8.2 deprecation warning --- .../integration/Mvc/Micro/GetServiceCest.php | 76 ++++++++++++------- 1 file changed, 50 insertions(+), 26 deletions(-) diff --git a/tests/integration/Mvc/Micro/GetServiceCest.php b/tests/integration/Mvc/Micro/GetServiceCest.php index 0ed85adba6c..6369ba801ae 100644 --- a/tests/integration/Mvc/Micro/GetServiceCest.php +++ b/tests/integration/Mvc/Micro/GetServiceCest.php @@ -13,59 +13,83 @@ namespace Phalcon\Tests\Integration\Mvc\Micro; +use ErrorException; use IntegrationTester; use Phalcon\Di\Di; +use Phalcon\Di\FactoryDefault; use Phalcon\Html\Escaper; +use Phalcon\Http\Request; use Phalcon\Mvc\Dispatcher; use Phalcon\Mvc\Micro; use Phalcon\Mvc\Router; +use function restore_error_handler; +use function set_error_handler; + class GetServiceCest { /** * Tests Phalcon\Mvc\Micro :: getService() * - * @author Sid Roberts + * @author Phalcon Team * @since 2019-05-22 */ public function mvcMicroGetService(IntegrationTester $I) { $I->wantToTest('Mvc\Micro - getService()'); - $micro = new Micro(); - - $di = new Di(); - - $micro->setDi($di); - - - $escaper = new Escaper(); - + $micro = new Micro(); + $container = new Di(); + $escaper = new Escaper(); + $micro->setDi($container); $micro->setService('escaper', $escaper); - $I->assertSame( - $escaper, - $micro->getService('escaper') - ); - + $expected = $escaper; + $actual = $micro->getService('escaper'); + $I->assertSame($expected, $actual); $dispatcher = new Dispatcher(); - $micro['dispatcher'] = $dispatcher; - $I->assertSame( - $dispatcher, - $micro->getService('dispatcher') - ); - + $expected = $dispatcher; + $actual = $micro->getService('dispatcher'); + $I->assertSame($expected, $actual); $router = new Router(); + $container->set('router', $router); - $di->set('router', $router); - - $I->assertSame( - $router, - $micro->getService('router') + $expected = $router; + $actual = $micro->getService('router'); + $I->assertSame($expected, $actual); + } + /** + * Tests after binding event + * + * @author Phalcon Team + * @since 2023-07-03 + */ + public function mvcMicroGetServiceWithProperty(IntegrationTester $I) + { + $container = new FactoryDefault(); + $micro = new Micro($container); + $error = ''; + + set_error_handler( + function ($number, $message, $file, $line) { + throw new ErrorException($message, 0, $number, $file, $line); + } ); + + try { + $class = Request::class; + $request = $micro->request; + $I->assertInstanceOf($class, $request); + } catch (ErrorException $ex) { + $error = $ex->getMessage(); + } + + restore_error_handler(); + + $I->assertEmpty($error); } } From 58e25db065f87101f097a38781f452c3765daa66 Mon Sep 17 00:00:00 2001 From: Nikolaos Dimopoulos Date: Mon, 17 Jul 2023 12:46:18 -0400 Subject: [PATCH 3/3] updating changelog --- CHANGELOG-5.0.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG-5.0.md b/CHANGELOG-5.0.md index ca9af17a6f2..42cf60f5015 100644 --- a/CHANGELOG-5.0.md +++ b/CHANGELOG-5.0.md @@ -5,6 +5,7 @@ ### Fixed - Tried to reproduce the behavior described in #16244 but had no success. [#16244](https://github.com/phalcon/cphalcon/issues/16244) - Added `getAdapter()` in `Phalcon\Mvc\Model\Metadata` to retrieve the internal cache adapter if necessary. [#16244](https://github.com/phalcon/cphalcon/issues/16244) +- Extended `Phalcon\Di\Injectable` from `stdClass` to remove the deprecation warning (dynamic properties) for PHP 8.2 [#16308](https://github.com/phalcon/cphalcon/issues/16308) ## [5.2.2](https://github.com/phalcon/cphalcon/releases/tag/v5.2.2) (2023-06-18)