1--TEST--
2Test function posix_ttyname() by substituting argument 1 with object values.
3--CREDITS--
4Marco Fabbri mrfabbri@gmail.com
5Francesco Fullone ff@ideato.it
6#PHPTestFest Cesena Italia on 2009-06-20
7--SKIPIF--
8<?php
9if (!extension_loaded('posix')) {
10    die('SKIP The posix extension is not loaded.');
11}
12?>
13--FILE--
14<?php
15
16
17echo "*** Test substituting argument 1 with object values ***\n";
18
19
20
21function 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";
25        }
26}
27set_error_handler('test_error_handler');
28
29
30
31class classWithToString
32{
33        public function __toString() {
34                return "Class A object";
35        }
36}
37
38class classWithoutToString
39{
40}
41
42$variation_array = array(
43  'instance of classWithToString' => new classWithToString(),
44  'instance of classWithoutToString' => new classWithoutToString(),
45  );
46
47
48foreach ( $variation_array as $var ) {
49  var_dump(posix_ttyname( $var  ) );
50}
51?>
52--EXPECTF--
53*** Test substituting argument 1 with object values ***
54Error: 8 - Object of class classWithToString could not be converted to int, %s(%d)
55bool(false)
56Error: 8 - Object of class classWithoutToString could not be converted to int, %s(%d)
57bool(false)
58