@@ -6,38 +6,38 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Stash |
| 8 | 8 | { |
| 9 | - /** |
|
| 9 | +/** |
|
| 10 | 10 | * @var array |
| 11 | 11 | */ |
| 12 | - private array $values = []; |
|
| 12 | +private array $values = []; |
|
| 13 | 13 | |
| 14 | - /** |
|
| 14 | +/** |
|
| 15 | 15 | * @param string $key |
| 16 | 16 | * @param mixed $value |
| 17 | 17 | * |
| 18 | 18 | * @return void |
| 19 | 19 | */ |
| 20 | - public function set(string $key, mixed $value): void |
|
| 21 | - { |
|
| 22 | - $this->values[$key] = $value; |
|
| 23 | - } |
|
| 20 | +public function set(string $key, mixed $value): void |
|
| 21 | +{ |
|
| 22 | +$this->values[$key] = $value; |
|
| 23 | +} |
|
| 24 | 24 | |
| 25 | - /** |
|
| 25 | +/** |
|
| 26 | 26 | * @param string $key |
| 27 | 27 | * @param mixed $default |
| 28 | 28 | * |
| 29 | 29 | * @return mixed |
| 30 | 30 | */ |
| 31 | - public function get(string $key, mixed $default = null): mixed |
|
| 32 | - { |
|
| 33 | - $value = $this->values[$key] ?? $default; |
|
| 34 | - if(is_callable($value)) |
|
| 35 | - { |
|
| 36 | - $value = $value(); |
|
| 37 | - // Save the value returned by the callback in the stash. |
|
| 38 | - $this->values[$key] = $value; |
|
| 39 | - } |
|
| 31 | +public function get(string $key, mixed $default = null): mixed |
|
| 32 | +{ |
|
| 33 | +$value = $this->values[$key] ?? $default; |
|
| 34 | +if(is_callable($value)) |
|
| 35 | +{ |
|
| 36 | +$value = $value(); |
|
| 37 | +// Save the value returned by the callback in the stash. |
|
| 38 | +$this->values[$key] = $value; |
|
| 39 | +} |
|
| 40 | 40 | |
| 41 | - return $value; |
|
| 42 | - } |
|
| 41 | +return $value; |
|
| 42 | +} |
|
| 43 | 43 | } |
@@ -16,11 +16,11 @@ |
||
| 16 | 16 | |
| 17 | 17 | class AfterData extends HookData |
| 18 | 18 | { |
| 19 | - /** |
|
| 19 | +/** |
|
| 20 | 20 | * @inheritDoc |
| 21 | 21 | */ |
| 22 | - protected function getType(): string |
|
| 23 | - { |
|
| 24 | - return 'after'; |
|
| 25 | - } |
|
| 22 | +protected function getType(): string |
|
| 23 | +{ |
|
| 24 | +return 'after'; |
|
| 25 | +} |
|
| 26 | 26 | } |
@@ -16,11 +16,11 @@ |
||
| 16 | 16 | |
| 17 | 17 | class BeforeData extends HookData |
| 18 | 18 | { |
| 19 | - /** |
|
| 19 | +/** |
|
| 20 | 20 | * @inheritDoc |
| 21 | 21 | */ |
| 22 | - protected function getType(): string |
|
| 23 | - { |
|
| 24 | - return 'before'; |
|
| 25 | - } |
|
| 22 | +protected function getType(): string |
|
| 23 | +{ |
|
| 24 | +return 'before'; |
|
| 25 | +} |
|
| 26 | 26 | } |
@@ -30,16 +30,16 @@ |
||
| 30 | 30 | |
| 31 | 31 | abstract class AbstractRequestPlugin extends AbstractPlugin implements CallableRegistryInterface, RequestHandlerInterface |
| 32 | 32 | { |
| 33 | - /** |
|
| 33 | +/** |
|
| 34 | 34 | * @var Target |
| 35 | 35 | */ |
| 36 | - protected $xTarget = null; |
|
| 36 | +protected $xTarget = null; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 38 | +/** |
|
| 39 | 39 | * @inheritDoc |
| 40 | 40 | */ |
| 41 | - public function getTarget(): ?Target |
|
| 42 | - { |
|
| 43 | - return $this->xTarget; |
|
| 44 | - } |
|
| 41 | +public function getTarget(): ?Target |
|
| 42 | +{ |
|
| 43 | +return $this->xTarget; |
|
| 44 | +} |
|
| 45 | 45 | } |
@@ -7,21 +7,21 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | interface RequestHandlerInterface |
| 9 | 9 | { |
| 10 | - /** |
|
| 10 | +/** |
|
| 11 | 11 | * Get the target function or class and method |
| 12 | 12 | * |
| 13 | 13 | * @return Target|null |
| 14 | 14 | */ |
| 15 | - public function getTarget(): ?Target; |
|
| 15 | +public function getTarget(): ?Target; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 17 | +/** |
|
| 18 | 18 | * @param ServerRequestInterface $xRequest |
| 19 | 19 | * |
| 20 | 20 | * @return Target |
| 21 | 21 | */ |
| 22 | - public function setTarget(ServerRequestInterface $xRequest): Target; |
|
| 22 | +public function setTarget(ServerRequestInterface $xRequest): Target; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | +/** |
|
| 25 | 25 | * Check if this plugin can process the current request |
| 26 | 26 | * |
| 27 | 27 | * Called by the <Jaxon\Plugin\RequestManager> when a request has been received to determine |
@@ -31,9 +31,9 @@ discard block |
||
| 31 | 31 | * |
| 32 | 32 | * @return bool |
| 33 | 33 | */ |
| 34 | - public static function canProcessRequest(ServerRequestInterface $xRequest): bool; |
|
| 34 | +public static function canProcessRequest(ServerRequestInterface $xRequest): bool; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 36 | +/** |
|
| 37 | 37 | * Process the current request |
| 38 | 38 | * |
| 39 | 39 | * Called by the <Jaxon\Plugin\RequestManager> when a request is being processed. |
@@ -42,5 +42,5 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @return void |
| 44 | 44 | */ |
| 45 | - public function processRequest(): void; |
|
| 45 | +public function processRequest(): void; |
|
| 46 | 46 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | abstract class AbstractAnnotation extends Annotation implements IAnnotationParser |
| 22 | 22 | { |
| 23 | - /** |
|
| 23 | +/** |
|
| 24 | 24 | * Save the annotation value |
| 25 | 25 | * |
| 26 | 26 | * @param Metadata $xMetadata |
@@ -28,5 +28,5 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @return void |
| 30 | 30 | */ |
| 31 | - abstract public function saveValue(Metadata $xMetadata, string $sMethod = '*'): void; |
|
| 31 | +abstract public function saveValue(Metadata $xMetadata, string $sMethod = '*'): void; |
|
| 32 | 32 | } |
@@ -18,22 +18,22 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | class TemplateView implements ViewInterface |
| 20 | 20 | { |
| 21 | - /** |
|
| 21 | +/** |
|
| 22 | 22 | * The Jaxon template engine |
| 23 | 23 | * |
| 24 | 24 | * @var TemplateEngine |
| 25 | 25 | */ |
| 26 | - protected $xTemplateEngine; |
|
| 26 | +protected $xTemplateEngine; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 28 | +/** |
|
| 29 | 29 | * The class constructor |
| 30 | 30 | */ |
| 31 | - public function __construct(TemplateEngine $xTemplateEngine) |
|
| 32 | - { |
|
| 33 | - $this->xTemplateEngine = $xTemplateEngine; |
|
| 34 | - } |
|
| 31 | +public function __construct(TemplateEngine $xTemplateEngine) |
|
| 32 | +{ |
|
| 33 | +$this->xTemplateEngine = $xTemplateEngine; |
|
| 34 | +} |
|
| 35 | 35 | |
| 36 | - /** |
|
| 36 | +/** |
|
| 37 | 37 | * Add a namespace to this view renderer |
| 38 | 38 | * |
| 39 | 39 | * @param string $sNamespace The namespace name |
@@ -42,28 +42,28 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @return void |
| 44 | 44 | */ |
| 45 | - public function addNamespace(string $sNamespace, string $sDirectory, string $sExtension = ''): void |
|
| 46 | - { |
|
| 47 | - $this->xTemplateEngine->addNamespace($sNamespace, $sDirectory, $sExtension); |
|
| 48 | - } |
|
| 45 | +public function addNamespace(string $sNamespace, string $sDirectory, string $sExtension = ''): void |
|
| 46 | +{ |
|
| 47 | +$this->xTemplateEngine->addNamespace($sNamespace, $sDirectory, $sExtension); |
|
| 48 | +} |
|
| 49 | 49 | |
| 50 | - /** |
|
| 50 | +/** |
|
| 51 | 51 | * Render a view |
| 52 | 52 | * |
| 53 | 53 | * @param Store $store A store populated with the view data |
| 54 | 54 | * |
| 55 | 55 | * @return string The string representation of the view |
| 56 | 56 | */ |
| 57 | - public function render(Store $store): string |
|
| 58 | - { |
|
| 59 | - $sViewName = $store->getViewName(); |
|
| 60 | - $sNamespace = $store->getNamespace(); |
|
| 61 | - // In this view renderer, the namespace must always be prepended to the view name. |
|
| 62 | - if(substr($sViewName, 0, strlen($sNamespace) + 2) != $sNamespace . '::') |
|
| 63 | - { |
|
| 64 | - $sViewName = $sNamespace . '::' . $sViewName; |
|
| 65 | - } |
|
| 66 | - // Render the template |
|
| 67 | - return trim($this->xTemplateEngine->render($sViewName, $store->getViewData()), " \t\n"); |
|
| 68 | - } |
|
| 57 | +public function render(Store $store): string |
|
| 58 | +{ |
|
| 59 | +$sViewName = $store->getViewName(); |
|
| 60 | +$sNamespace = $store->getNamespace(); |
|
| 61 | +// In this view renderer, the namespace must always be prepended to the view name. |
|
| 62 | +if(substr($sViewName, 0, strlen($sNamespace) + 2) != $sNamespace . '::') |
|
| 63 | +{ |
|
| 64 | +$sViewName = $sNamespace . '::' . $sViewName; |
|
| 65 | +} |
|
| 66 | +// Render the template |
|
| 67 | +return trim($this->xTemplateEngine->render($sViewName, $store->getViewData()), " \t\n"); |
|
| 68 | +} |
|
| 69 | 69 | } |
@@ -6,17 +6,17 @@ |
||
| 6 | 6 | |
| 7 | 7 | interface ResponsePluginInterface |
| 8 | 8 | { |
| 9 | - /** |
|
| 9 | +/** |
|
| 10 | 10 | * Get the attached response |
| 11 | 11 | * |
| 12 | 12 | * @return AbstractResponse|null |
| 13 | 13 | */ |
| 14 | - public function response(): ?AbstractResponse; |
|
| 14 | +public function response(): ?AbstractResponse; |
|
| 15 | 15 | |
| 16 | - /** |
|
| 16 | +/** |
|
| 17 | 17 | * @param AbstractResponse $xResponse The response |
| 18 | 18 | * |
| 19 | 19 | * @return static |
| 20 | 20 | */ |
| 21 | - public function initPlugin(AbstractResponse $xResponse): static; |
|
| 21 | +public function initPlugin(AbstractResponse $xResponse): static; |
|
| 22 | 22 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | interface CallableRegistryInterface |
| 6 | 6 | { |
| 7 | - /** |
|
| 7 | +/** |
|
| 8 | 8 | * Check if the provided options are correct, and convert them into an array. |
| 9 | 9 | * |
| 10 | 10 | * @param string $sCallable |
@@ -12,9 +12,9 @@ discard block |
||
| 12 | 12 | * |
| 13 | 13 | * @return array |
| 14 | 14 | */ |
| 15 | - public function checkOptions(string $sCallable, $xOptions): array; |
|
| 15 | +public function checkOptions(string $sCallable, $xOptions): array; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 17 | +/** |
|
| 18 | 18 | * Register a callable entity: a function or a class. |
| 19 | 19 | * |
| 20 | 20 | * Called by the <Jaxon\Plugin\RequestManager> when a user script |
@@ -27,14 +27,14 @@ discard block |
||
| 27 | 27 | * |
| 28 | 28 | * @return bool |
| 29 | 29 | */ |
| 30 | - public function register(string $sType, string $sCallable, array $aOptions): bool; |
|
| 30 | +public function register(string $sType, string $sCallable, array $aOptions): bool; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 32 | +/** |
|
| 33 | 33 | * Get the callable object for a registered item |
| 34 | 34 | * |
| 35 | 35 | * @param string $sCallable |
| 36 | 36 | * |
| 37 | 37 | * @return mixed |
| 38 | 38 | */ |
| 39 | - public function getCallable(string $sCallable): mixed; |
|
| 39 | +public function getCallable(string $sCallable): mixed; |
|
| 40 | 40 | } |