From 0ef71a49cbbc18fc948a4af113eced6eb8a2839a Mon Sep 17 00:00:00 2001 From: Matt Brown Date: Tue, 10 Jul 2018 17:40:34 -0400 Subject: [PATCH] Fix #882 - allow STDOUT and STDERR as constants --- .../Statements/Expression/Fetch/ConstFetchChecker.php | 7 +++++++ tests/ConstantTest.php | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/src/Psalm/Checker/Statements/Expression/Fetch/ConstFetchChecker.php b/src/Psalm/Checker/Statements/Expression/Fetch/ConstFetchChecker.php index 16c6bbce3e6..ea2ec7ff4d9 100644 --- a/src/Psalm/Checker/Statements/Expression/Fetch/ConstFetchChecker.php +++ b/src/Psalm/Checker/Statements/Expression/Fetch/ConstFetchChecker.php @@ -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])) { diff --git a/tests/ConstantTest.php b/tests/ConstantTest.php index 2dd80790eff..ba35a513144 100644 --- a/tests/ConstantTest.php +++ b/tests/ConstantTest.php @@ -215,6 +215,12 @@ class B { ' [ + '