PageRenderTime 41ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/hphp/test/zend/bad/ext/standard/tests/array/array_udiff_uassoc_variation4.php

http://github.com/facebook/hiphop-php
PHP | 103 lines | 59 code | 22 blank | 22 comment | 0 complexity | b865dce7db7879486316f32fc6e4ddff MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
  1. <?php
  2. /* Prototype : array array_udiff_uassoc(array arr1, array arr2 [, array ...], callback data_comp_func, callback key_comp_func)
  3. * Description: Returns the entries of arr1 that have values which are not present in any of the others arguments but do additional checks whether the keys are equal. Keys and elements are compared by user supplied functions.
  4. * Source code: ext/standard/array.c
  5. * Alias to functions:
  6. */
  7. echo "*** Testing array_udiff_uassoc() : usage variation ***\n";
  8. // Initialise function arguments not being substituted (if any)
  9. $arr1 = array(1, 2);
  10. $arr2 = array(1, 2);
  11. include('compare_function.inc');
  12. $data_comp_func = 'compare_function';
  13. //get an unset variable
  14. $unset_var = 10;
  15. unset ($unset_var);
  16. // define some classes
  17. class classWithToString
  18. {
  19. public function __toString() {
  20. return "Class A object";
  21. }
  22. }
  23. class classWithoutToString
  24. {
  25. }
  26. // heredoc string
  27. $heredoc = <<<EOT
  28. hello world
  29. EOT;
  30. // add arrays
  31. $index_array = array (1, 2, 3);
  32. $assoc_array = array ('one' => 1, 'two' => 2);
  33. //array of values to iterate over
  34. $inputs = array(
  35. // int data
  36. 'int 0' => 0,
  37. 'int 1' => 1,
  38. 'int 12345' => 12345,
  39. 'int -12345' => -2345,
  40. // float data
  41. 'float 10.5' => 10.5,
  42. 'float -10.5' => -10.5,
  43. 'float 12.3456789000e10' => 12.3456789000e10,
  44. 'float -12.3456789000e10' => -12.3456789000e10,
  45. 'float .5' => .5,
  46. // array data
  47. 'empty array' => array(),
  48. 'int indexed array' => $index_array,
  49. 'associative array' => $assoc_array,
  50. 'nested arrays' => array('foo', $index_array, $assoc_array),
  51. // null data
  52. 'uppercase NULL' => NULL,
  53. 'lowercase null' => null,
  54. // boolean data
  55. 'lowercase true' => true,
  56. 'lowercase false' =>false,
  57. 'uppercase TRUE' =>TRUE,
  58. 'uppercase FALSE' =>FALSE,
  59. // empty data
  60. 'empty string DQ' => "",
  61. 'empty string SQ' => '',
  62. // string data
  63. 'string DQ' => "string",
  64. 'string SQ' => 'string',
  65. 'mixed case string' => "sTrInG",
  66. 'heredoc' => $heredoc,
  67. // object data
  68. 'instance of classWithToString' => new classWithToString(),
  69. 'instance of classWithoutToString' => new classWithoutToString(),
  70. // undefined data
  71. 'undefined var' => @$undefined_var,
  72. // unset data
  73. 'unset var' => @$unset_var,
  74. );
  75. // loop through each element of the array for key_comp_func
  76. foreach($inputs as $key =>$value) {
  77. echo "\n--$key--\n";
  78. var_dump( array_udiff_uassoc($arr1, $arr2, $data_comp_func, $value) );
  79. };
  80. ?>
  81. ===DONE===