Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ Vagrant.configure("2") do |config|
# documentation for more information about their specific syntax and use.
config.vm.provision "shell", inline: <<-SHELL
apt-get update -qq
apt-get install -y -qq php-cli php-curl php-xml php-mbstring unzip
apt-get install -y -qq software-properties-common gnupg2 unzip
add-apt-repository -y ppa:ondrej/php
apt-get update -qq
apt-get install -y -qq php8.3-cli php8.3-curl php8.3-xml php8.3-mbstring
apt-get install -y -qq php8.4-cli php8.4-curl php8.4-xml php8.4-mbstring
apt-get install -y -qq php8.5-cli php8.5-curl php8.5-xml php8.5-mbstring
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
cd /home/vagrant/php-opencage-geocode
composer install
Expand Down
6 changes: 6 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
level: max
paths:
- src
- tests
reportUnmatchedIgnoredErrors: false
12 changes: 8 additions & 4 deletions src/AbstractGeocoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,16 @@ protected function getJSONByFopen($query)
error_clear_last();

$ret = @file_get_contents($query);

if ($ret === false) {
/** NOTE: https://github.com/phpstan/phpstan/issues/3213 */
$response_headers = function_exists('http_get_last_response_headers')
? http_get_last_response_headers()
/** NOTE: https://github.com/phpstan/phpstan/issues/3213 */
/** @phpstan-ignore-next-line */
: (isset($http_response_header) ? $http_response_header : null);

/** @phpstan-ignore-next-line */
if (isset($http_response_header) && is_array($http_response_header)) {
$error_message = $http_response_header[0];
if (isset($response_headers) && is_array($response_headers)) {
$error_message = $response_headers[0];
if ($error = error_get_last()) {
$error_message = $error['message'];
}
Expand Down