1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Procedural wrappers for various functions. |
5
|
|
|
* |
6
|
|
|
* This file is part of PinkCrab Function Constructors. |
7
|
|
|
* |
8
|
|
|
* PinkCrab Function Constructors is free software: you can redistribute it and/or modify it under the terms of the |
9
|
|
|
* GNU General Public License as published by the Free Software Foundation, either version 2 |
10
|
|
|
* of the License, or (at your option) any later version. |
11
|
|
|
* |
12
|
|
|
* PinkCrab Function Constructors is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without |
13
|
|
|
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
14
|
|
|
* See the GNU General Public License for more details. |
15
|
|
|
* |
16
|
|
|
* You should have received a copy of the GNU General Public License along with PinkCrab Function Constructors. |
17
|
|
|
* If not, see <https://www.gnu.org/licenses/>. |
18
|
|
|
* |
19
|
|
|
* @author Glynn Quelch <[email protected]> |
20
|
|
|
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html |
21
|
|
|
* @package PinkCrab\FunctionConstructors |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
declare(strict_types=1); |
25
|
|
|
|
26
|
|
|
use PinkCrab\FunctionConstructors\Arrays as Arr; |
|
|
|
|
27
|
|
|
|
28
|
|
|
if (! function_exists('stringContains')) { |
29
|
|
|
/** |
30
|
|
|
* Checks if a string contains a sub string |
31
|
|
|
* |
32
|
|
|
* @param string $haystack The string to search within. |
33
|
|
|
* @param string $needle The sub string to look for. |
34
|
|
|
* @return bool |
35
|
|
|
*/ |
36
|
|
|
function stringContains(string $haystack, string $needle): bool |
37
|
|
|
{ |
38
|
|
|
return strpos($haystack, $needle) !== false; |
39
|
|
|
} |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
if (! function_exists('array_flatten')) { |
43
|
|
|
/** |
44
|
|
|
* Flattens an array to desired depth. |
45
|
|
|
* doesn't preserve keys |
46
|
|
|
* |
47
|
|
|
* @param mixed[] $array The array to flatten |
48
|
|
|
* @param int|null $n The depth to flatten the array, if null will flatten all arrays. |
49
|
|
|
* @return mixed[] |
50
|
|
|
*/ |
51
|
|
|
function arrayFlatten(array $array, ?int $n = null): array |
52
|
|
|
{ |
53
|
|
|
return Arr\flattenByN($n)($array); |
|
|
|
|
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
if (! function_exists('toObject')) { |
58
|
|
|
/** |
59
|
|
|
* Simple mapper for turning arrays into stdClass objects. |
60
|
|
|
* |
61
|
|
|
* @param array<string|int, mixed> $array |
62
|
|
|
* @return object |
63
|
|
|
*/ |
64
|
|
|
function toObject(array $array) |
65
|
|
|
{ |
66
|
|
|
return Arr\toObject(new stdClass())($array); |
|
|
|
|
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
if (! function_exists('invokeCallable')) { |
71
|
|
|
/** |
72
|
|
|
* Used to invoke a callable. |
73
|
|
|
* |
74
|
|
|
* @param callable(mixed ...$args):mixed $fn |
75
|
|
|
* @param mixed ...$args |
76
|
|
|
* @return mixed |
77
|
|
|
*/ |
78
|
|
|
function invokeCallable(callable $fn, ...$args) |
79
|
|
|
{ |
80
|
|
|
return $fn(...$args); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
if (! function_exists('isArrayAccess')) { |
85
|
|
|
/** |
86
|
|
|
* Checks if an array or an object which has array like access. |
87
|
|
|
* |
88
|
|
|
* @source https://stackoverflow.com/questions/12346479/how-to-check-for-arrayness-in-php |
89
|
|
|
* @param mixed $var |
90
|
|
|
* @return bool |
91
|
|
|
*/ |
92
|
|
|
function isArrayAccess($var) |
93
|
|
|
{ |
94
|
|
|
return is_array($var) || $var instanceof \ArrayAccess; |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths