Skip to content
Permalink
Browse files

Extend impure functions (#2042)

* extended impure functions, fixes #2038

* extended UnusedCodeTest #2038
  • Loading branch information...
thomasbley authored and muglug committed Aug 21, 2019
1 parent f08894d commit 149402abda0cab0751dc4a46a9feadab0537cf00
Showing with 14 additions and 3 deletions.
  1. +4 −3 src/Psalm/Internal/Codebase/Functions.php
  2. +10 −0 tests/UnusedCodeTest.php
@@ -271,7 +271,7 @@ public function isCallMapFunctionPure(Codebase $codebase, string $function_id, a
'chdir', 'chgrp', 'chmod', 'chown', 'chroot', 'closedir', 'copy', 'file_put_contents',
'fopen', 'fread', 'fwrite', 'fclose', 'touch', 'fpassthru', 'fputs', 'fscanf', 'fseek',
'ftruncate', 'fprintf', 'symlink', 'mkdir', 'unlink', 'rename', 'rmdir', 'popen', 'pclose',
'fputcsv',
'fputcsv', 'umask',
// stream/socket io
'stream_context_set_option', 'socket_write', 'stream_set_blocking', 'socket_close',
@@ -296,8 +296,9 @@ public function isCallMapFunctionPure(Codebase $codebase, string $function_id, a
'curl_setopt', 'curl_close', 'curl_multi_add_handle', 'curl_multi_remove_handle',
'curl_multi_select', 'curl_multi_close', 'curl_setopt_array',
// apc
'apc_store', 'apc_delete', 'apcu_store', 'apcu_delete', 'apc_clear_cache',
// apc, apcu
'apc_store', 'apc_delete', 'apc_clear_cache', 'apc_add', 'apc_inc', 'apc_dec', 'apc_cas',
'apcu_store', 'apcu_delete', 'apcu_clear_cache', 'apcu_add', 'apcu_inc', 'apcu_dec', 'apcu_cas',
// newrelic
'newrelic_start_transaction', 'newrelic_name_transaction', 'newrelic_add_custom_parameter',
@@ -246,6 +246,11 @@ function foo(int $unusedArg) : void {}
foo(4);',
],
'usedFunctionCall' => [
'<?php
$a = strlen("goodbye");
echo $a;',
],
'possiblyUnusedParamWithUnderscore' => [
'<?php
class A {
@@ -645,6 +650,11 @@ public function bar() : void {}
(new C)->bar();',
'error_message' => 'PossiblyUnusedMethod',
],
'unusedFunctionCall' => [
'<?php
strlen("goodbye");',
'error_message' => 'UnusedFunctionCall',
],
'propertyOverriddenDownstreamAndNotUsed' => [
'<?php
class A {

0 comments on commit 149402a

Please sign in to comment.
You can’t perform that action at this time.