Skip to content

Commit

Permalink
Rewrite issue OggettoWeb#7
Browse files Browse the repository at this point in the history
  • Loading branch information
rut4 committed Jun 10, 2014
1 parent d9f616a commit 35cdf3f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 24 deletions.
21 changes: 2 additions & 19 deletions Oggetto/Sniffs/Files/OnlyValidCharactersInNameSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,8 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
{
$fileName = $phpcsFile->getFileName();

//get file name without extension '.php'
$arrCatalogs = explode('\\', $fileName);
$fileNameSubstrs = explode('.', end($arrCatalogs));
$fileName = join('.', array_slice( $fileNameSubstrs, 0, count($fileNameSubstrs) - 1 ) );

//file name is gotten

$lowerLetters = range('a', 'z');
$upperLetters = range('A', 'Z');
$nums = range('0', '9');

for ($i = 0; $i < strlen($fileName); $i++) {
$char = $fileName[$i];

if (!(in_array(ord($char) - ord('0'), $nums) || in_array($char, $lowerLetters) ||
in_array($char, $upperLetters) || $char == '-' || $char == '_')) {
$phpcsFile->addError("Character '%s' should not be used in file name",
$stackPtr, 'Found', $fileName[$i]);
}
if (!preg_match("/^(\w|\/|\-)+\.php$/", $fileName)) {
$phpcsFile->addError("Invalid file name", $stackPtr, 'Error');
}
}
}
5 changes: 0 additions & 5 deletions Oggetto/ruleset.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
Expand Down Expand Up @@ -58,8 +57,4 @@
<rule ref="Oggetto.Commenting.FunctionComment"/>
<rule ref="Oggetto.Strings.ConcatenationSpacing"/>
<rule ref="Oggetto.Files.OnlyValidCharactersInName"/>

<rule ref="Oggetto.Functions.FunctionWhiteSpace"/>
<rule ref="Oggetto.Arrays.ArrayNegativeIndex"/>
<rule ref="Oggetto.File.OnlyEnglish"/>
</ruleset>

0 comments on commit 35cdf3f

Please sign in to comment.