1--TEST--
2posix_ttyname(): 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_ttyname($type));
35}
36?>
37--EXPECTF--
38null:
39Deprecated: posix_ttyname(): 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_ttyname(): Argument #1 ($file_descriptor) must be of type int|resource, string given in %s on line %d
55bool(false)
56array:
57Warning: posix_ttyname(): Argument #1 ($file_descriptor) must be of type int|resource, array given in %s on line %d
58bool(false)
59class:
60Warning: posix_ttyname(): Argument #1 ($file_descriptor) must be of type int|resource, stdClass given in %s on line %d
61
62Warning: Object of class stdClass could not be converted to int in %s on line %d
63bool(false)
64stringable class:
65Warning: posix_ttyname(): Argument #1 ($file_descriptor) must be of type int|resource, classWithToString given in %s on line %d
66
67Warning: Object of class classWithToString could not be converted to int in %s on line %d
68bool(false)
69int castable class:
70Warning: posix_ttyname(): Argument #1 ($file_descriptor) must be of type int|resource, GMP given in %s on line %d
71bool(false)
72