File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
src/org/cakephp/netbeans/editor Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -133,10 +133,7 @@ public void visit(MethodInvocation node) {
133133 if (e instanceof Scalar ) {
134134 Scalar s = (Scalar )e ;
135135 if (s .getScalarType () == Scalar .Type .STRING ) {
136- viewVarName = s .getStringValue ();
137- if (!viewVarName .isEmpty ()) {
138- viewVarName = viewVarName .substring (1 , viewVarName .length () - 1 ).trim ();
139- }
136+ viewVarName = prepareViewVar (s .getStringValue ());
140137 }
141138 }
142139
@@ -145,9 +142,19 @@ public void visit(MethodInvocation node) {
145142 && CakePhpUtils .isControllerName (className )
146143 && !viewVarName .isEmpty ()) {
147144 synchronized (fields ) {
148- fields .add (new PhpVariable ("$" + viewVarName , new PhpClass ("HtmlHelper " , "HtmlHelper " )));
145+ fields .add (new PhpVariable ("$" + viewVarName , new PhpClass ("stdClass " , "stdClass " )));
149146 }
150147 }
151148 }
149+
150+ private String prepareViewVar (String viewVarName ) {
151+ if (!viewVarName .isEmpty ()) {
152+ viewVarName = viewVarName .substring (1 , viewVarName .length () - 1 ).trim ();
153+ if (!viewVarName .matches ("[A-Za-z][A-Za-z0-9]*" )) {
154+ viewVarName = "" ;
155+ }
156+ }
157+ return viewVarName ;
158+ }
152159 }
153160}
You can’t perform that action at this time.
0 commit comments