Edit report at https://bugs.php.net/bug.php?id=63639&edit=1

 ID:                 63639
 Updated by:         m...@php.net
 Reported by:        antronin at gmail dot com
 Summary:            posix_isatty and posix_ttyname weird var handling
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            POSIX related
 Operating System:   Ubuntu 12.10
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Expecting integer parameters the arguments get converted, so:

true -> 1 -> STDOUT
false/'str'/array() -> 0 -> STDIN


Previous Comments:
------------------------------------------------------------------------
[2012-11-28 21:55:52] antronin at gmail dot com

Description:
------------
---
>From manual page: http://www.php.net/function.posix-isatty
---
Although documentation says "Returns TRUE if fd is an open descriptor connected 
to a terminal and FALSE otherwise." clearly this is not the case. 
It also returns TRUE if the parameter is not a file descriptor at all except is 
it is an integer < 3.

Test script:
---------------
var_dump(posix_isatty(true));
var_dump(posix_isatty(false));
var_dump(posix_isatty('str'));
var_dump(posix_isatty(array()));
var_dump(posix_isatty(42));

for ($i=0; $i<50; $i++) {
    var_dump(posix_isatty($i));
}


Expected result:
----------------
(bool)false
(bool)false
(bool)false
(bool)false
(bool)false

(bool)false x50

Actual result:
--------------
(bool)true
(bool)true
(bool)true
(bool)true
(bool)false

(bool)true
(bool)true
(bool)true
(bool)false x47


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63639&edit=1

Reply via email to