Skip to content

Commit fdc3274

Browse files
authored
Merge pull request #19 from OpenCageData/fix/deprecation-warning
fix: πŸ› Warning http_response_header deprecated
2 parents df4d0e2 + e5113ba commit fdc3274

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

β€ŽVagrantfileβ€Ž

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ Vagrant.configure("2") do |config|
2121
# documentation for more information about their specific syntax and use.
2222
config.vm.provision "shell", inline: <<-SHELL
2323
apt-get update -qq
24-
apt-get install -y -qq php-cli php-curl php-xml php-mbstring unzip
24+
apt-get install -y -qq software-properties-common gnupg2 unzip
25+
add-apt-repository -y ppa:ondrej/php
26+
apt-get update -qq
27+
apt-get install -y -qq php8.3-cli php8.3-curl php8.3-xml php8.3-mbstring
28+
apt-get install -y -qq php8.4-cli php8.4-curl php8.4-xml php8.4-mbstring
29+
apt-get install -y -qq php8.5-cli php8.5-curl php8.5-xml php8.5-mbstring
2530
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
2631
cd /home/vagrant/php-opencage-geocode
2732
composer install

β€Žphpstan.neonβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
parameters:
2+
level: max
3+
paths:
4+
- src
5+
- tests
6+
reportUnmatchedIgnoredErrors: false

β€Žsrc/AbstractGeocoder.phpβ€Ž

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,16 @@ protected function getJSONByFopen($query)
6767
error_clear_last();
6868

6969
$ret = @file_get_contents($query);
70-
7170
if ($ret === false) {
72-
/** NOTE: https://github.com/phpstan/phpstan/issues/3213 */
71+
$response_headers = function_exists('http_get_last_response_headers')
72+
? http_get_last_response_headers()
73+
/** NOTE: https://github.com/phpstan/phpstan/issues/3213 */
74+
/** @phpstan-ignore-next-line */
75+
: (isset($http_response_header) ? $http_response_header : null);
76+
7377
/** @phpstan-ignore-next-line */
74-
if (isset($http_response_header) && is_array($http_response_header)) {
75-
$error_message = $http_response_header[0];
78+
if (isset($response_headers) && is_array($response_headers)) {
79+
$error_message = $response_headers[0];
7680
if ($error = error_get_last()) {
7781
$error_message = $error['message'];
7882
}

0 commit comments

Comments
Β (0)