@@ -76,6 +76,9 @@ class ActionObject
76
76
const ACTION_ATTRIBUTE_USERINPUT = 'userInput ' ;
77
77
const ACTION_TYPE_COMMENT = 'comment ' ;
78
78
const INVISIBLE_STEP_ACTIONS = ['retrieveEntityField ' , 'getSecret ' ];
79
+ const REGEX_SINGLE_GROUP = '[\w]+ ' ;
80
+ const REGEX_WITH_INDEX = '[\w]+\.[\w\[\]]+ ' ;
81
+ const REGEX_WITH_PARAM = '[\w]+\.[\w]+\((?(?!}}).)+\) ' ;
79
82
80
83
/**
81
84
* The unique identifier for the action
@@ -433,8 +436,13 @@ private function resolveUrlReference()
433
436
*/
434
437
private function getMissingReferences ($ replacement ): array
435
438
{
436
- $ mustachePattern = '/({{[\w]+}})|({{[\w]+\.[\w\[\]]+}})|({{[\w]+\.[\w]+\((?(?!}}).)+\)}})/ ' ;
437
- preg_match_all ($ mustachePattern , $ replacement , $ matches );
439
+ $ matchPatterns = [
440
+ self ::REGEX_SINGLE_GROUP ,
441
+ self ::REGEX_WITH_INDEX ,
442
+ self ::REGEX_WITH_PARAM
443
+ ];
444
+
445
+ preg_match_all ($ this ->getMustachePattern ($ matchPatterns ), $ replacement , $ matches );
438
446
439
447
return array_filter ($ matches [1 ], function ($ match ) {
440
448
return !empty ($ match ) && false === strpos ($ match , '_ENV. ' );
@@ -534,10 +542,12 @@ private function stripAndReturnParameters($reference)
534
542
*/
535
543
private function findAndReplaceReferences ($ objectHandler , $ inputString )
536
544
{
537
- //look for parameter area, if so use different regex
538
- $ regex = ActionObject::ACTION_ATTRIBUTE_VARIABLE_REGEX_PATTERN ;
545
+ $ matchPatterns = [
546
+ self ::REGEX_WITH_INDEX ,
547
+ self ::REGEX_WITH_PARAM
548
+ ];
539
549
540
- preg_match_all ($ regex , $ inputString , $ matches );
550
+ preg_match_all ($ this -> getMustachePattern ( $ matchPatterns ) , $ inputString , $ matches );
541
551
542
552
$ outputString = $ inputString ;
543
553
@@ -720,7 +730,11 @@ private function resolveParameterization($isParameterized, $replacement, $match,
720
730
*/
721
731
private function matchParameterReferences ($ reference , $ parameters )
722
732
{
723
- preg_match_all ('/{{[\w.]+}}/ ' , $ reference , $ varMatches );
733
+ $ matchPatterns = [
734
+ self ::REGEX_SINGLE_GROUP
735
+ ];
736
+
737
+ preg_match_all ($ this ->getMustachePattern ($ matchPatterns ), $ reference , $ varMatches );
724
738
$ varMatches [0 ] = array_unique ($ varMatches [0 ]);
725
739
$ this ->checkParameterCount ($ varMatches [0 ], $ parameters , $ reference );
726
740
@@ -790,4 +804,15 @@ private function checkParameterCount($matches, $parameters, $reference)
790
804
);
791
805
}
792
806
}
807
+
808
+ /**
809
+ * Returns Mustache regex pattern
810
+ *
811
+ * @param array|null $patterns
812
+ * @return string
813
+ */
814
+ private function getMustachePattern (array $ patterns = []): string
815
+ {
816
+ return '/({{ ' .implode ('}})|({{ ' , $ patterns ).'}})/ ' ;
817
+ }
793
818
}
0 commit comments