djoos / Symfony-coding-standard

Development repository for the Symfony coding standard
MIT License
401 stars 102 forks source link

[Current Sniffs] Documentation #69

Closed wickedOne closed 7 years ago

wickedOne commented 7 years ago

this issue lists all sniffs currently implemented in this repository as described in the documentation section of the symfony coding standard.

this issue can be marked as resolved once the example class at the bottom triggers all mentioned errors when checked with this standard (be sure to remove all comment lines before checking and ignore the multiple classes per file error).

the requirement of a license is debatable as it's specific to contributing to the symfony code base. we might want to consider implementing this sniff and make it a type warning in the ruleset.xml so it can easily be ignored for builds by a phpcs --config-set show_warnings 0 ?

Documentation

<?php

// the license block has to be present at the top of every PHP file, before the namespace
namespace Symfony;

// Add PHPDoc blocks for all classes, methods, and functions;
class Foo
{
    /**
     * Group annotations together so that annotations of the same type immediately follow each other, and annotations of a different type are separated by a single blank line
     * @Baz("qux")
     * @Corge("grault")
     * @Baz("qux")
     */
    private $bar;

    /**
     * Omit the @return tag if the method does not return anything
     *
     * @return void
     */
    public function __construct($bar)
    {
        $this->bar = $bar;
    }

    // Add PHPDoc blocks for all classes, methods, and functions;
    protected function bar()
    {
    }

    // Add PHPDoc blocks for all classes, methods, and functions;
    private function baz()
    {
    }
}

/**
 * @package baz
 */
class Bar
{
}
wickedOne commented 7 years ago

this one is completed, just a couple to go and we're fully compatible!