php - Sniffer Snippet to allow brackets on new line -


is there codesniffer snippet allows/forces { } put on newlines every function/method?

basically, forcing this:

if (true) {      // code logic } else {     // code logic } 

and

public function test() {      // code logic } 

yes, there ready one. it's called openingfunctionbracebsdallmansniff , can find under /path/to/codesniffer/standards/generic/sniffs/functions. that's functions' declarations.

for control structures can take /path/to/standards/squiz/sniffs/controlstructures/controlsignaturesniff.php , tweak pattern array

protected function getpatterns() {     return array(             'try {eol...} catch (...) {eol',             'do {eol...} while (...);eol',             'while (...) {eol',             'for (...) {eol',             'if (...) {eol',             'foreach (...) {eol',             '} else if (...) {eol',             '} elseif (...) {eol',             '} else {eol',            );  }//end getpatterns() 

to, i.e.

protected function getpatterns() {     return array(             'try {eol...} catch (...) {eol',             'do {eol...} while (...);eol',             'while (...) {eol',             'for (...) {eol',             'if (...)eol{',              // that's need             'foreach (...) {eol',             '} else if (...) {eol',             '} elseif (...) {eol',             '} elseeol{',               // ,            );  }//end getpatterns() 

if need apply same rule other control structure, can go same way, changing patterns in array.

update: 1 cleaner solution be, of course, write own class extends above , overrides the getpatterns() method.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -