@@ -10,10 +10,10 @@ function resolve($promiseOrValue = null)
1010
1111 // Check is_object() first to avoid method_exists() triggering
1212 // 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 ' )) {
1414 $ canceller = null ;
1515
16- if (method_exists ($ promiseOrValue , 'cancel ' )) {
16+ if (\ method_exists ($ promiseOrValue , 'cancel ' )) {
1717 $ canceller = [$ promiseOrValue , 'cancel ' ];
1818 }
1919
@@ -70,7 +70,7 @@ function any($promisesOrValues)
7070{
7171 return some ($ promisesOrValues , 1 )
7272 ->then (function ($ val ) {
73- return array_shift ($ val );
73+ return \ array_shift ($ val );
7474 });
7575}
7676
@@ -82,16 +82,16 @@ function some($promisesOrValues, $howMany)
8282 return new Promise (function ($ resolve , $ reject , $ notify ) use ($ promisesOrValues , $ howMany , $ cancellationQueue ) {
8383 resolve ($ promisesOrValues )
8484 ->done (function ($ array ) use ($ howMany , $ cancellationQueue , $ resolve , $ reject , $ notify ) {
85- if (!is_array ($ array ) || $ howMany < 1 ) {
85+ if (!\ is_array ($ array ) || $ howMany < 1 ) {
8686 $ resolve ([]);
8787 return ;
8888 }
8989
90- $ len = count ($ array );
90+ $ len = \ count ($ array );
9191
9292 if ($ len < $ howMany ) {
9393 throw new Exception \LengthException (
94- sprintf (
94+ \ sprintf (
9595 'Input array must contain at least %d item%s but contains only %s item%s. ' ,
9696 $ howMany ,
9797 1 === $ howMany ? '' : 's ' ,
@@ -148,12 +148,12 @@ function map($promisesOrValues, callable $mapFunc)
148148 return new Promise (function ($ resolve , $ reject , $ notify ) use ($ promisesOrValues , $ mapFunc , $ cancellationQueue ) {
149149 resolve ($ promisesOrValues )
150150 ->done (function ($ array ) use ($ mapFunc , $ cancellationQueue , $ resolve , $ reject , $ notify ) {
151- if (!is_array ($ array ) || !$ array ) {
151+ if (!\ is_array ($ array ) || !$ array ) {
152152 $ resolve ([]);
153153 return ;
154154 }
155155
156- $ toResolve = count ($ array );
156+ $ toResolve = \ count ($ array );
157157 $ values = [];
158158
159159 foreach ($ array as $ i => $ promiseOrValue ) {
@@ -186,11 +186,11 @@ function reduce($promisesOrValues, callable $reduceFunc, $initialValue = null)
186186 return new Promise (function ($ resolve , $ reject , $ notify ) use ($ promisesOrValues , $ reduceFunc , $ initialValue , $ cancellationQueue ) {
187187 resolve ($ promisesOrValues )
188188 ->done (function ($ array ) use ($ reduceFunc , $ initialValue , $ cancellationQueue , $ resolve , $ reject , $ notify ) {
189- if (!is_array ($ array )) {
189+ if (!\ is_array ($ array )) {
190190 $ array = [];
191191 }
192192
193- $ total = count ($ array );
193+ $ total = \ count ($ array );
194194 $ i = 0 ;
195195
196196 // Wrap the supplied $reduceFunc with one that handles promises and then
@@ -209,7 +209,7 @@ function reduce($promisesOrValues, callable $reduceFunc, $initialValue = null)
209209
210210 $ cancellationQueue ->enqueue ($ initialValue );
211211
212- array_reduce ($ array , $ wrappedReduceFunc , resolve ($ initialValue ))
212+ \ array_reduce ($ array , $ wrappedReduceFunc , resolve ($ initialValue ))
213213 ->done ($ resolve , $ reject , $ notify );
214214 }, $ reject , $ notify );
215215 }, $ cancellationQueue );
@@ -218,13 +218,13 @@ function reduce($promisesOrValues, callable $reduceFunc, $initialValue = null)
218218// Internal functions
219219function _checkTypehint (callable $ callback , $ object )
220220{
221- if (!is_object ($ object )) {
221+ if (!\ is_object ($ object )) {
222222 return true ;
223223 }
224224
225- if (is_array ($ callback )) {
225+ if (\ is_array ($ callback )) {
226226 $ callbackReflection = new \ReflectionMethod ($ callback [0 ], $ callback [1 ]);
227- } elseif (is_object ($ callback ) && !$ callback instanceof \Closure) {
227+ } elseif (\ is_object ($ callback ) && !$ callback instanceof \Closure) {
228228 $ callbackReflection = new \ReflectionMethod ($ callback , '__invoke ' );
229229 } else {
230230 $ callbackReflection = new \ReflectionFunction ($ callback );
0 commit comments