Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Comptoir
Comptoir-srv
Commits
9dcd1254
Commit
9dcd1254
authored
Mar 23, 2021
by
Fabrice Gangler
🎨
Browse files
REFACTOR: move polyfills (array_key_last and array_key_first)
parent
630cfff5
Changes
2
Hide whitespace changes
Inline
Side-by-side
tests/Acceptance/bootstrap.php
View file @
9dcd1254
<?php
// Here you can initialize variables that will be available to your tests, e.g. the app's bootstrap.php
// Polyfill for array_key_first() function added in PHP 7.3.
if
(
!
function_exists
(
'array_key_first'
))
{
function
array_key_first
(
array
$array
)
{
if
(
$array
===
[])
{
return
null
;
}
foreach
(
$array
as
$key
=>
$_
)
{
return
$key
;
}
}
}
// Polyfill for array_key_last() function added in PHP 7.3.
if
(
!
function_exists
(
'array_key_last'
))
{
function
array_key_last
(
array
$array
)
{
if
(
$array
===
[])
{
return
null
;
}
return
array_key_first
(
array_slice
(
$array
,
-
1
));
}
}
tests/bootstrap.php
View file @
9dcd1254
...
...
@@ -6,3 +6,27 @@
* unit tests in this file.
*/
require
dirname
(
__DIR__
)
.
'/config/bootstrap.php'
;
// Polyfill for array_key_first() function added in PHP 7.3.
if
(
!
function_exists
(
'array_key_first'
))
{
function
array_key_first
(
array
$array
)
{
if
(
$array
===
[])
{
return
null
;
}
foreach
(
$array
as
$key
=>
$_
)
{
return
$key
;
}
}
}
// Polyfill for array_key_last() function added in PHP 7.3.
if
(
!
function_exists
(
'array_key_last'
))
{
function
array_key_last
(
array
$array
)
{
if
(
$array
===
[])
{
return
null
;
}
return
array_key_first
(
array_slice
(
$array
,
-
1
));
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment