@@ -77,23 +77,47 @@ public function parse($file, $searchObjects = false)
77
77
protected function _extractPhrases ($ searchObjects )
78
78
{
79
79
if ($ firstToken = $ this ->_tokenizer ->getNextRealToken ()) {
80
- if ($ firstToken ->isEqualFunction ('__ ' )) {
81
- $ secondToken = $ this ->_tokenizer ->getNextRealToken ();
82
- if ($ secondToken && $ secondToken ->isOpenBrace ()) {
83
- $ arguments = $ this ->_tokenizer ->getFunctionArgumentsTokens ();
84
- $ phrase = $ this ->_collectPhrase (array_shift ($ arguments ));
85
- if (null !== $ phrase ) {
86
- $ this ->_addPhrase ($ phrase , count ($ arguments ), $ this ->_file , $ firstToken ->getLine ());
87
- }
88
- }
89
- } elseif ($ searchObjects && $ firstToken ->isNew () && $ this ->_tokenizer ->isMatchingClass ('Phrase ' )) {
80
+ if (!$ this ->extractMethodPhrase ($ firstToken ) && $ searchObjects ) {
81
+ $ this ->extractObjectPhrase ($ firstToken );
82
+ }
83
+ }
84
+ }
85
+
86
+ /**
87
+ * @param Token $firstToken
88
+ * @return bool
89
+ */
90
+ protected function extractMethodPhrase (Token $ firstToken )
91
+ {
92
+ if ($ firstToken ->isEqualFunction ('__ ' )) {
93
+ $ secondToken = $ this ->_tokenizer ->getNextRealToken ();
94
+ if ($ secondToken && $ secondToken ->isOpenBrace ()) {
90
95
$ arguments = $ this ->_tokenizer ->getFunctionArgumentsTokens ();
91
96
$ phrase = $ this ->_collectPhrase (array_shift ($ arguments ));
92
97
if (null !== $ phrase ) {
93
98
$ this ->_addPhrase ($ phrase , count ($ arguments ), $ this ->_file , $ firstToken ->getLine ());
99
+ return true ;
94
100
}
95
101
}
96
102
}
103
+ return false ;
104
+ }
105
+
106
+ /**
107
+ * @param Token $firstToken
108
+ * @return bool
109
+ */
110
+ protected function extractObjectPhrase (Token $ firstToken )
111
+ {
112
+ if ($ firstToken ->isNew () && $ this ->_tokenizer ->isMatchingClass ('Phrase ' )) {
113
+ $ arguments = $ this ->_tokenizer ->getFunctionArgumentsTokens ();
114
+ $ phrase = $ this ->_collectPhrase (array_shift ($ arguments ));
115
+ if (null !== $ phrase ) {
116
+ $ this ->_addPhrase ($ phrase , count ($ arguments ), $ this ->_file , $ firstToken ->getLine ());
117
+ return true ;
118
+ }
119
+ }
120
+ return false ;
97
121
}
98
122
99
123
/**
0 commit comments