Browse Source

phpstan analyse level 4

Chance 2 years ago
parent
commit
d6d3df3115
5 changed files with 9 additions and 3 deletions
  1. 1 1
      phpstan.neon
  2. 2 0
      src/Events/Event.php
  3. 1 0
      src/Events/Swow.php
  4. 2 2
      src/Protocols/Http/Request.php
  5. 3 0
      src/Worker.php

+ 1 - 1
phpstan.neon

@@ -1,5 +1,5 @@
 parameters:
-	level: 3
+	level: 4
 	paths:
 		- src
 		- tests

+ 2 - 0
src/Events/Event.php

@@ -166,6 +166,7 @@ class Event implements EventInterface
         $className = $this->eventClassName;
         $fdKey = (int)$stream;
         $event = new $this->eventClassName($this->eventBase, $stream, $className::READ | $className::PERSIST, $func, $stream);
+        // @phpstan-ignore-next-line Negated boolean expression is always false.
         if (!$event || !$event->add()) {
             return;
         }
@@ -194,6 +195,7 @@ class Event implements EventInterface
         $className = $this->eventClassName;
         $fdKey = (int)$stream;
         $event = new $this->eventClassName($this->eventBase, $stream, $className::WRITE | $className::PERSIST, $func, $stream);
+        // @phpstan-ignore-next-line Negated boolean expression is always false.
         if (!$event || !$event->add()) {
             return;
         }

+ 1 - 0
src/Events/Swow.php

@@ -85,6 +85,7 @@ class Swow implements EventInterface
         $t = max($t, 1);
         $that = $this;
         $coroutine = Coroutine::run(static function () use ($t, $func, $args, $that): void {
+            // @phpstan-ignore-next-line While loop condition is always true.
             while (true) {
                 msleep($t);
                 try {

+ 2 - 2
src/Protocols/Http/Request.php

@@ -303,11 +303,11 @@ class Request
     /**
      * Get/Set session id.
      *
-     * @param null $sessionId
+     * @param string|null $sessionId
      * @return string
      * @throws Exception
      */
-    public function sessionId($sessionId = null): string
+    public function sessionId(string $sessionId = null): string
     {
         if ($sessionId) {
             unset($this->sid);

+ 3 - 0
src/Worker.php

@@ -1686,6 +1686,7 @@ class Worker
     protected static function monitorWorkersForLinux(): void
     {
         static::$status = static::STATUS_RUNNING;
+        // @phpstan-ignore-next-line While loop condition is always true.
         while (1) {
             // Calls signal handlers for pending signals.
             pcntl_signal_dispatch();
@@ -2211,6 +2212,7 @@ class Worker
         if (!$stream) {
             $stream = static::$outputStream ?: STDOUT;
         }
+        // @phpstan-ignore-next-line Negated boolean expression is always false.
         if (!$stream || !is_resource($stream) || 'stream' !== get_resource_type($stream)) {
             return false;
         }
@@ -2550,6 +2552,7 @@ class Worker
                 if ($this->protocol !== null) {
                     /** @var ProtocolInterface $parser */
                     $parser = $this->protocol;
+                    // @phpstan-ignore-next-line Left side of && is always true.
                     if ($parser && method_exists($parser, 'input')) {
                         while ($recvBuffer !== '') {
                             $len = $parser::input($recvBuffer, $connection);