Import function with php 5.4

0

I am using an API, but it was designed to work in php 5.6+, but my server is running version 5.4, alias, my server is not the client server and this client server already has several applications running in 5.4 then it would be more complex to update, since I do not know these applications and they are huge, so I am trying to adapt this API to run in version 5.4, it was happening okay, I found several alternatives until I found this:

use function GuzzleHttp\Psr7\modify_request;

Where it imports a function from a particular file, I wanted to know if an alternative to import this function using php 5.4.

    
asked by anonymous 23.01.2018 / 14:13

1 answer

1

use function is supported only by PHP5.6 +, as well as constants:

use const Foo\Bar\CONSTANT;

Now when dealing with functions in link you can simply import functions_include.php and use the function directly GuzzleHttp\Psr7\modify_request(..., ...); and do not use use function :

<?php

use GuzzleHttp\Psr7\Request;

require_once 'vendor/guzzlehttp/psr7/src/functions_include.php';
require_once 'vendor/autoload.php';

$request = new Request('GET', 'https://pt.stackoverflow.com');

$request = GuzzleHttp\Psr7\modify_request($request, [ 'set_headers' => [ 'foo' => 'bar' ] ]);
    
23.01.2018 / 16:30