Skip to content

Commit

Permalink
Fix #882 - allow STDOUT and STDERR as constants
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Jul 10, 2018
1 parent 66f6d4b commit 0ef71a4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Expand Up @@ -236,6 +236,13 @@ public static function getGlobalConstType(
$fq_const_name,
$const_name
) {
if ($const_name === 'STDERR'
|| $const_name === 'STDOUT'
|| $const_name === 'STDIN'
) {
return Type::getResource();
}

$predefined_constants = $codebase->config->getPredefinedConstants();

if (isset($predefined_constants[$fq_const_name ?: $const_name])) {
Expand Down
6 changes: 6 additions & 0 deletions tests/ConstantTest.php
Expand Up @@ -215,6 +215,12 @@ class B {
'<?php
if ("phpdbg" === \PHP_SAPI) {}',
],
'stdinout' => [
'<?php
echo fread(STDIN, 100);
fwrite(STDOUT, "asd");
fwrite(STDERR, "zcx");'
],
];
}

Expand Down

0 comments on commit 0ef71a4

Please sign in to comment.