From 956a7c749b4bbbeff9754e49d7542fef51c37cad Mon Sep 17 00:00:00 2001 From: Matt Brown Date: Wed, 29 Aug 2018 13:58:07 -0400 Subject: [PATCH] Improve handling of array_search and strstr, and restrict ini_set types --- src/Psalm/CallMap.php | 2 +- src/Psalm/Checker/FunctionChecker.php | 5 +++++ src/psalm.php | 6 +++--- src/psalter.php | 4 ++-- tests/bootstrap.php | 4 ++-- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Psalm/CallMap.php b/src/Psalm/CallMap.php index 41288039e..c241b1b16 100644 --- a/src/Psalm/CallMap.php +++ b/src/Psalm/CallMap.php @@ -5343,7 +5343,7 @@ return [ 'ini_get' => ['string|false', 'varname'=>'string'], 'ini_get_all' => ['array', 'extension='=>'?string', 'details='=>'bool'], 'ini_restore' => ['void', 'varname'=>'string'], -'ini_set' => ['string|false', 'varname'=>'string', 'newvalue'=>'string|int|float|bool'], +'ini_set' => ['string|false', 'varname'=>'string', 'newvalue'=>'string'], 'inotify_add_watch' => ['int', 'inotify_instance'=>'resource', 'pathname'=>'string', 'mask'=>'int'], 'inotify_init' => ['resource'], 'inotify_queue_len' => ['int', 'inotify_instance'=>'resource'], diff --git a/src/Psalm/Checker/FunctionChecker.php b/src/Psalm/Checker/FunctionChecker.php index 7f95ac8b1..3b0bea870 100644 --- a/src/Psalm/Checker/FunctionChecker.php +++ b/src/Psalm/Checker/FunctionChecker.php @@ -494,6 +494,11 @@ class FunctionChecker extends FunctionLikeChecker case 'strrpos': case 'stripos': case 'strripos': + case 'strstr': + case 'stristr': + case 'strrchr': + case 'strpbrk': + case 'array_search': break; default: diff --git a/src/psalm.php b/src/psalm.php index 676118f10..fad4f135d 100644 --- a/src/psalm.php +++ b/src/psalm.php @@ -77,9 +77,9 @@ array_map( $options = getopt(implode('', $valid_short_options), $valid_long_options); if (!array_key_exists('use-ini-defaults', $options)) { - ini_set('display_errors', 1); - ini_set('display_startup_errors', 1); - ini_set('memory_limit', 4 * 1024 * 1024 * 1024); + ini_set('display_errors', '1'); + ini_set('display_startup_errors', '1'); + ini_set('memory_limit', (string) (4 * 1024 * 1024 * 1024)); } if (array_key_exists('help', $options)) { diff --git a/src/psalter.php b/src/psalter.php index ccbbc5b86..ba056139b 100644 --- a/src/psalter.php +++ b/src/psalter.php @@ -7,8 +7,8 @@ use Psalm\IssueBuffer; // show all errors error_reporting(-1); -ini_set('display_errors', 1); -ini_set('display_startup_errors', 1); +ini_set('display_errors', '1'); +ini_set('display_startup_errors', '1'); ini_set('memory_limit', '2048M'); // get options from command line diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 55d15f200..84687b5dd 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,7 +1,7 @@