1--TEST--
2Test natcasesort() function : object functionality - mixed visibility within objects
3--FILE--
4<?php
5/* Prototype  : bool natcasesort(array &$array_arg)
6 * Description: Sort an array using case-insensitive natural sort
7 * Source code: ext/standard/array.c
8 */
9
10/*
11 * Pass natcasesort() an array of objects which have properties of different
12 * visibilities to test how it re-orders the array.
13 */
14
15echo "*** Testing natcasesort() : object functionality ***\n";
16
17// class declaration for string objects
18class for_string_natcasesort
19{
20	public $public_class_value;
21	private $private_class_value;
22	protected $protected_class_value;
23	// initializing object member value
24	function __construct($value1, $value2,$value3){
25		$this->public_class_value = $value1;
26		$this->private_class_value = $value2;
27		$this->protected_class_value = $value3;
28	}
29
30	// return string value
31	function __tostring() {
32		return (string)$this->public_class_value;
33	}
34
35}
36
37// array of string objects
38$unsorted_str_obj = array (
39new for_string_natcasesort("axx","AXX","ass"),
40new for_string_natcasesort("t","eee","abb"),
41new for_string_natcasesort("w","W", "c"),
42new for_string_natcasesort("py","PY", "pt"),
43);
44
45
46echo "\n-- Testing natcasesort() by supplying object arrays --\n";
47
48// testing natcasesort() function by supplying string object array
49$temp_array = $unsorted_str_obj;
50var_dump(natcasesort($temp_array) );
51var_dump($temp_array);
52
53echo "Done";
54?>
55--EXPECTF--
56*** Testing natcasesort() : object functionality ***
57
58-- Testing natcasesort() by supplying object arrays --
59bool(true)
60array(4) {
61  [0]=>
62  object(for_string_natcasesort)#%d (3) {
63    ["public_class_value"]=>
64    string(3) "axx"
65    ["private_class_value":"for_string_natcasesort":private]=>
66    string(3) "AXX"
67    ["protected_class_value":protected]=>
68    string(3) "ass"
69  }
70  [3]=>
71  object(for_string_natcasesort)#%d (3) {
72    ["public_class_value"]=>
73    string(2) "py"
74    ["private_class_value":"for_string_natcasesort":private]=>
75    string(2) "PY"
76    ["protected_class_value":protected]=>
77    string(2) "pt"
78  }
79  [1]=>
80  object(for_string_natcasesort)#%d (3) {
81    ["public_class_value"]=>
82    string(1) "t"
83    ["private_class_value":"for_string_natcasesort":private]=>
84    string(3) "eee"
85    ["protected_class_value":protected]=>
86    string(3) "abb"
87  }
88  [2]=>
89  object(for_string_natcasesort)#%d (3) {
90    ["public_class_value"]=>
91    string(1) "w"
92    ["private_class_value":"for_string_natcasesort":private]=>
93    string(1) "W"
94    ["protected_class_value":protected]=>
95    string(1) "c"
96  }
97}
98Done
99