1--TEST--
2posix_isatty(): manually validating int ZPP param
3--EXTENSIONS--
4posix
5gmp
6--FILE--
7<?php
8
9class classWithToString {
10    public function __toString() {
11        return "string";
12    }
13}
14
15$types = [
16    'null' => null,
17    'false' => false,
18    'true' => true,
19    'int' => 1,
20    'float no decimal' => 1.0,
21    'float decimal' => 5.5,
22    'string int' => "1",
23    'string float no decimal' => "1.0",
24    'string float decimal' => "5.5",
25    'string' => "Hello",
26    'array' => [],
27    'class' => new stdClass(),
28    'stringable class' => new classWithToString(),
29    'int castable class' => gmp_init(1),
30];
31
32foreach ($types as $description => $type) {
33    echo $description, ':';
34    var_dump(posix_isatty($type));
35}
36?>
37--EXPECTF--
38null:
39Deprecated: posix_isatty(): Passing null to parameter #1 ($file_descriptor) of type int is deprecated in %s on line %d
40bool(false)
41false:bool(false)
42true:bool(false)
43int:bool(false)
44float no decimal:bool(false)
45float decimal:
46Deprecated: Implicit conversion from float 5.5 to int loses precision in %s on line %d
47bool(false)
48string int:bool(false)
49string float no decimal:bool(false)
50string float decimal:
51Deprecated: Implicit conversion from float-string "5.5" to int loses precision in %s on line %d
52bool(false)
53string:
54Warning: posix_isatty(): Argument #1 ($file_descriptor) must be of type int|resource, string given in %s on line %d
55bool(false)
56array:
57Warning: posix_isatty(): Argument #1 ($file_descriptor) must be of type int|resource, array given in %s on line %d
58bool(false)
59class:
60Warning: posix_isatty(): Argument #1 ($file_descriptor) must be of type int|resource, stdClass given in %s on line %d
61bool(false)
62stringable class:
63Warning: posix_isatty(): Argument #1 ($file_descriptor) must be of type int|resource, classWithToString given in %s on line %d
64bool(false)
65int castable class:
66Warning: posix_isatty(): Argument #1 ($file_descriptor) must be of type int|resource, GMP given in %s on line %d
67bool(false)
68