diff options
author | Xinchen Hui <laruence@php.net> | 2013-04-01 19:11:45 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@php.net> | 2013-04-01 19:11:45 +0800 |
commit | d8a5f41a606a19efea7fe4df34bb24e66d3d3762 (patch) | |
tree | a62fdbd9dab6396d241e538dc2d04f91968ecf2c /ext/standard/tests/array | |
parent | 3b504a371734cec343a5b17adc019b54f474b2a9 (diff) | |
download | php-git-d8a5f41a606a19efea7fe4df34bb24e66d3d3762.tar.gz |
Fixed bug parameter is casted to string of array_column
Diffstat (limited to 'ext/standard/tests/array')
-rw-r--r-- | ext/standard/tests/array/array_column_object_cast.phpt | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/ext/standard/tests/array/array_column_object_cast.phpt b/ext/standard/tests/array/array_column_object_cast.phpt new file mode 100644 index 0000000000..762aaa81f4 --- /dev/null +++ b/ext/standard/tests/array/array_column_object_cast.phpt @@ -0,0 +1,52 @@ +--TEST-- +Test array_column() function: basic functionality +--FILE-- +<?php +class ColumnKeyClass { + function __toString() { return 'first_name'; } +} + +class IndexKeyClass { + function __toString() { return 'id'; } +} + +class ValueClass { + function __toString() { return '2135'; } +} + + +$column_key = new ColumnKeyClass(); +$index_key = new IndexKeyClass(); +$value = new ValueClass(); + + +// Array representing a possible record set returned from a database +$records = array( + array( + 'id' => $value, + 'first_name' => 'John', + 'last_name' => 'XXX' + ), + array( + 'id' => 3245, + 'first_name' => 'Sally', + 'last_name' => 'Smith' + ), +); +$firstNames = array_column($records, $column_key, $index_key); +print_r($firstNames); +var_dump($column_key); +var_dump($index_key); +var_dump($value); +--EXPECTF-- +Array +( + [2135] => John + [3245] => Sally +) +object(ColumnKeyClass)#%d (0) { +} +object(IndexKeyClass)#%d (0) { +} +object(ValueClass)#%d (0) { +} |