Create post-HADVAs expect files
[hiphop-php.git] / hphp / test / zend / good / ext / standard / tests / file / basename_variation4.php
blob98c564f9e7ecf5de737ad2954a848e767920a20f
1 <?hh
2 /* Prototype : string basename(string path [, string suffix])
3 * Description: Returns the filename component of the path
4 * Source code: ext/standard/string.c
5 * Alias to functions:
6 */
8 // define some classes
9 class classWithToString
11 public function __toString() {
12 return "Class A object";
16 class classWithoutToString
20 // Define error handler
21 function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
22 if (error_reporting() != 0) {
23 // report non-silenced errors
24 echo "Error: $err_no - $err_msg, $filename($linenum)\n";
27 <<__EntryPoint>> function main(): void {
28 echo "*** Testing basename() : usage variation ***\n";
29 set_error_handler(test_error_handler<>);
31 // Initialise function arguments not being substituted
32 $path = 'path';
35 // heredoc string
36 $heredoc = <<<EOT
37 hello world
38 EOT;
40 // add arrays
41 $index_array = varray [1, 2, 3];
42 $assoc_array = darray ['one' => 1, 'two' => 2];
44 //array of values to iterate over
45 $inputs = darray[
47 // int data
48 'int 0' => 0,
49 'int 1' => 1,
50 'int 12345' => 12345,
51 'int -12345' => -2345,
53 // float data
54 'float 10.5' => 10.5,
55 'float -10.5' => -10.5,
56 'float 12.3456789000e10' => 12.3456789000e10,
57 'float -12.3456789000e10' => -12.3456789000e10,
58 'float .5' => .5,
60 // array data
61 'empty array' => varray[],
62 'int indexed array' => $index_array,
63 'associative array' => $assoc_array,
64 'nested arrays' => varray['foo', $index_array, $assoc_array],
66 // null data
67 'uppercase NULL' => NULL,
68 'lowercase null' => null,
70 // boolean data
71 'lowercase true' => true,
72 'lowercase false' =>false,
73 'uppercase TRUE' =>TRUE,
74 'uppercase FALSE' =>FALSE,
76 // empty data
77 'empty string DQ' => "",
78 'empty string SQ' => '',
80 // object data
81 'instance of classWithToString' => new classWithToString(),
82 'instance of classWithoutToString' => new classWithoutToString(),
87 // loop through each element of the array for suffix
89 foreach($inputs as $key =>$value) {
90 echo "\n--$key--\n";
91 try { var_dump( basename($path, $value) ); } catch (Exception $e) { echo "\n".'Warning: '.$e->getMessage().' in '.__FILE__.' on line '.__LINE__."\n"; }
94 echo "===DONE===\n";