symbiote / silverstripe-phpstan

Extend PHPStan (PHP Static Analysis) to support SilverStripe projects
BSD 3-Clause "New" or "Revised" License
12 stars 13 forks source link

Error when running with silverstripe 4.5 and php 7.4 #24

Open KallivdH opened 3 years ago

KallivdH commented 3 years ago
PHP Notice:  Undefined index: SERVER_PROTOCOL in /data/site/vendor/silverstripe/framework/src/Control/HTTPResponse.php on line 144
PHP Notice:  Undefined index: SERVER_PROTOCOL in /data/site/vendor/silverstripe/framework/src/Control/HTTPResponse.php on line 380
ERROR [Notice]: Undefined index: SERVER_PROTOCOL
IN  
Line 144 in /data/site/vendor/silverstripe/framework/src/Control/HTTPResponse.php

Source
======
  135:      * @param string $protocolVersion
  136:      */
  137:     public function __construct($body = null, $statusCode = null, $statusDescription = null,
       $protocolVersion = null)
  138:     {
  139:         $this->setBody($body);
  140:         if ($statusCode) {
  141:             $this->setStatusCode($statusCode, $statusDescription);
  142:         }
  143:         if (!$protocolVersion) {
* 144:             if (preg_match('/HTTP\/(?<version>\d+(\.\d+)?)/i', $_SERVER['SERVER_PROTOCOL'],
       $matches)) {
  145:                 $protocolVersion = $matches['version'];
  146:             }
  147:         }
  148:         if ($protocolVersion) {
  149:             $this->setProtocolVersion($protocolVersion);
  150:         }

Trace
=====
Monolog\ErrorHandler->handleError(8, Undefined index: SERVER_PROTOCOL, /data/site/vendor/silverstripe/framework/src/Control/HTTPResponse.php, 144, Array)
HTTPResponse.php:144

SilverStripe\Control\HTTPResponse->__construct()
HTTPOutputHandler.php:153

SilverStripe\Logging\HTTPOutputHandler->write(Array)
AbstractProcessingHandler.php:39

Monolog\Handler\AbstractProcessingHandler->handle(Array)
Logger.php:344

Monolog\Logger->addRecord(550, Fatal Error (E_COMPILE_ERROR): Declaration of SilbinaryWolf\SilverstripePHPStan\Reflection\MethodClassReflectionExtension::setBroker(PHPStan\Broker\Broker $broker) must be compatible with PHPStan\Reflection\BrokerAwareExtension::setBroker(PHPStan\Broker\Broker $broker): void, Array)
Logger.php:614

Monolog\Logger->log(550, Fatal Error (E_COMPILE_ERROR): Declaration of SilbinaryWolf\SilverstripePHPStan\Reflection\MethodClassReflectionExtension::setBroker(PHPStan\Broker\Broker $broker) must be compatible with PHPStan\Reflection\BrokerAwareExtension::setBroker(PHPStan\Broker\Broker $broker): void, Array)
ErrorHandler.php:189

Monolog\ErrorHandler->handleFatalError()

PHP Notice:  Undefined index: SERVER_PROTOCOL in /data/site/vendor/silverstripe/framework/src/Control/HTTPResponse.php on line 144
ERROR [UNKNOWN TYPE, ERRNO 64]: Declaration of SilbinaryWolf\SilverstripePHPStan\Reflection\MethodClassReflectionExtension::setBroker(PHPStan\Broker\Broker $broker) must be compatible with PHPStan\Reflection\BrokerAwareExtension::setBroker(PHPStan\Broker\Broker $broker): void
IN  
Line 53 in /data/site/vendor/symbiote/silverstripe-phpstan/src/Reflection/MethodClassReflectionExtension.php

Source
======
  44:      public function getMethod(ClassReflection $classReflection, string $methodName):
       MethodReflection
  45:      {
  46:          if (!isset($this->methods[$classReflection->getName()])) {
  47:              $this->methods[$classReflection->getName()] = $this->createMethods($classReflection);
  48:          }
  49:          // Fallback to has_one/has_many/many_many
  50:          return $this->methods[$classReflection->getName()][strtolower($methodName)];
  51:      }
  52:  
* 53:      public function setBroker(Broker $broker)
  54:      {
  55:          $this->broker = $broker;
  56:      }
  57:  
  58:      /**
  59:       * @param ClassReflection $classReflection

Trace
=====
SilverStripe\Dev\CliDebugView->renderTrace()
DetailedErrorFormatter.php:119

SilverStripe\Logging\DetailedErrorFormatter->output(64, Declaration of SilbinaryWolf\SilverstripePHPStan\Reflection\MethodClassReflectionExtension::setBroker(PHPStan\Broker\Broker $broker) must be compatible with PHPStan\Reflection\BrokerAwareExtension::setBroker(PHPStan\Broker\Broker $broker): void, /data/site/vendor/symbiote/silverstripe-phpstan/src/Reflection/MethodClassReflectionExtension.php, 53, )
DetailedErrorFormatter.php:54

SilverStripe\Logging\DetailedErrorFormatter->format(Array)
AbstractProcessingHandler.php:37

Monolog\Handler\AbstractProcessingHandler->handle(Array)
Logger.php:344

Monolog\Logger->addRecord(550, Fatal Error (E_COMPILE_ERROR): Declaration of SilbinaryWolf\SilverstripePHPStan\Reflection\MethodClassReflectionExtension::setBroker(PHPStan\Broker\Broker $broker) must be compatible with PHPStan\Reflection\BrokerAwareExtension::setBroker(PHPStan\Broker\Broker $broker): void, Array)
Logger.php:614

Monolog\Logger->log(550, Fatal Error (E_COMPILE_ERROR): Declaration of SilbinaryWolf\SilverstripePHPStan\Reflection\MethodClassReflectionExtension::setBroker(PHPStan\Broker\Broker $broker) must be compatible with PHPStan\Reflection\BrokerAwareExtension::setBroker(PHPStan\Broker\Broker $broker): void, Array)
ErrorHandler.php:189

Monolog\ErrorHandler->handleFatalError()

[defaultsite@directleaseint site]$ clear

[defaultsite@directleaseint site]$ 
[defaultsite@directleaseint site]$ vendor/bin/phpstan analyse directlease/code -c phpstan.neon -a vendor/symbiote/silverstripe-phpstan/bootstrap.php --level 2
PHP Fatal error:  Declaration of SilbinaryWolf\SilverstripePHPStan\Reflection\MethodClassReflectionExtension::setBroker(PHPStan\Broker\Broker $broker) must be compatible with PHPStan\Reflection\BrokerAwareExtension::setBroker(PHPStan\Broker\Broker $broker): void in /data/site/vendor/symbiote/silverstripe-phpstan/src/Reflection/MethodClassReflectionExtension.php on line 53
PHP Notice:  Undefined index: SERVER_PROTOCOL in /data/site/vendor/silverstripe/framework/src/Control/HTTPResponse.php on line 144
PHP Notice:  Undefined index: SERVER_PROTOCOL in /data/site/vendor/silverstripe/framework/src/Control/HTTPResponse.php on line 380
ERROR [Notice]: Undefined index: SERVER_PROTOCOL
IN  
Line 144 in /data/site/vendor/silverstripe/framework/src/Control/HTTPResponse.php

Source
======
  135:      * @param string $protocolVersion
  136:      */
  137:     public function __construct($body = null, $statusCode = null, $statusDescription = null,
       $protocolVersion = null)
  138:     {
  139:         $this->setBody($body);
  140:         if ($statusCode) {
  141:             $this->setStatusCode($statusCode, $statusDescription);
  142:         }
  143:         if (!$protocolVersion) {
* 144:             if (preg_match('/HTTP\/(?<version>\d+(\.\d+)?)/i', $_SERVER['SERVER_PROTOCOL'],
       $matches)) {
  145:                 $protocolVersion = $matches['version'];
  146:             }
  147:         }
  148:         if ($protocolVersion) {
  149:             $this->setProtocolVersion($protocolVersion);
  150:         }

Trace
=====
Monolog\ErrorHandler->handleError(8, Undefined index: SERVER_PROTOCOL, /data/site/vendor/silverstripe/framework/src/Control/HTTPResponse.php, 144, Array)
HTTPResponse.php:144

SilverStripe\Control\HTTPResponse->__construct()
HTTPOutputHandler.php:153

SilverStripe\Logging\HTTPOutputHandler->write(Array)
AbstractProcessingHandler.php:39

Monolog\Handler\AbstractProcessingHandler->handle(Array)
Logger.php:344

Monolog\Logger->addRecord(550, Fatal Error (E_COMPILE_ERROR): Declaration of SilbinaryWolf\SilverstripePHPStan\Reflection\MethodClassReflectionExtension::setBroker(PHPStan\Broker\Broker $broker) must be compatible with PHPStan\Reflection\BrokerAwareExtension::setBroker(PHPStan\Broker\Broker $broker): void, Array)
Logger.php:614

Monolog\Logger->log(550, Fatal Error (E_COMPILE_ERROR): Declaration of SilbinaryWolf\SilverstripePHPStan\Reflection\MethodClassReflectionExtension::setBroker(PHPStan\Broker\Broker $broker) must be compatible with PHPStan\Reflection\BrokerAwareExtension::setBroker(PHPStan\Broker\Broker $broker): void, Array)
ErrorHandler.php:189

Monolog\ErrorHandler->handleFatalError()

PHP Notice:  Undefined index: SERVER_PROTOCOL in /data/site/vendor/silverstripe/framework/src/Control/HTTPResponse.php on line 144
ERROR [UNKNOWN TYPE, ERRNO 64]: Declaration of SilbinaryWolf\SilverstripePHPStan\Reflection\MethodClassReflectionExtension::setBroker(PHPStan\Broker\Broker $broker) must be compatible with PHPStan\Reflection\BrokerAwareExtension::setBroker(PHPStan\Broker\Broker $broker): void
IN  
Line 53 in /data/site/vendor/symbiote/silverstripe-phpstan/src/Reflection/MethodClassReflectionExtension.php

Source
======
  44:      public function getMethod(ClassReflection $classReflection, string $methodName):
       MethodReflection
  45:      {
  46:          if (!isset($this->methods[$classReflection->getName()])) {
  47:              $this->methods[$classReflection->getName()] = $this->createMethods($classReflection);
  48:          }
  49:          // Fallback to has_one/has_many/many_many
  50:          return $this->methods[$classReflection->getName()][strtolower($methodName)];
  51:      }
  52:  
* 53:      public function setBroker(Broker $broker)
  54:      {
  55:          $this->broker = $broker;
  56:      }
  57:  
  58:      /**
  59:       * @param ClassReflection $classReflection

Trace
=====
SilverStripe\Dev\CliDebugView->renderTrace()
DetailedErrorFormatter.php:119

SilverStripe\Logging\DetailedErrorFormatter->output(64, Declaration of SilbinaryWolf\SilverstripePHPStan\Reflection\MethodClassReflectionExtension::setBroker(PHPStan\Broker\Broker $broker) must be compatible with PHPStan\Reflection\BrokerAwareExtension::setBroker(PHPStan\Broker\Broker $broker): void, /data/site/vendor/symbiote/silverstripe-phpstan/src/Reflection/MethodClassReflectionExtension.php, 53, )
DetailedErrorFormatter.php:54

SilverStripe\Logging\DetailedErrorFormatter->format(Array)
AbstractProcessingHandler.php:37

Monolog\Handler\AbstractProcessingHandler->handle(Array)
Logger.php:344

Monolog\Logger->addRecord(550, Fatal Error (E_COMPILE_ERROR): Declaration of SilbinaryWolf\SilverstripePHPStan\Reflection\MethodClassReflectionExtension::setBroker(PHPStan\Broker\Broker $broker) must be compatible with PHPStan\Reflection\BrokerAwareExtension::setBroker(PHPStan\Broker\Broker $broker): void, Array)
Logger.php:614

Monolog\Logger->log(550, Fatal Error (E_COMPILE_ERROR): Declaration of SilbinaryWolf\SilverstripePHPStan\Reflection\MethodClassReflectionExtension::setBroker(PHPStan\Broker\Broker $broker) must be compatible with PHPStan\Reflection\BrokerAwareExtension::setBroker(PHPStan\Broker\Broker $broker): void, Array)
ErrorHandler.php:189

Monolog\ErrorHandler->handleFatalError()
eFFemeer commented 1 year ago

I'm getting a similar error.

PHP Notice: Undefined index: SERVER_PROTOCOL in /volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php on line 388 ERROR [Notice]: Undefined index: SERVER_PROTOCOL IN Line 388 in /volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php How can it be resolved?