-
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 #347 from Yoast/JRF/filename-add-check-for-psr4-co…
…mpliance Files/FileName: add ability to check PSR-4-style file names
- Loading branch information
Showing
30 changed files
with
326 additions
and
21 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
8 changes: 8 additions & 0 deletions
8
Yoast/Tests/Files/FileNameUnitTests/PSR4/Dot_Prefixed_Path.inc
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 @@ | ||
<!-- Annotation must be on line 2 as this sniff throws issues on line 1 and PHPCS ignores errors on annotation lines. --> | ||
phpcs:set Yoast.Files.FileName psr4_paths[] Prefix\\=>./PSR4 | ||
|
||
<?php | ||
|
||
class Dot_Prefixed_Path {} | ||
|
||
// phpcs:set Yoast.Files.FileName psr4_paths[] |
8 changes: 8 additions & 0 deletions
8
Yoast/Tests/Files/FileNameUnitTests/PSR4/Illegal_PSR4_Path.inc
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 @@ | ||
<!-- Annotation must be on line 2 as this sniff throws issues on line 1 and PHPCS ignores errors on annotation lines. --> | ||
phpcs:set Yoast.Files.FileName psr4_paths[] Prefix=>PSR4/../PSR4/../ | ||
|
||
<?php | ||
|
||
class Illegal_PSR4_Path {} | ||
|
||
// phpcs:set Yoast.Files.FileName psr4_paths[] |
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 @@ | ||
<!-- Annotation must be on line 2 as this sniff throws issues on line 1 and PHPCS ignores errors on annotation lines. --> | ||
phpcs:set Yoast.Files.FileName psr4_paths[] PrefixA\=>Other_Path/,PrefixB=>/PSR4/,PrefixC\=>/Deep/Path/Sub/ | ||
|
||
<?php | ||
|
||
class Multiple_Paths {} | ||
|
||
// phpcs:set Yoast.Files.FileName psr4_paths[] |
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 @@ | ||
<!-- Annotation must be on line 2 as this sniff throws issues on line 1 and PHPCS ignores errors on annotation lines. --> | ||
phpcs:set Yoast.Files.FileName psr4_paths[] Prefix=>/PSR4/ | ||
phpcs:set Yoast.Files.FileName excluded_files_strict_check[] PSR4/Not_Excluded.inc | ||
|
||
<?php | ||
|
||
// The excluded files property should only be applied when prefix stripping is supported, which it is not for PSR4 files. | ||
class Yoast_Not_Excluded {} | ||
|
||
// phpcs:set Yoast.Files.FileName psr4_paths[] | ||
// phpcs:set Yoast.Files.FileName excluded_files_strict_check[] |
11 changes: 11 additions & 0 deletions
11
Yoast/Tests/Files/FileNameUnitTests/PSR4/Prefix_Stripped.inc
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 @@ | ||
<!-- Annotation must be on line 2 as this sniff throws issues on line 1 and PHPCS ignores errors on annotation lines. --> | ||
phpcs:set Yoast.Files.FileName psr4_paths[] Prefix=>/PSR4/ | ||
phpcs:set Yoast.Files.FileName oo_prefixes[] wpseo,yoast | ||
|
||
<?php | ||
|
||
// For PSR4 file names, prefixes should *not* be stripped. | ||
class WPSEO_Prefix_Stripped {} | ||
|
||
// phpcs:set Yoast.Files.FileName psr4_paths[] | ||
// phpcs:set Yoast.Files.FileName oo_prefixes[] |
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 @@ | ||
<!-- Annotation must be on line 2 as this sniff throws issues on line 1 and PHPCS ignores errors on annotation lines. --> | ||
phpcs:set Yoast.Files.FileName psr4_paths[] Prefix=>/PSR4/ | ||
|
||
<?php | ||
|
||
class Some_Class {} | ||
|
||
// phpcs:set Yoast.Files.FileName psr4_paths[] |
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 @@ | ||
<!-- Annotation must be on line 2 as this sniff throws issues on line 1 and PHPCS ignores errors on annotation lines. --> | ||
phpcs:set Yoast.Files.FileName psr4_paths[] Prefix\=>PSR4 | ||
|
||
<?php | ||
|
||
enum Some_Enum:int implements ArrayAccess {} | ||
|
||
// phpcs:set Yoast.Files.FileName psr4_paths[] |
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 @@ | ||
<!-- Annotation must be on line 2 as this sniff throws issues on line 1 and PHPCS ignores errors on annotation lines. --> | ||
phpcs:set Yoast.Files.FileName psr4_paths[] Prefix\\=>/PSR4 | ||
|
||
<?php | ||
|
||
interface Some_Interface {} | ||
|
||
// phpcs:set Yoast.Files.FileName psr4_paths[] |
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 @@ | ||
<!-- Annotation must be on line 2 as this sniff throws issues on line 1 and PHPCS ignores errors on annotation lines. --> | ||
phpcs:set Yoast.Files.FileName psr4_paths[] Prefix=>PSR4/ | ||
|
||
<?php | ||
|
||
TraiT Some_Trait {} | ||
|
||
// phpcs:set Yoast.Files.FileName psr4_paths[] |
11 changes: 11 additions & 0 deletions
11
Yoast/Tests/Files/FileNameUnitTests/PSR4/WPSEO_Prefixed.inc
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 @@ | ||
<!-- Annotation must be on line 2 as this sniff throws issues on line 1 and PHPCS ignores errors on annotation lines. --> | ||
phpcs:set Yoast.Files.FileName psr4_paths[] Prefix\\=>/PSR4/ | ||
phpcs:set Yoast.Files.FileName oo_prefixes[] wpseo,yoast | ||
|
||
<?php | ||
|
||
// For PSR4 file names, prefixes should *not* be stripped. | ||
class WPSEO_Prefixed {} | ||
|
||
// phpcs:set Yoast.Files.FileName psr4_paths[] | ||
// phpcs:set Yoast.Files.FileName oo_prefixes[] |
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 @@ | ||
<!-- Annotation must be on line 2 as this sniff throws issues on line 1 and PHPCS ignores errors on annotation lines. --> | ||
phpcs:set Yoast.Files.FileName psr4_paths[] Prefix=>/PSR4/ | ||
|
||
<?php | ||
|
||
class wrong_case_too {} | ||
|
||
// phpcs:set Yoast.Files.FileName psr4_paths[] |
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 @@ | ||
<!-- Annotation must be on line 2 as this sniff throws issues on line 1 and PHPCS ignores errors on annotation lines. --> | ||
phpcs:set Yoast.Files.FileName psr4_paths[] Prefix\\=>/PSR4/ | ||
|
||
<?php | ||
|
||
class Some_Class {} | ||
|
||
// phpcs:set Yoast.Files.FileName psr4_paths[] |
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 @@ | ||
<!-- Annotation must be on line 2 as this sniff throws issues on line 1 and PHPCS ignores errors on annotation lines. --> | ||
phpcs:set Yoast.Files.FileName psr4_paths[] Prefix=>PSR4 | ||
|
||
<?php | ||
|
||
enum Some_Enum:int implements ArrayAccess {} | ||
|
||
// phpcs:set Yoast.Files.FileName psr4_paths[] |
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 @@ | ||
<!-- Annotation must be on line 2 as this sniff throws issues on line 1 and PHPCS ignores errors on annotation lines. --> | ||
phpcs:set Yoast.Files.FileName psr4_paths[] Prefix=>/PSR4 | ||
|
||
<?php | ||
|
||
interface Some_Interface {} | ||
|
||
// phpcs:set Yoast.Files.FileName psr4_paths[] |
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 @@ | ||
<!-- Annotation must be on line 2 as this sniff throws issues on line 1 and PHPCS ignores errors on annotation lines. --> | ||
phpcs:set Yoast.Files.FileName psr4_paths[] Prefix=>PSR4/ | ||
|
||
<?php | ||
|
||
TraiT Some_Trait {} | ||
|
||
// phpcs:set Yoast.Files.FileName psr4_paths[] |
11 changes: 11 additions & 0 deletions
11
Yoast/Tests/Files/FileNameUnitTests/PSR4/Yoast_Prefixed.inc
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 @@ | ||
<!-- Annotation must be on line 2 as this sniff throws issues on line 1 and PHPCS ignores errors on annotation lines. --> | ||
phpcs:set Yoast.Files.FileName psr4_paths[] PrefixA=>/src/,PrefixB=>/PSR4/ | ||
phpcs:set Yoast.Files.FileName oo_prefixes[] wpseo,yoast | ||
|
||
<?php | ||
|
||
// For PSR4 file names, prefixes should *not* be stripped. | ||
class Yoast_Prefixed {} | ||
|
||
// phpcs:set Yoast.Files.FileName psr4_paths[] | ||
// phpcs:set Yoast.Files.FileName oo_prefixes[] |
8 changes: 8 additions & 0 deletions
8
Yoast/Tests/Files/FileNameUnitTests/PSR4/illegal-psr4-path.inc
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 @@ | ||
<!-- Annotation must be on line 2 as this sniff throws issues on line 1 and PHPCS ignores errors on annotation lines. --> | ||
phpcs:set Yoast.Files.FileName psr4_paths[] Prefix\\=>PSR4/../PSR4/../ | ||
|
||
<?php | ||
|
||
class Illegal_PSR4_Path {} | ||
|
||
// phpcs:set Yoast.Files.FileName psr4_paths[] |
11 changes: 11 additions & 0 deletions
11
Yoast/Tests/Files/FileNameUnitTests/PSR4/missing-suffix.inc
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 @@ | ||
<!-- Annotation must be on line 2 as this sniff throws issues on line 1 and PHPCS ignores errors on annotation lines. --> | ||
phpcs:set Yoast.Files.FileName psr4_paths[] Prefix\\=>/PSR4/ | ||
|
||
<?php | ||
|
||
// Files without an OO structure, should follow the normal "lowercase hyphenated" + "-functions" suffix file name rules. | ||
function Foo() {} | ||
|
||
function Bar() {} | ||
|
||
// phpcs:set Yoast.Files.FileName psr4_paths[] |
11 changes: 11 additions & 0 deletions
11
Yoast/Tests/Files/FileNameUnitTests/PSR4/no-oo-functions.inc
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 @@ | ||
<!-- Annotation must be on line 2 as this sniff throws issues on line 1 and PHPCS ignores errors on annotation lines. --> | ||
phpcs:set Yoast.Files.FileName psr4_paths[] Prefix=>/PSR4/ | ||
|
||
<?php | ||
|
||
// Files without an OO structure, should follow the normal "lowercase hyphenated" + "-functions" suffix file name rules. | ||
function Foo() {} | ||
|
||
function Bar() {} | ||
|
||
// phpcs:set Yoast.Files.FileName psr4_paths[] |
Oops, something went wrong.