summaryrefslogtreecommitdiff
path: root/ext/standard/tests/file/is_file_variation3.phpt
blob: 0a06ad501585b237e3c6b475e20a093209ad5e91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
--TEST--
Test is_file() function: usage variations - invalid filenames
--FILE--
<?php
/* Prototype: bool is_file ( string $filename );
   Description: Tells whether the filename is a regular file
     Returns TRUE if the filename exists and is a regular file
*/

/* Testing is_file() with invalid arguments -int, float, bool, NULL, resource */

function flatten($variable) {
    \ob_start();
    \var_dump($variable);
    $flattened =
        \ob_get_contents();
    \ob_end_clean();
    return \trim($flattened);
}

foreach([
  /* Invalid filenames */
  -2.34555,
  " ",
  "",
  true,
  false,
  null,

  /* scalars */
  1234,
  0,

  /* resource */
  fopen(__FILE__, "r")
] as $filename ) {
  printf(
      "%s: %d\n",
      flatten($filename), @is_file($filename));
  clearstatcache();
}
?>
--EXPECTF--
float(-2.34555): 0
string(1) " ": 0
string(0) "": 0
bool(true): 0
bool(false): 0
NULL: 0
int(1234): 0
int(0): 0
resource(%d) of type (stream): 0