0

this is php 8 and this error appears everytime from my incomingRequest.php file

the error states ```Deprecated: Required parameter $userAgent follows optional parameter $body``

the initial code

public function __construct($config, URI $uri = null, $body = 'php://input', UserAgent $userAgent)
    {
        // Get our body from php://input
        if ($body === 'php://input')
        {
            $body = file_get_contents('php://input');
        }

        $this->body      = ! empty($body) ? $body : null;
        $this->config    = $config;
        $this->userAgent = $userAgent;

        
parent::__construct($config);

        $this->populateHeaders();

this is php 8 and this error appears everytime from my incomingRequest.php file

the error states ```Deprecated: Required parameter $userAgent follows optional parameter $body``

the initial code

public function __construct($config, URI $uri = null, $body = 'php://input', UserAgent $userAgent)
    {
        // Get our body from php://input
        if ($body === 'php://input')
        {
            $body = file_get_contents('php://input');
        }

        $this->body      = ! empty($body) ? $body : null;
        $this->config    = $config;
        $this->userAgent = $userAgent;

        
parent::__construct($config);

        $this->populateHeaders();
  • [`Note that any optional arguments should be specified after any required arguments, otherwise they cannot be omitted from calls.`](https://www.php.net/manual/en/functions.arguments.php). Your `$uri` and `$body` are not required, but `$userAgent` is, which forces the other two to be required. – aynber Mar 30 '22 at 18:16
  • so what am i to do? – oliver samuel Mar 30 '22 at 18:18
  • Remove the default values from those function parameters would be the easiest way to go about it. If this is from a plugin or library, contact the dev that created it – aynber Mar 30 '22 at 18:19

0 Answers0