Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8880979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:15:23+00:00 2026-06-14T20:15:23+00:00

I’d like to make a small change to the PEAR standard for our phpcs

  • 0

I’d like to make a small change to the PEAR standard for our phpcs validation. At the moment PEAR requires you to write else statements like this:

} else {

We’d like to write them like this:

}
else {

How can I go about making this change?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:15:24+00:00Added an answer on June 14, 2026 at 8:15 pm

    The only way to do this is to write your own coding standard using a ruleset.xml file. It needs to import the whole PEAR coding standard but exclude the specific sniff performing this check. This bit can be done with the single XML file.

    But there are no built-in sniffs that enforce the type of else syntax you are looking for. So to enforce that, you’ll need to write a custom sniff, which is more complicated as you also have to store it somewhere.

    If you want to start by trying the simple custom coding standard, create a file called ruleset.xml and make this the contents:

    <?xml version="1.0"?>
    <ruleset name="MyStandard">
     <description>My custom coding standard.</description>
     <rule ref="PEAR">
      <exclude name="PEAR.ControlStructures.ControlSignature"/>
     </rule>
    </ruleset>
    

    Then run PHP_CodeSniffer like this:

    phpcs --standard=/path/to/ruleset.xml /path/to/code
    

    This will check your code against the PEAR coding standard but exclude the specific checks for control structures. If this is all you need, you can stop there. If you have a team of people you want running this custom standard, just give them the file and they can use it as well.

    There is more info about the ruleset.xml format here: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml

    If you want to go ahead and write a custom sniff, it is best to start with the basic tutorial: http://pear.php.net/manual/en/package.php.php-codesniffer.coding-standard-tutorial.php

    This will explain what a coding standard is. Then, you’ll want to create your own sniff, which is just a copy of the PEAR one with slight changes for how you do control structured. The PEAR sniff is here: https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/PEAR/Sniffs/ControlStructures/ControlSignatureSniff.php

    Without testing, I assume you’d want to change } else {EOL', to }EOLelse {EOL', and see if that works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a small JavaScript validation script that validates inputs based on Regex. I
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I would like to run a str_replace or preg_replace which looks for certain words
I am trying to render a haml file in a javascript response like so:
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.