php-src/ext/spl/tests/arrayObject_asort_basic1.phpt
Larry Garfield 96f2f3174b Update array parameter names for named parameters
* The array "subject" of a function gets called $array.

* Further parameters should be self-descriptive if used
  as a named parameter, and a full word, not an abbreviation.

* If there is a "bunch more arrays" variadic, it gets
  called $arrays (because that's what was already there).

* A few functions have a variadic "a bunch more arrays,
  and then a callable", and were already called $rest.
  I left those as is and died a little inside.

* Any callable provided to an array function that acts
  on the array is called $callback. (Nearly all were already,
  I just fixed the one or two outliers.)

* array_multisort() is beyond help so I ran screaming.
2020-09-14 14:56:49 +00:00

62 lines
1.2 KiB
PHP

--TEST--
SPL: Test ArrayObject::asort() function : basic functionality with array based store
--FILE--
<?php
/* Sort the entries by values.
* Source code: ext/spl/spl_array.c
* Alias to functions:
*/
echo "*** Testing ArrayObject::asort() : basic functionality ***\n";
$ao1 = new ArrayObject(array(4,2,3));
$ao2 = new ArrayObject(array('a'=>4,'b'=>2,'c'=>3));
var_dump($ao1->asort());
var_dump($ao1);
try {
var_dump($ao2->asort('blah'));
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
var_dump($ao2);
var_dump($ao2->asort(SORT_NUMERIC));
var_dump($ao2);
?>
--EXPECTF--
*** Testing ArrayObject::asort() : basic functionality ***
bool(true)
object(ArrayObject)#%d (1) {
["storage":"ArrayObject":private]=>
array(3) {
[1]=>
int(2)
[2]=>
int(3)
[0]=>
int(4)
}
}
asort(): Argument #2 ($flags) must be of type int, string given
object(ArrayObject)#%d (1) {
["storage":"ArrayObject":private]=>
array(3) {
["a"]=>
int(4)
["b"]=>
int(2)
["c"]=>
int(3)
}
}
bool(true)
object(ArrayObject)#%d (1) {
["storage":"ArrayObject":private]=>
array(3) {
["b"]=>
int(2)
["c"]=>
int(3)
["a"]=>
int(4)
}
}