Skip to content

Commit

Permalink
Minor fixes for latest PHP compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
claudio-silva committed Jun 14, 2024
1 parent d50c43e commit 83915ef
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/arrays.php
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ function array_toClass (array $array, $className)
*
* @return mixed
*/
function get ($array = null, $key, $def = null)
function get ($array, $key, $def = null)
{
return isset ($array[$key]) ? $array[$key] : $def;
}
Expand Down
9 changes: 5 additions & 4 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* </ul>
* @return callable
*/
function fn (callable $f)
function _fn (callable $f)
{
if ($f instanceof Closure)
return $f;
Expand Down Expand Up @@ -140,8 +140,8 @@ function f ($exp)
if (isset($cache[$exp]))
return $cache[$exp];
list ($a, $f) = explode ('=>', $exp, 2);

return $cache[$exp] = create_function ($a, "return $f;");
$code = sprintf('return function(%s) { return %s; };', $a, $f);
return $cache[$exp] = eval($code);
}

/**
Expand All @@ -162,7 +162,8 @@ function fx ($exp)
static $cache = [];
if (isset($cache[$exp]))
return $cache[$exp];
return $cache[$exp] = create_function ('$x', "return $exp;");
$code = sprintf('return function($x) { return %s; };', $exp);
return $cache[$exp] = eval($code);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/profiling.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* @param string $label Optinal label.
* @param string $label Optional label.
* @param string $hr The character sequence to use as an Horizontal Ruler for visually highlighting the profiler's
* messages.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/system.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function runExternalCommand ($cmd, $input = '', $extraPath = '', array $extraEnv
];

if ($extraPath) {
$path = $extraPath . PATH_SEPARATOR . array_at ($_SERVER, 'PATH', getenv ('PATH'));
$path = $extraPath . PATH_SEPARATOR . ($_SERVER['PATH'] ?? getenv ('PATH'));
if (!isset($extraEnv))
$extraEnv = [];
$extraEnv['PATH'] = $path;
Expand Down

0 comments on commit 83915ef

Please sign in to comment.