From a696e559b7a76f5f81568efc87494abed599f08d Mon Sep 17 00:00:00 2001 From: Michael Stilkerich Date: Fri, 1 Apr 2022 16:13:55 +0200 Subject: [PATCH] Treat readline functions as impure --- src/Psalm/Internal/Codebase/Functions.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Psalm/Internal/Codebase/Functions.php b/src/Psalm/Internal/Codebase/Functions.php index f8f5b16fa..ca882a0c6 100644 --- a/src/Psalm/Internal/Codebase/Functions.php +++ b/src/Psalm/Internal/Codebase/Functions.php @@ -404,7 +404,7 @@ class Functions 'opendir', 'readdir', 'closedir', 'rewinddir', 'scandir', 'fopen', 'fread', 'fwrite', 'fclose', 'touch', 'fpassthru', 'fputs', 'fscanf', 'fseek', 'flock', 'ftruncate', 'fprintf', 'symlink', 'mkdir', 'unlink', 'rename', 'rmdir', 'popen', 'pclose', - 'fgetcsv', 'fputcsv', 'umask', 'finfo_open', 'finfo_close', 'finfo_file', 'readline_add_history', + 'fgetcsv', 'fputcsv', 'umask', 'finfo_open', 'finfo_close', 'finfo_file', 'stream_set_timeout', 'fgets', 'fflush', 'move_uploaded_file', 'file_exists', 'realpath', 'glob', 'is_readable', 'is_dir', 'is_file', @@ -515,6 +515,10 @@ class Functions return false; } + if (strpos($function_id, 'readline') === 0) { + return false; + } + if (($function_id === 'var_export' || $function_id === 'print_r') && !isset($args[1])) { return false; }