Skip to content

Coding standard does not specify negation formatting #48

Open

Description

@mhujer

Currently the negation formatting is not explicitly specified in the standard.

It can be written either:

  • with no spaces if (!is_array($foo))
  • with space after if (! is_array($foo))
  • with spaces around if ( ! is_array($foo))

In the Scalar types chapter there is a code example which includes negation formatted without spaces around:

<?php

if (!is_int($foo)) {
	return (int) $foo;
}

So it would be nice to have it explicitly stated in the coding standard. Maybe eventually also checked automatically (but PHP_CodeSniffer currently offers only SpaceAfterNotSniff).

Activity

  1. VasekPurchart commented on Aug 27, 2018

    @VasekPurchart
    Member

    Thanks for the suggestion, I will add it in next major version (to not break versioning) in the format stated in the code example.

  2. mhujer commented on Dec 21, 2018

    @mhujer
    ContributorAuthor

    It is now possible to check this with PHPCS>=3.4 squizlabs/PHP_CodeSniffer#2233

  3. VasekPurchart commented on Dec 21, 2018

    @VasekPurchart
    Member

    Yes, I noticed, already have it in my notes :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions