Giter Site home page Giter Site logo

cdn77 / coding-standard Goto Github PK

View Code? Open in Web Editor NEW
6.0 6.0 4.0 301 KB

Cdn77 Coding Standard, defensive and strict, based on Doctrine standard https://github.com/doctrine/coding-standard

PHP 97.35% Makefile 2.65%
php php-codesniffer coding-standard

coding-standard's Introduction

coding-standard's People

Contributors

baci266 avatar davidxkurka avatar grongor avatar majkl578 avatar renovate[bot] avatar simpod avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

coding-standard's Issues

It's not possible to configure any sniff from your rule set

Hello, I'm trying to configure ClassStructure sniff, but the property is not propagated to sniff instance. My xml definition is:

	<rule ref="Cdn77.Classes.ClassStructure">
        <properties>
            <property name="requiredOrder" type="array" value="
                0=>0,
                10=>10,
                20=>20,
                30=>20,
                40=>20,
                50=>50,
                60=>50,
                70=>50,
                80=>80,
                90=>80,
                100=>80,
                110=>110,
                120=>110,
                130=>110,
                140=>140,
                150=>150,
                160=>160,
                170=>170,
                180=>180,
                190=>180,
                200=>180
            "/>
        </properties>
    </rule>

IMHO The problem is the ruleset name is not the same as src namespace (Cdn77 vs Cdn77CodingStandard). When I try to normalize it, everything works correctly.

I can send you PR, but I don't know if you prefer Cdn77 or Cdn77CodingStandard. Both variants lead to bc break :(

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

composer
composer.json
  • php ^8.2
  • doctrine/coding-standard ^12.0
  • slevomat/coding-standard ^8.15
  • squizlabs/php_codesniffer ^3.9
  • phpstan/extension-installer ^1.2
  • phpstan/phpstan ^1.0.0
  • phpstan/phpstan-phpunit ^1.0.0
  • phpstan/phpstan-strict-rules ^1.0.0
  • phpunit/phpunit ^11.0
github-actions
.github/workflows/ci.yml
  • actions/checkout v4
  • shivammathur/setup-php v2
  • ramsey/composer-install v1
  • actions/checkout v4
  • shivammathur/setup-php v2
  • ramsey/composer-install v1
  • actions/checkout v4
  • shivammathur/setup-php v2
  • ramsey/composer-install v1
  • actions/upload-artifact v4
  • actions/checkout v4
  • actions/download-artifact v4
  • codecov/codecov-action v4
  • ubuntu 22.04
  • ubuntu 22.04
  • ubuntu 22.04

  • Check this box to trigger a request for Renovate to run again on this repository

ClassStructure Ordering bug

Hello,
while running Cdn77CodingStandard.Classes.ClassStructure on my code I found a bug in ordering of functions inside class with higher amount of functions.

For example, when I run the sniff on this piece of code

<?php

declare(strict_types = 1);

class ClassStructureBug
{
    protected function protectedFunction()
    {
    }

    protected function protectedFunction1()
    {
    }

    protected function protectedFunction2()
    {
    }

    protected function protectedFunction3()
    {
    }

    protected function protectedFunction4()
    {
    }

    protected function protectedFunction5()
    {
    }

    protected function protectedFunction6()
    {
    }

    protected function protectedFunction7()
    {
    }

    public function publicFunction()
    {
    }

    public function publicFunction1()
    {
    }

    public function publicFunction2()
    {
    }

    public function publicFunction3()
    {
    }

    public function publicFunction4()
    {
    }
}

It will reorder the class to this state:

<?php

declare(strict_types = 1);

class ClassStructureBug
{
    public function publicFunction()
    {
    }

    public function publicFunction1()
    {
    }

    public function publicFunction2()
    {
    }

    public function publicFunction3()
    {
    }

    protected function protectedFunction()
    {
    }

    protected function protectedFunction1()
    {
    }

    protected function protectedFunction2()
    {
    }

    protected function protectedFunction3()
    {
    }

    protected function protectedFunction4()
    {
    }

    protected function protectedFunction5()
    {
    }

    public function publicFunction4()
    {
    }

    protected function protectedFunction6()
    {
    }

    protected function protectedFunction7()
    {
    }
}

I'm using default $requiredOrder.

Fix IncorrectLinesCountBeforeControlStructure edge cases

In these edge cases, sniff Cdn77CodingStandard.ControlStructures.JumpStatementsSpacing.IncorrectLinesCountBeforeControlStructure produces incorrect results:

Yield as a function argument

run(
    yield 1
);

run(yield 1);

Current behaviour

run(

    yield 1
);

Desired behaviour

Do not change

Yield in while

probably same case as previous?

while (yield 1) {
}

Current behaviour

while (
yield 1) {
}

Desired behaviour

Do not change

LineTooLong conflicts with ArrayDeclaration.MultiLineNotAllowed

This violates Cdn77CodingStandard.Files.LineLength.LineTooLong:

[
     'errors' => ["Command cannot be used over the API at this time. To see ASCII output, set format='te"],
],

I cannot do

[
     'errors' => [
        "Command cannot be used over the API at this time. To see ASCII output, set format='te"
    ],
],

That violates Squiz.Arrays.ArrayDeclaration.MultiLineNotAllowed. What's the recommended solution?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.