-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #333 from Yoast/JRF/yoastcs-filecomment-various-im…
…provements Commenting/FileComment: allow for namespaced procedural files and other improvements
- Loading branch information
Showing
31 changed files
with
346 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<!-- Edge case test: empty file, fall through to parent sniff and flag for missing file comment. | ||
<?php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace\functionCall(); | ||
|
||
/** | ||
* Class docblock. No namespace (above is operator, not declaration), file comment is needed, but missing. | ||
*/ | ||
class Testing {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
/** | ||
* File Comment for a file without a namespace. | ||
* | ||
* For the purposes of the unit test, the docblock here needs to comply with the | ||
* complete Squiz file comment rules as the ruleset is not taken into account | ||
* when unit testing sniffs. | ||
* | ||
* @package Some\Package | ||
* @subpackage Something\Else | ||
* @author Squiz Pty Ltd <[email protected]> | ||
* @copyright 2018 Squiz Pty Ltd (ABN 77 084 670 600) | ||
*/ | ||
|
||
/** | ||
* Interface docblock. | ||
*/ | ||
interface Testing { | ||
public function test(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
/** | ||
* Interface docblock. No namespace, file comment is needed, but missing. | ||
*/ | ||
interface Testing { | ||
public function test(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Yoast\Plugin\Sub; | ||
|
||
/** | ||
* Interface docblock. A file docblock is not needed in a namespaced file containing an OO structure. | ||
*/ | ||
interface Testing { | ||
public function test(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
/** | ||
* File Comment for a file WITH a namespace and containing an OO structure. This should be flagged as unnecessary. | ||
* | ||
* @package Some\Package | ||
*/ | ||
|
||
namespace Yoast\Plugin\Sub; | ||
|
||
/** | ||
* Interface docblock. | ||
*/ | ||
interface Testing { | ||
public function test(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
/** | ||
* File Comment for a file without a namespace. | ||
* | ||
* For the purposes of the unit test, the docblock here needs to comply with the | ||
* complete Squiz file comment rules as the ruleset is not taken into account | ||
* when unit testing sniffs. | ||
* | ||
* @package Some\Package | ||
* @subpackage Something\Else | ||
* @author Squiz Pty Ltd <[email protected]> | ||
* @copyright 2018 Squiz Pty Ltd (ABN 77 084 670 600) | ||
*/ | ||
|
||
/** | ||
* Trait docblock. | ||
*/ | ||
trait Testing { | ||
public function test() { | ||
echo namespace\SomeClass::$static_property; // This is not a namespace declaration, but use of the namespace operator. | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
|
||
/** | ||
* Trait docblock. No namespace, file comment is needed, but missing. | ||
*/ | ||
trait Testing {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Yoast\Plugin\Sub; | ||
|
||
/** | ||
* Trait docblock. A file docblock is not needed in a namespaced file containing an OO structure. | ||
*/ | ||
trait Testing {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
/** | ||
* File Comment for a file WITH a namespace and containing an OO structure. This should be flagged as unnecessary. | ||
* | ||
* @package Some\Package | ||
*/ | ||
|
||
namespace Yoast\Plugin\Sub; | ||
|
||
/** | ||
* Trait docblock. | ||
*/ | ||
trait Testing {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
/** | ||
* File Comment for a file without a namespace. | ||
* | ||
* For the purposes of the unit test, the docblock here needs to comply with the | ||
* complete Squiz file comment rules as the ruleset is not taken into account | ||
* when unit testing sniffs. | ||
* | ||
* @package Some\Package | ||
* @subpackage Something\Else | ||
* @author Squiz Pty Ltd <[email protected]> | ||
* @copyright 2018 Squiz Pty Ltd (ABN 77 084 670 600) | ||
*/ | ||
|
||
/** | ||
* Enum docblock. | ||
*/ | ||
enum Testing { | ||
public function test() { | ||
echo namespace\SomeClass::$static_property; // This is not a namespace declaration, but use of the namespace operator. | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
|
||
/** | ||
* Enum docblock. No namespace, file comment is needed, but missing. | ||
*/ | ||
enum Testing {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Yoast\Plugin\Sub; | ||
|
||
/** | ||
* Enum docblock. A file docblock is not needed in a namespaced file containing an OO structure. | ||
*/ | ||
enum Testing {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
/** | ||
* File Comment for a file WITH a namespace and containing an OO structure. This should be flagged as unnecessary. | ||
* | ||
* @package Some\Package | ||
*/ | ||
|
||
namespace Yoast\Plugin\Sub; | ||
|
||
/** | ||
* Enum docblock. | ||
*/ | ||
enum Testing {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
/** | ||
* File Comment for a file without a namespace and without OO structure. | ||
* | ||
* For the purposes of the unit test, the docblock here needs to comply with the | ||
* complete Squiz file comment rules as the ruleset is not taken into account | ||
* when unit testing sniffs. | ||
* | ||
* @package Some\Package | ||
* @subpackage Something\Else | ||
* @author Squiz Pty Ltd <[email protected]> | ||
* @copyright 2018 Squiz Pty Ltd (ABN 77 084 670 600) | ||
*/ | ||
|
||
do_something(); | ||
|
||
/** | ||
* Function docblock. | ||
*/ | ||
function test() { | ||
echo namespace\SomeClass::$static_property; // This is not a namespace declaration, but use of the namespace operator. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
/** | ||
* Function docblock. No namespace, file comment is needed, but missing. | ||
*/ | ||
function test() {} | ||
|
||
do_something(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Yoast\Plugin\Sub; | ||
|
||
do_something(); | ||
|
||
/** | ||
* Function docblock. A file docblock is not needed in a namespaced file, but also not forbidden if the file doesn't contain an OO structure. | ||
*/ | ||
function testing() {} |
Oops, something went wrong.