diff --git a/README.md b/README.md index 66b3b5a..962eff6 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ Refer to http://php.net/eol.php for the latest updates on supported PHP versions ## Features polyfilled by this library * PHP 5.5 + * `array_column()` * `boolval()` * `hash_pbkdf2()` * `openssl_pbkdf2()` diff --git a/autoload.php b/autoload.php index 407eca1..e57a16a 100644 --- a/autoload.php +++ b/autoload.php @@ -30,6 +30,27 @@ }); error_reporting(E_ALL); ini_set('display_errors', 'On'); + +if (!function_exists('array_column')) { + /** + * Get the boolean value of a variable + */ + function array_column(array $array, $column_key, $index_key = null) + { + return Future\Utility::arrayColumn($array, $column_key, $index_key); + } +} + +if (!function_exists('boolval')) { + /** + * Get the boolean value of a variable + */ + function boolval($mixed_var) + { + return !!$mixed_var; + } +} + if (!function_exists('hash_equals')) { /** * From PHP 5.6 @@ -107,13 +128,3 @@ function openssl_pbkdf2($password, $salt, $length, $iterations, $algo = 'sha1') return $key; } } - -if (!function_exists('boolval')) { - /** - * Get the boolean value of a variable - */ - function boolval($mixed_var) - { - return !!$mixed_var; - } -} diff --git a/src/Utility.php b/src/Utility.php new file mode 100644 index 0000000..acca4da --- /dev/null +++ b/src/Utility.php @@ -0,0 +1,61 @@ + 1, 'b' => 1], + ['a' => 2, 'b' => 3], + ['a' => 3, 'b' => 2] + ]; + + $y = [ + 1 => 1, + 2 => 3, + 3 => 2 + ]; + + $this->assertEquals( + $y, + Future\Utility::arrayColumn($x, 'b', 'a') + ); + } +} diff --git a/wishlist.txt b/wishlist.txt index 645ec34..dbc2a87 100644 --- a/wishlist.txt +++ b/wishlist.txt @@ -2,7 +2,6 @@ PHP 5.5 FUNCTIONS ========= - array_column() curl_escape() curl_unescape() pg_escape_literal()