Skip to content

Commit b487fd2

Browse files
bcordisclaude
andcommitted
fix: add AbstractImmutableEvent shim to resolve v4 Event signature conflict
Joomla 5.4.x CMS source has offsetSet() without :void return type but joomla/event v4.0 requires it. Pre-define a compatible shim in CmsRuntimeShims.php that satisfies both, loaded before the CMS source autoloader. Also includes AbstractEvent::create() factory method needed by Table::check() and Table::delete() event dispatching. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent faa0bb5 commit b487fd2

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

tests/unit/Stubs/CmsRuntimeShims.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,35 @@
1717
// phpcs:disable PSR1.Classes.ClassDeclaration.MultipleClasses
1818
// phpcs:disable PSR1.Files.SideEffects
1919

20+
namespace Joomla\CMS\Event {
21+
22+
/**
23+
* Shim for AbstractImmutableEvent — Joomla 5.4.x CMS source has offsetSet()
24+
* without : void return type, but joomla/event v4.0 requires it.
25+
* This shim provides a compatible definition that satisfies both.
26+
*/
27+
class AbstractImmutableEvent extends \Joomla\Event\AbstractEvent
28+
{
29+
public function offsetSet($name, $value): void
30+
{
31+
throw new \BadMethodCallException('Immutable event');
32+
}
33+
34+
public function offsetUnset($name): void
35+
{
36+
throw new \BadMethodCallException('Immutable event');
37+
}
38+
}
39+
40+
class AbstractEvent extends AbstractImmutableEvent
41+
{
42+
public static function create(string $eventName, array $arguments = [])
43+
{
44+
return new static($eventName, $arguments);
45+
}
46+
}
47+
}
48+
2049
namespace Joomla\CMS {
2150

2251
class Factory

tests/unit/bootstrap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
// IMPORTANT: This autoloader is appended (not prepended) so our Composer
158158
// autoloader always wins for framework classes like Joomla\Database\*.
159159
spl_autoload_register(function ($class) use ($rootDir) {
160+
160161
// Joomla\CMS\ → libraries/src/
161162
$cmsPrefix = 'Joomla\\CMS\\';
162163

0 commit comments

Comments
 (0)