Skip to content

Commit

Permalink
Fixes "Creation of dynamic property Zend_Controller_Action::$ajaxable…
Browse files Browse the repository at this point in the history
… is deprecated"
  • Loading branch information
marcing committed Mar 19, 2024
1 parent 7f31369 commit ab64d58
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/zend-controller/library/Zend/Controller/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ abstract class Zend_Controller_Action implements Zend_Controller_Action_Interfac
* @var array
*/
public $contexts;

/**
* Controller's ajaxable, managed by Zend_Controller_Action_Helper_AjaxContext
* @var array
*/
public $ajaxable;

/**
* Class constructor
Expand Down
23 changes: 23 additions & 0 deletions tests/Zend/Controller/Action/Helper/AjaxContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,25 @@ public function tearDown()
unset($_SERVER['HTTP_X_REQUESTED_WITH']);
}
}

public function testAddActionContext()
{
// test covering PHP 8.2+ changes:
// Creation of dynamic property ::$ajaxable is deprecated
$controller = new Zend_Controller_Action_Helper_AjaxContextNoConfigTestController(
$this->request,
$this->response,
array()
);
$this->helper->setActionController($controller);

$this->helper
->addActionContext('error', 'html')
->initContext('html');

$actionContexts = $this->helper->getActionContexts('error');
$this->assertEquals('html', $actionContexts[0]);
}

public function testDefaultContextsIncludesHtml()
{
Expand Down Expand Up @@ -293,6 +312,10 @@ class Zend_Controller_Action_Helper_AjaxContextTestController extends Zend_Contr
);
}

class Zend_Controller_Action_Helper_AjaxContextNoConfigTestController extends Zend_Controller_Action
{
}

class Zend_Controller_Action_Helper_AjaxContextTest_LayoutOverride extends Zend_Layout
{
public static function resetMvcInstance()
Expand Down

0 comments on commit ab64d58

Please sign in to comment.