Update registerHook docs with newer PHP 8.1+ syntax for callables (#9443)

* Update registerHook docs with newer PHP 8.1+ syntax for callables

* Use the correct function name for the second hook

* Use correct return type for the second hook function
This commit is contained in:
Inverle authored and GitHub committed 2026-10-15 19:51:52 +02:00
1 parent ed34f6a21d
commit c8d859b88d
2 files changed
+6 -6

No files matched your search

@@ -146,8 +146,8 @@ final class HelloWorldExtension extends Minz_Extension
public function init(): void {
parent::init();
$this->registerHook(Minz_HookType::EntryBeforeDisplay, [$this, 'renderEntry'], 10);
$this->registerHook(Minz_HookType::CheckUrlBeforeAdd, [self::class, 'checkUrl'], -10);
$this->registerHook(Minz_HookType::EntryBeforeDisplay, $this->renderEntry(...), 10);
$this->registerHook(Minz_HookType::CheckUrlBeforeAdd, self::checkUrlBeforeAdd(...), -10);
}
public function renderEntry(FreshRSS_Entry $entry): FreshRSS_Entry {
@@ -156,7 +156,7 @@ final class HelloWorldExtension extends Minz_Extension
return $entry;
}
public static function checkUrlBeforeAdd(string $url): string {
public static function checkUrlBeforeAdd(string $url): ?string {
if (str_starts_with($url, 'https://')) {
return $url;
}
@@ -200,8 +200,8 @@ final class HelloWorldExtension extends Minz_Extension
public function init(): void {
parent::init();
$this->registerHook(Minz_HookType::EntryBeforeDisplay, [$this, 'renderEntry'], 10);
$this->registerHook(Minz_HookType::CheckUrlBeforeAdd, [self::class, 'checkUrl'], -10);
$this->registerHook(Minz_HookType::EntryBeforeDisplay, $this->renderEntry(...), 10);
$this->registerHook(Minz_HookType::CheckUrlBeforeAdd, self::checkUrlBeforeAdd(...), -10);
}
public function renderEntry(FreshRSS_Entry $entry): FreshRSS_Entry {
@@ -210,7 +210,7 @@ final class HelloWorldExtension extends Minz_Extension
return $entry;
}
public static function checkUrlBeforeAdd(string $url): string {
public static function checkUrlBeforeAdd(string $url): ?string {
if (str_starts_with($url, 'https://')) {
return $url;
}