From 8321c1cdd250c49c3b333f675d9b18baaccc214c Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Wed, 26 Jul 2023 17:08:21 +0200 Subject: [PATCH] Fix some PHPstan warnings for PHP 8 support --- example/includes/core.php | 2 +- skel/includes/core.php | 2 +- src/HookEvent.php | 5 +++++ src/Session.php | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/example/includes/core.php b/example/includes/core.php index f00b7f5..9940b31 100644 --- a/example/includes/core.php +++ b/example/includes/core.php @@ -9,7 +9,7 @@ error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED); // Root directory path $script = null; -if (defined('__FILE__') && constant('__FILE__')) { +if (defined('__FILE__') && constant('__FILE__')) { // @phpstan-ignore-line $script = __FILE__; } else { diff --git a/skel/includes/core.php b/skel/includes/core.php index f3f9420..7108884 100644 --- a/skel/includes/core.php +++ b/skel/includes/core.php @@ -8,7 +8,7 @@ error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED); // Root directory path $script = null; -if (defined('__FILE__') && constant('__FILE__')) { +if (defined('__FILE__') && constant('__FILE__')) { // @phpstan-ignore-line $script = __FILE__; } else { diff --git a/src/HookEvent.php b/src/HookEvent.php index e819b5e..cd03003 100644 --- a/src/HookEvent.php +++ b/src/HookEvent.php @@ -23,6 +23,11 @@ class HookEvent implements JsonSerializable { return null; } + /** + * Return data to serialize a HookEvent object as JSON + * @return array + */ + #[\ReturnTypeWillChange] public function jsonSerialize() { return array ( 'name' => $this -> name, diff --git a/src/Session.php b/src/Session.php index 42036a7..1f08849 100644 --- a/src/Session.php +++ b/src/Session.php @@ -21,6 +21,7 @@ class Session { // In CLI or Phpstan context, do not initialize if ( php_sapi_name() == "cli" + // @phpstan-ignore-next-line || (defined('__PHPSTAN_RUNNING__') && constant('__PHPSTAN_RUNNING__')) ) return;