Skip to content

Commit 1f69087

Browse files
authored
Merge pull request #12 from peckadesign/oneperfile
V jednom PHP souboru může být jedna třída, interface nebo traita
2 parents 477b708 + c1ec67f commit 1f69087

File tree

3 files changed

+27
-9
lines changed

3 files changed

+27
-9
lines changed

src/PeckaCodingStandard/ruleset-strict.xml

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
4+
class PeckaCodingStandardStrict_Sniffs_Files_OneClassInterfaceTraitPerFileSniff implements PHP_CodeSniffer_Sniff
5+
{
6+
7+
public function register()
8+
{
9+
return [T_CLASS, T_INTERFACE, T_TRAIT];
10+
}
11+
12+
13+
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
14+
{
15+
$nextInterface = $phpcsFile->findNext($this->register(), ($stackPtr + 1));
16+
if ($nextInterface !== FALSE) {
17+
$error = 'Only one class, interface or trait is allowed in a file';
18+
$phpcsFile->addError($error, $nextInterface, 'MultipleFound');
19+
}
20+
}
21+
22+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" ?>
2+
<ruleset name="PeckaDesign">
3+
4+
5+
</ruleset>

0 commit comments

Comments
 (0)