소스 검색

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
Inverle 1 일 전
부모
커밋
c8d859b88d
2개의 변경된 파일과 6개의 추가작업 그리고 6개의 파일을 삭제
  1. 3 3
      docs/en/developers/03_Backend/05_Extensions.md
  2. 3 3
      docs/fr/developers/03_Backend/05_Extensions.md

+ 3 - 3
docs/en/developers/03_Backend/05_Extensions.md

@@ -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;
 		}

+ 3 - 3
docs/fr/developers/03_Backend/05_Extensions.md

@@ -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;
 		}