1--TEST--
2Test array_multisort() function : usage variation - test sort order of all types
3--FILE--
4<?php
5/* Prototype  : bool array_multisort(array ar1 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING|SORT_NATURAL|SORT_FLAG_CASE]] [, array ar2 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING|SORT_NATURAL|SORT_FLAG_CASE]], ...])
6 * Description: Sort multiple arrays at once similar to how ORDER BY clause works in SQL
7 * Source code: ext/standard/array.c
8 * Alias to functions:
9 */
10
11echo "*** Testing array_multisort() : usage variation  - test sort order of all types***\n";
12
13// define some classes
14class classWithToString {
15	public function __toString() {
16		return "Class A object";
17	}
18}
19
20class classWithoutToString { }
21
22$inputs = array(
23      'int 0' => 0,
24      'float -10.5' => -10.5,
25      array(),
26      'uppercase NULL' => NULL,
27      'lowercase true' => true,
28      'empty string DQ' => "",
29      'string DQ' => "string",
30      'instance of classWithToString' => new classWithToString(),
31      'instance of classWithoutToString' => new classWithoutToString(),
32      'undefined var' => @$undefined_var,
33);
34
35var_dump(array_multisort($inputs, SORT_NUMERIC));
36var_dump($inputs);
37
38?>
39===DONE===
40--EXPECTF--
41*** Testing array_multisort() : usage variation  - test sort order of all types***
42
43Notice: Object of class classWithToString could not be converted to double in %sarray_multisort_variation9.php on line %d
44
45Notice: Object of class classWithoutToString could not be converted to double in %sarray_multisort_variation9.php on line %d
46
47Notice: Object of class classWithoutToString could not be converted to double in %sarray_multisort_variation9.php on line %d
48
49Notice: Object of class classWithoutToString could not be converted to double in %sarray_multisort_variation9.php on line %d
50
51Notice: Object of class classWithoutToString could not be converted to double in %sarray_multisort_variation9.php on line %d
52bool(true)
53array(10) {
54  ["float -10.5"]=>
55  float(-10.5)
56  ["string DQ"]=>
57  string(6) "string"
58  ["undefined var"]=>
59  NULL
60  ["empty string DQ"]=>
61  string(0) ""
62  ["uppercase NULL"]=>
63  NULL
64  ["int 0"]=>
65  int(0)
66  [0]=>
67  array(0) {
68  }
69  ["instance of classWithoutToString"]=>
70  object(classWithoutToString)#2 (0) {
71  }
72  ["lowercase true"]=>
73  bool(true)
74  ["instance of classWithToString"]=>
75  object(classWithToString)#1 (0) {
76  }
77}
78===DONE===