Skip to content

Commit 1ecd438

Browse files
committed
Fix Phalcon 5.15 runtime compatibility
1 parent 408709f commit 1ecd438

2 files changed

Lines changed: 45 additions & 6 deletions

File tree

src/Dispatcher/AbstractDispatcher.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,50 @@
1313

1414
namespace PhalconKit\Dispatcher;
1515

16+
use Phalcon\Dispatcher\Exception as DispatcherException;
17+
18+
/**
19+
* Generic PhalconKit dispatcher helper.
20+
*
21+
* Native Phalcon 5.15 requires concrete dispatchers to implement the internal
22+
* exception hooks used by the dispatch loop. MVC and CLI dispatchers keep their
23+
* native specialized behavior; this generic wrapper provides a minimal
24+
* concrete implementation so shared helper behavior can still be tested and
25+
* used where no namespace-specific dispatcher is required.
26+
*/
1627
class AbstractDispatcher extends \Phalcon\Dispatcher\AbstractDispatcher implements DispatcherInterface
1728
{
1829
use DispatcherTrait;
30+
31+
/**
32+
* Bubble user exceptions unchanged for the generic dispatcher wrapper.
33+
*
34+
* Namespace-specific dispatchers can route exceptions through their
35+
* `dispatch:beforeException` event flow, but this base helper has no
36+
* controller/task domain to recover through.
37+
*
38+
* @param \Exception $exception Exception raised during dispatch.
39+
*
40+
* @throws \Exception Always rethrows the original exception.
41+
*/
42+
#[\Override]
43+
protected function handleException(\Exception $exception): never
44+
{
45+
throw $exception;
46+
}
47+
48+
/**
49+
* Raise a generic dispatcher exception for base-wrapper dispatch failures.
50+
*
51+
* @param string $message Diagnostic failure message.
52+
* @param int $exceptionCode Native dispatcher exception code.
53+
*
54+
* @throws DispatcherException Always throws the generated dispatcher
55+
* exception.
56+
*/
57+
#[\Override]
58+
protected function throwDispatchException(string $message, int $exceptionCode = 0): never
59+
{
60+
throw new DispatcherException($message, $exceptionCode);
61+
}
1962
}

src/Translate/Adapter/NestedNativeArray.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,6 @@ class NestedNativeArray extends AbstractAdapter implements \ArrayAccess
7272
*/
7373
private array $translate = [];
7474

75-
/**
76-
* Whether missing keys should throw instead of returning the original key.
77-
*/
78-
private bool $triggerError = false;
79-
8075
/**
8176
* Delimiter used when resolving nested translation paths.
8277
*
@@ -100,7 +95,7 @@ public function __construct(InterpolatorFactory $interpolator, array $options)
10095
{
10196
parent::__construct($interpolator, $options);
10297
$this->delimiter = $options['delimiter'] ?? $this->delimiter ?: '.';
103-
$this->triggerError = $options['triggerError'] ?? $this->triggerError;
98+
$this->triggerError = (bool)($options['triggerError'] ?? $this->triggerError);
10499
$this->translate = $options['content'] ?? $this->translate;
105100
}
106101

@@ -164,6 +159,7 @@ public function has(string $index): bool
164159
*
165160
* @throws RuntimeException When `triggerError` is true.
166161
*/
162+
#[\Override]
167163
public function notFound(string $index): string
168164
{
169165
if ($this->triggerError) {

0 commit comments

Comments
 (0)