|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace PHPSA\Analyzer\Pass\Expression\FunctionCall; |
|
4
|
|
|
|
|
5
|
|
|
use PhpParser\Node\Expr\FuncCall; |
|
6
|
|
|
use PhpParser\Node\Name; |
|
7
|
|
|
use PHPSA\Compiler\Expression; |
|
8
|
|
|
use PHPSA\Context; |
|
9
|
|
|
|
|
10
|
|
|
class DeprecatedFunctions extends AbstractFunctionCallAnalyzer |
|
11
|
|
|
{ |
|
12
|
|
|
protected $map = [ |
|
13
|
|
|
'datefmt_set_timezone_id' => ['5.5','IntlDateFormatter::setTimeZone()'], |
|
14
|
|
|
'define_syslog_variables' => ['5.3','_'], |
|
15
|
|
|
'set_magic_quotes_runtime' => ['5.3','_'], |
|
16
|
|
|
'set_socket_blocking' => ['5.3','_'], |
|
17
|
|
|
'ereg' => ['5.3','preg_match()'], |
|
18
|
|
|
'eregi' => ['5.3','preg_match()'], |
|
19
|
|
|
'ereg_replace' => ['5.3','preg_replace()'], |
|
20
|
|
|
'eregi_replace' => ['5.3','preg_replace()'], |
|
21
|
|
|
'split' => ['5.3','explode()'], |
|
22
|
|
|
'spliti' => ['5.3','preg_split()'], |
|
23
|
|
|
'sql_regcase' => ['5.3','preg_match()'], |
|
24
|
|
|
'session_is_registered' => ['5.3','$_SESSION'], |
|
25
|
|
|
'session_unregister' => ['5.3','$_SESSION'], |
|
26
|
|
|
'session_register' => ['5.3','$_SESSION'], |
|
27
|
|
|
]; |
|
28
|
|
|
|
|
29
|
6 |
|
public function pass(FuncCall $funcCall, Context $context) |
|
30
|
|
|
{ |
|
31
|
6 |
|
$functionName = $this->resolveFunctionName($funcCall, $context); |
|
32
|
6 |
|
if ($functionName) { |
|
33
|
6 |
|
if (isset($this->map[$functionName])) { |
|
34
|
|
|
$context->notice( |
|
35
|
|
|
'deprecated.function', |
|
36
|
|
|
sprintf('%s() is deprecated since PHP %s. Use %s instead.', $functionName, $this->map[$functionName][0], $this->map[$functionName][1]), |
|
37
|
|
|
$funcCall |
|
38
|
|
|
); |
|
39
|
6 |
|
} elseif (substr($functionName, 0, 6) === 'mysql_') { |
|
40
|
|
|
$context->notice( |
|
41
|
|
|
'deprecated.function', |
|
42
|
|
|
sprintf('The MySQL Extension is deprecated since PHP 5.5. Use PDO instead.'), |
|
43
|
|
|
$funcCall |
|
44
|
|
|
); |
|
45
|
6 |
|
} elseif (substr($functionName, 0, 7) === 'mcrypt_') { |
|
46
|
|
|
$context->notice( |
|
47
|
|
|
'deprecated.function', |
|
48
|
|
|
sprintf('The Mcrypt Extension is deprecated since PHP 7.1. Use paragonie/halite instead.'), |
|
49
|
|
|
$funcCall |
|
50
|
|
|
); |
|
51
|
|
|
} |
|
52
|
6 |
|
} |
|
53
|
6 |
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|