@@ -10,10 +10,10 @@ function resolve($promiseOrValue = null)
10
10
11
11
// Check is_object() first to avoid method_exists() triggering
12
12
// class autoloaders if $promiseOrValue is a string.
13
- if (is_object ($ promiseOrValue ) && method_exists ($ promiseOrValue , 'then ' )) {
13
+ if (\ is_object ($ promiseOrValue ) && \ method_exists ($ promiseOrValue , 'then ' )) {
14
14
$ canceller = null ;
15
15
16
- if (method_exists ($ promiseOrValue , 'cancel ' )) {
16
+ if (\ method_exists ($ promiseOrValue , 'cancel ' )) {
17
17
$ canceller = [$ promiseOrValue , 'cancel ' ];
18
18
}
19
19
@@ -70,7 +70,7 @@ function any($promisesOrValues)
70
70
{
71
71
return some ($ promisesOrValues , 1 )
72
72
->then (function ($ val ) {
73
- return array_shift ($ val );
73
+ return \ array_shift ($ val );
74
74
});
75
75
}
76
76
@@ -82,16 +82,16 @@ function some($promisesOrValues, $howMany)
82
82
return new Promise (function ($ resolve , $ reject , $ notify ) use ($ promisesOrValues , $ howMany , $ cancellationQueue ) {
83
83
resolve ($ promisesOrValues )
84
84
->done (function ($ array ) use ($ howMany , $ cancellationQueue , $ resolve , $ reject , $ notify ) {
85
- if (!is_array ($ array ) || $ howMany < 1 ) {
85
+ if (!\ is_array ($ array ) || $ howMany < 1 ) {
86
86
$ resolve ([]);
87
87
return ;
88
88
}
89
89
90
- $ len = count ($ array );
90
+ $ len = \ count ($ array );
91
91
92
92
if ($ len < $ howMany ) {
93
93
throw new Exception \LengthException (
94
- sprintf (
94
+ \ sprintf (
95
95
'Input array must contain at least %d item%s but contains only %s item%s. ' ,
96
96
$ howMany ,
97
97
1 === $ howMany ? '' : 's ' ,
@@ -148,12 +148,12 @@ function map($promisesOrValues, callable $mapFunc)
148
148
return new Promise (function ($ resolve , $ reject , $ notify ) use ($ promisesOrValues , $ mapFunc , $ cancellationQueue ) {
149
149
resolve ($ promisesOrValues )
150
150
->done (function ($ array ) use ($ mapFunc , $ cancellationQueue , $ resolve , $ reject , $ notify ) {
151
- if (!is_array ($ array ) || !$ array ) {
151
+ if (!\ is_array ($ array ) || !$ array ) {
152
152
$ resolve ([]);
153
153
return ;
154
154
}
155
155
156
- $ toResolve = count ($ array );
156
+ $ toResolve = \ count ($ array );
157
157
$ values = [];
158
158
159
159
foreach ($ array as $ i => $ promiseOrValue ) {
@@ -186,11 +186,11 @@ function reduce($promisesOrValues, callable $reduceFunc, $initialValue = null)
186
186
return new Promise (function ($ resolve , $ reject , $ notify ) use ($ promisesOrValues , $ reduceFunc , $ initialValue , $ cancellationQueue ) {
187
187
resolve ($ promisesOrValues )
188
188
->done (function ($ array ) use ($ reduceFunc , $ initialValue , $ cancellationQueue , $ resolve , $ reject , $ notify ) {
189
- if (!is_array ($ array )) {
189
+ if (!\ is_array ($ array )) {
190
190
$ array = [];
191
191
}
192
192
193
- $ total = count ($ array );
193
+ $ total = \ count ($ array );
194
194
$ i = 0 ;
195
195
196
196
// Wrap the supplied $reduceFunc with one that handles promises and then
@@ -209,7 +209,7 @@ function reduce($promisesOrValues, callable $reduceFunc, $initialValue = null)
209
209
210
210
$ cancellationQueue ->enqueue ($ initialValue );
211
211
212
- array_reduce ($ array , $ wrappedReduceFunc , resolve ($ initialValue ))
212
+ \ array_reduce ($ array , $ wrappedReduceFunc , resolve ($ initialValue ))
213
213
->done ($ resolve , $ reject , $ notify );
214
214
}, $ reject , $ notify );
215
215
}, $ cancellationQueue );
@@ -218,13 +218,13 @@ function reduce($promisesOrValues, callable $reduceFunc, $initialValue = null)
218
218
// Internal functions
219
219
function _checkTypehint (callable $ callback , $ object )
220
220
{
221
- if (!is_object ($ object )) {
221
+ if (!\ is_object ($ object )) {
222
222
return true ;
223
223
}
224
224
225
- if (is_array ($ callback )) {
225
+ if (\ is_array ($ callback )) {
226
226
$ callbackReflection = new \ReflectionMethod ($ callback [0 ], $ callback [1 ]);
227
- } elseif (is_object ($ callback ) && !$ callback instanceof \Closure) {
227
+ } elseif (\ is_object ($ callback ) && !$ callback instanceof \Closure) {
228
228
$ callbackReflection = new \ReflectionMethod ($ callback , '__invoke ' );
229
229
} else {
230
230
$ callbackReflection = new \ReflectionFunction ($ callback );
0 commit comments