Skip to content

Commit

Permalink
Fixed multi-line regex
Browse files Browse the repository at this point in the history
- See issue potsky#33
- Added tests
  • Loading branch information
Max13 committed Aug 21, 2016
1 parent 6c92ea6 commit 24f9eff
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 42 deletions.
28 changes: 14 additions & 14 deletions src/config/config-laravel5.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,30 +60,30 @@
*/
'trans_methods' => array(
'trans' => array(
'@trans\(\s*(\'.*\')\s*(,.*)*\)@U' ,
'@trans\(\s*(".*")\s*(,.*)*\)@U' ,
'@trans\(\s*(\'.*\')\s*(,\s*.*)*\)@U' ,
'@trans\(\s*(".*")\s*(,\s*.*)*\)@U' ,
) ,
'Lang::Get' => array(
'@Lang::Get\(\s*(\'.*\')\s*(,.*)*\)@U' ,
'@Lang::Get\(\s*(".*")\s*(,.*)*\)@U' ,
'@Lang::get\(\s*(\'.*\')\s*(,.*)*\)@U' ,
'@Lang::get\(\s*(".*")\s*(,.*)*\)@U' ,
'@Lang::Get\(\s*(\'.*\')\s*(,\s*.*)*\)@U' ,
'@Lang::Get\(\s*(".*")\s*(,\s*.*)*\)@U' ,
'@Lang::get\(\s*(\'.*\')\s*(,\s*.*)*\)@U' ,
'@Lang::get\(\s*(".*")\s*(,\s*.*)*\)@U' ,
) ,
'trans_choice' => array(
'@trans_choice\(\s*(\'.*\')\s*,.*\)@U' ,
'@trans_choice\(\s*(".*")\s*,.*\)@U' ,
'@trans_choice\(\s*(\'.*\')\s*,\s*.*\)@U' ,
'@trans_choice\(\s*(".*")\s*,\s*.*\)@U' ,
) ,
'Lang::choice' => array(
'@Lang::choice\(\s*(\'.*\')\s*,.*\)@U' ,
'@Lang::choice\(\s*(".*")\s*,.*\)@U' ,
'@Lang::choice\(\s*(\'.*\')\s*,\s*.*\)@U' ,
'@Lang::choice\(\s*(".*")\s*,\s*.*\)@U' ,
) ,
'@lang' => array(
'@\@lang\(\s*(\'.*\')\s*(,.*)*\)@U' ,
'@\@lang\(\s*(".*")\s*(,.*)*\)@U' ,
'@\@lang\(\s*(\'.*\')\s*(,\s*.*)*\)@U' ,
'@\@lang\(\s*(".*")\s*(,\s*.*)*\)@U' ,
) ,
'@choice' => array(
'@\@choice\(\s*(\'.*\')\s*,.*\)@U' ,
'@\@choice\(\s*(".*")\s*,.*\)@U' ,
'@\@choice\(\s*(\'.*\')\s*,\s*.*\)@U' ,
'@\@choice\(\s*(".*")\s*,\s*.*\)@U' ,
) ,
) ,

Expand Down
28 changes: 14 additions & 14 deletions src/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,30 +61,30 @@
*/
'trans_methods' => array(
'trans' => array(
'@trans\(\s*(\'.*\')\s*(,.*)*\)@U' ,
'@trans\(\s*(".*")\s*(,.*)*\)@U' ,
'@trans\(\s*(\'.*\')\s*(,\s*.*)*\)@U' ,
'@trans\(\s*(".*")\s*(,\s*.*)*\)@U' ,
) ,
'Lang::Get' => array(
'@Lang::Get\(\s*(\'.*\')\s*(,.*)*\)@U' ,
'@Lang::Get\(\s*(".*")\s*(,.*)*\)@U' ,
'@Lang::get\(\s*(\'.*\')\s*(,.*)*\)@U' ,
'@Lang::get\(\s*(".*")\s*(,.*)*\)@U' ,
'@Lang::Get\(\s*(\'.*\')\s*(,\s*.*)*\)@U' ,
'@Lang::Get\(\s*(".*")\s*(,\s*.*)*\)@U' ,
'@Lang::get\(\s*(\'.*\')\s*(,\s*.*)*\)@U' ,
'@Lang::get\(\s*(".*")\s*(,\s*.*)*\)@U' ,
) ,
'trans_choice' => array(
'@trans_choice\(\s*(\'.*\')\s*,.*\)@U' ,
'@trans_choice\(\s*(".*")\s*,.*\)@U' ,
'@trans_choice\(\s*(\'.*\')\s*,\s*.*\)@U' ,
'@trans_choice\(\s*(".*")\s*,\s*.*\)@U' ,
) ,
'Lang::choice' => array(
'@Lang::choice\(\s*(\'.*\')\s*,.*\)@U' ,
'@Lang::choice\(\s*(".*")\s*,.*\)@U' ,
'@Lang::choice\(\s*(\'.*\')\s*,\s*.*\)@U' ,
'@Lang::choice\(\s*(".*")\s*,\s*.*\)@U' ,
) ,
'@lang' => array(
'@\@lang\(\s*(\'.*\')\s*(,.*)*\)@U' ,
'@\@lang\(\s*(".*")\s*(,.*)*\)@U' ,
'@\@lang\(\s*(\'.*\')\s*(,\s*.*)*\)@U' ,
'@\@lang\(\s*(".*")\s*(,\s*.*)*\)@U' ,
) ,
'@choice' => array(
'@\@choice\(\s*(\'.*\')\s*,.*\)@U' ,
'@\@choice\(\s*(".*")\s*,.*\)@U' ,
'@\@choice\(\s*(\'.*\')\s*,\s*.*\)@U' ,
'@\@choice\(\s*(".*")\s*,\s*.*\)@U' ,
) ,
) ,

