Skip to content

Commit

Permalink
Fix PHP 8.1 compatibility.
Browse files Browse the repository at this point in the history
When using this library with PHP 8.1, a deprecation warning is triggered: fwrite(): Passing null to parameter #2 ($data) of type string is deprecated
(see: phayes#190)
  • Loading branch information
itamair committed Jul 4, 2022
1 parent 30255e6 commit 00e26b7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion geoPHP.inc
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class geoPHP
// It could make a mistake in XML detection if you are mixing or using namespaces in weird ways (ie, KML inside an RSS feed)
static function detectFormat(&$input) {
$mem = fopen('php://memory', 'r+');
fwrite($mem, $input, 11); // Write 11 bytes - we can detect the vast majority of formats in the first 11 bytes
fwrite($mem, (string) $input, 11); // Write 11 bytes - we can detect the vast majority of formats in the first 11 bytes
fseek($mem, 0);

$bytes = unpack("c*", fread($mem, 11));
Expand Down
2 changes: 1 addition & 1 deletion lib/adapters/EWKB.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function read($wkb, $is_hex_string = FALSE) {

// Open the wkb up in memory so we can examine the SRID
$mem = fopen('php://memory', 'r+');
fwrite($mem, $wkb);
fwrite($mem, (string) $wkb);
fseek($mem, 0);
$base_info = unpack("corder/ctype/cz/cm/cs", fread($mem, 5));
if ($base_info['s']) {
Expand Down
2 changes: 1 addition & 1 deletion lib/adapters/WKB.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function read($wkb, $is_hex_string = FALSE) {
}

$mem = fopen('php://memory', 'r+');
fwrite($mem, $wkb);
fwrite($mem, (string) $wkb);
fseek($mem, 0);

$geometry = $this->getGeometry($mem);
Expand Down

0 comments on commit 00e26b7

Please sign in to comment.