Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

parse_str(): Calling parse_str() without the result argument is deprecated in jwage/purl

Tags:

php

laravel

public function postIndex(){

$url = new Url('https://www.dropbox.com/1/oauth2/authorize');

$url->query->setData([
    'response_type'=>'code',
    'client_id'=> env('DROPBOX_APP_KEY'),
    'redirect_uri'=> env('DROPBOX_REDIRECT_URI')
]);

parse_str defined in the purl class takes only one parameter

protected function doInitialize()
{
    parse_str($this->query);

    $this->data = get_defined_vars();
}

My current php version is 7.1.17.It needs a second 'result' parameter, how should I pass the second required parameter to get rid of this error

Thanks in advance.

like image 392
handlerFive Avatar asked Jan 29 '23 05:01

handlerFive


1 Answers

According to the documentation, parse_str didn't start raising a deprecation warning until 7.2, but in any case, it makes sense to move over to the two-argument usage.

That code sample is thankfully very straightforward, and can easily be updated as follows:

protected function doInitialize()
{
    parse_str($this->query, $this->data);
}

The jwage/purl library already had basically this exact fix applied, but it doesn't look like it's been re-tagged since then so if you pulled it in via Composer you'll need to manually require the master branch.

like image 158
iainn Avatar answered Feb 05 '23 18:02

iainn