line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# parse and transform PHP source files |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
package PHP::Decode; |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
68515
|
use strict; |
|
2
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
60
|
|
7
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
52
|
|
8
|
2
|
|
|
2
|
|
1729
|
use PHP::Decode::Parser; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
161
|
|
9
|
2
|
|
|
2
|
|
2385
|
use PHP::Decode::Transformer; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
1404
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.301_04'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
721
|
|
|
721
|
1
|
35820
|
my ($class, %args) = @_; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $parser = PHP::Decode::Parser->new(strmap => {}, |
17
|
|
|
|
|
|
|
exists $args{inscript} ? (inscript => $args{inscript}) : (), |
18
|
|
|
|
|
|
|
exists $args{filename} ? (filename => $args{filename}) : (), |
19
|
|
|
|
|
|
|
exists $args{max_strlen} ? (max_strlen => $args{max_strlen}) : (), |
20
|
|
|
|
|
|
|
exists $args{log} ? (log => $args{log}) : (), |
21
|
|
|
|
|
|
|
exists $args{debug} ? (debug => $args{debug}) : (), |
22
|
721
|
50
|
|
|
|
6148
|
exists $args{warn} ? (warn => $args{warn}) : ()); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $ctx = PHP::Decode::Transformer->new(parser => $parser, |
25
|
|
|
|
|
|
|
exists $args{skip} ? (skip => $args{skip}) : (), |
26
|
|
|
|
|
|
|
exists $args{with} ? (with => $args{with}) : (), |
27
|
|
|
|
|
|
|
exists $args{max_loop} ? (max_loop => $args{max_loop}) : (), |
28
|
|
|
|
|
|
|
exists $args{log} ? (log => \&_log_cb) : (), |
29
|
721
|
50
|
|
|
|
5070
|
exists $args{warn} ? (warn => \&_warn_cb) : ()); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
721
|
|
|
|
|
2602
|
return bless { |
32
|
|
|
|
|
|
|
ctx => $ctx, |
33
|
|
|
|
|
|
|
}, $class; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _log_cb { |
37
|
0
|
|
|
0
|
|
0
|
my ($ctx, $action, $stmt, $fmt) = (shift, shift, shift, shift); |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
0
|
my $parser = $ctx->{parser}; |
40
|
0
|
0
|
|
|
|
0
|
my $flg = $ctx->{skipundef} ? '! ' : ''; |
41
|
0
|
0
|
|
|
|
0
|
if ($ctx->{incall}) { |
|
|
0
|
|
|
|
|
|
42
|
0
|
|
|
|
|
0
|
$parser->{log}->($flg . "[$ctx->{infunction}] $action $stmt", $fmt, @_); |
43
|
|
|
|
|
|
|
} elsif ($ctx->{infunction}) { |
44
|
0
|
|
|
|
|
0
|
$parser->{log}->("<$ctx->{infunction}> $action $stmt", $fmt, @_); |
45
|
|
|
|
|
|
|
} else { |
46
|
0
|
|
|
|
|
0
|
$parser->{log}->($flg . "$action $stmt", $fmt, @_); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _warn_cb { |
51
|
1834
|
|
|
1834
|
|
4323
|
my ($ctx, $action, $stmt, $fmt) = (shift, shift, shift, shift); |
52
|
|
|
|
|
|
|
|
53
|
1834
|
|
|
|
|
3012
|
my $parser = $ctx->{parser}; |
54
|
1834
|
100
|
|
|
|
4098
|
my $flg = $ctx->{skipundef} ? '! ' : ''; |
55
|
1834
|
100
|
|
|
|
4461
|
if ($ctx->{incall}) { |
|
|
100
|
|
|
|
|
|
56
|
95
|
|
|
|
|
471
|
$parser->{warn}->($flg . "[$ctx->{infunction}] $action $stmt", $fmt, @_); |
57
|
|
|
|
|
|
|
} elsif ($ctx->{infunction}) { |
58
|
416
|
|
|
|
|
1837
|
$parser->{warn}->("<$ctx->{infunction}> $action $stmt", $fmt, @_); |
59
|
|
|
|
|
|
|
} else { |
60
|
1323
|
|
|
|
|
5475
|
$parser->{warn}->($flg . "$action $stmt", $fmt, @_); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub parse { |
65
|
0
|
|
|
0
|
1
|
0
|
my ($self, $line) = @_; |
66
|
0
|
|
|
|
|
0
|
my $parser = $self->{ctx}{parser}; |
67
|
0
|
|
|
|
|
0
|
my $str = $parser->setstr($line); |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
0
|
return $self->{ctx}->parse_eval($str); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub exec { |
73
|
0
|
|
|
0
|
1
|
0
|
my ($self, $stmt) = @_; |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
0
|
return $self->{ctx}->exec_eval($stmt); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub eval { |
79
|
721
|
|
|
721
|
1
|
3062
|
my ($self, $line) = @_; |
80
|
721
|
|
|
|
|
1538
|
my $parser = $self->{ctx}{parser}; |
81
|
721
|
|
|
|
|
1905
|
my $str = $parser->setstr($line); |
82
|
|
|
|
|
|
|
|
83
|
721
|
|
|
|
|
2164
|
my $stmt = $self->{ctx}->parse_eval($str); |
84
|
721
|
|
|
|
|
2869
|
return $self->{ctx}->exec_eval($stmt); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub format { |
88
|
721
|
|
|
721
|
1
|
3647
|
my ($self, $stmt, $fmt) = @_; |
89
|
721
|
|
|
|
|
1341
|
my $parser = $self->{ctx}{parser}; |
90
|
|
|
|
|
|
|
|
91
|
721
|
|
|
|
|
2010
|
return $parser->format_stmt($stmt, $fmt); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
__END__ |