Expand Down
28 changes: 14 additions & 14 deletions tests/CommandFindTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,30 +51,30 @@ public function testSearchForRegexLemma()

$trans_methods = array(
'trans' => array(
'@trans\(\s*(\'.*\')\s*(,.*)*\)@U' ,
'@trans\(\s*(".*")\s*(,.*)*\)@U' ,
'@trans\(\s*(\'.*\')\s*(,\s*.*)*\)@U' ,
'@trans\(\s*(".*")\s*(,\s*.*)*\)@U' ,
) ,
'Lang::Get' => array(
'@Lang::Get\(\s*(\'.*\')\s*(,.*)*\)@U' ,
'@Lang::Get\(\s*(".*")\s*(,.*)*\)@U' ,
'@Lang::get\(\s*(\'.*\')\s*(,.*)*\)@U' ,
'@Lang::get\(\s*(".*")\s*(,.*)*\)@U' ,
'@Lang::Get\(\s*(\'.*\')\s*(,\s*.*)*\)@U' ,
'@Lang::Get\(\s*(".*")\s*(,\s*.*)*\)@U' ,
'@Lang::get\(\s*(\'.*\')\s*(,\s*.*)*\)@U' ,
'@Lang::get\(\s*(".*")\s*(,\s*.*)*\)@U' ,
) ,
'trans_choice' => array(
'@trans_choice\(\s*(\'.*\')\s*,.*\)@U' ,
'@trans_choice\(\s*(".*")\s*,.*\)@U' ,
'@trans_choice\(\s*(\'.*\')\s*,\s*.*\)@U' ,
'@trans_choice\(\s*(".*")\s*,\s*.*\)@U' ,
) ,
'Lang::choice' => array(
'@Lang::choice\(\s*(\'.*\')\s*,.*\)@U' ,
'@Lang::choice\(\s*(".*")\s*,.*\)@U' ,
'@Lang::choice\(\s*(\'.*\')\s*,\s*.*\)@U' ,
'@Lang::choice\(\s*(".*")\s*,\s*.*\)@U' ,
) ,
'@lang' => array(
'@\@lang\(\s*(\'.*\')\s*(,.*)*\)@U' ,
'@\@lang\(\s*(".*")\s*(,.*)*\)@U' ,
'@\@lang\(\s*(\'.*\')\s*(,\s*.*)*\)@U' ,
'@\@lang\(\s*(".*")\s*(,\s*.*)*\)@U' ,
) ,
'@choice' => array(
'@\@choice\(\s*(\'.*\')\s*,.*\)@U' ,
'@\@choice\(\s*(".*")\s*,.*\)@U' ,
'@\@choice\(\s*(\'.*\')\s*,\s*.*\)@U' ,
'@\@choice\(\s*(".*")\s*,\s*.*\)@U' ,
) ,
);

Expand Down
10 changes: 10 additions & 0 deletions tests/mock/trans.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
$d = trans( 'message.lemma.child 2' , [ 'name' => 'potsky' ] );
$e = trans_choice( 'message.lemma.child 3' , 0 , array( 'name' => 'potsky' , 'count' => 0 ) );
$f = trans_choice( 'message.lemma.child 4' , 2 , [ 'name' => 'potsky', 'count' => 2 ] );
$g = trans_choice(
'message.lemma.child 5' ,
0 ,
array( 'name' => 'potsky' , 'count' => 0 )
);

// method style
$la = Lang::get( 'message.lemma l' );
Expand All @@ -28,6 +33,11 @@
$ld = Lang::get( 'message.lemma.child l2' , [ 'name' => 'potsky' ] );
$le = Lang::choice( 'message.lemma.child l3' , 0 , array( 'name' => 'potsky' , 'count' => 0 ) );
$lf = Lang::choice( 'message.lemma.child l4' , 2 , [ 'name' => 'potsky', 'count' => 2 ] );
$lg = Lang::choice(
'message.lemma.child l5' ,
0 ,
array( 'name' => 'potsky' , 'count' => 0 )
);

// check translation
trans( 'message.dog' );
Expand Down

0 comments on commit 24f9eff

Please sign in to comment.