Skip to content

Commit 81fda05

Browse files
authored
[6.0] Workflow: use generic AbstractApplication in type hint (#43155)
1 parent e0cb7a8 commit 81fda05

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

libraries/src/Workflow/Workflow.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace Joomla\CMS\Workflow;
1111

12-
use Joomla\CMS\Application\CMSApplication;
12+
use Joomla\CMS\Application\CMSApplicationInterface;
1313
use Joomla\CMS\Event\AbstractEvent;
1414
use Joomla\CMS\Event\Workflow\WorkflowTransitionEvent;
1515
use Joomla\CMS\Extension\ComponentInterface;
@@ -18,6 +18,7 @@
1818
use Joomla\CMS\Table\Category;
1919
use Joomla\Database\DatabaseDriver;
2020
use Joomla\Database\ParameterType;
21+
use Joomla\Event\DispatcherAwareInterface;
2122
use Joomla\Registry\Registry;
2223
use Joomla\Utilities\ArrayHelper;
2324

@@ -50,7 +51,7 @@ class Workflow
5051
/**
5152
* Application Object
5253
*
53-
* @var CMSApplication
54+
* @var CMSApplicationInterface
5455
* @since 4.0.0
5556
*/
5657
protected $app;
@@ -98,13 +99,13 @@ class Workflow
9899
/**
99100
* Class constructor
100101
*
101-
* @param string $extension The extension name
102-
* @param ?CMSApplication $app Application Object
103-
* @param ?DatabaseDriver $db Database Driver Object
102+
* @param string $extension The extension name
103+
* @param ?CMSApplicationInterface $app Application Object
104+
* @param ?DatabaseDriver $db Database Driver Object
104105
*
105106
* @since 4.0.0
106107
*/
107-
public function __construct(string $extension, ?CMSApplication $app = null, ?DatabaseDriver $db = null)
108+
public function __construct(string $extension, ?CMSApplicationInterface $app = null, ?DatabaseDriver $db = null)
108109
{
109110
$this->extension = $extension;
110111

@@ -114,6 +115,10 @@ public function __construct(string $extension, ?CMSApplication $app = null, ?Dat
114115
$app = Factory::getApplication();
115116
}
116117

118+
if (!is_a($app, DispatcherAwareInterface::class)) {
119+
trigger_error('The given application object is not Dispatcher aware, which is mandatory.', E_ERROR);
120+
}
121+
117122
$this->app = $app;
118123

119124
if ($db === null) {

0 commit comments

Comments
 (0)