@@ -23,8 +23,7 @@ discard block |
||
| 23 | 23 | /** |
| 24 | 24 | * Model for handling requests dealing with the manga list |
| 25 | 25 | */ |
| 26 | -class Manga extends API |
|
| 27 | -{ |
|
| 26 | +class Manga extends API { |
|
| 28 | 27 | |
| 29 | 28 | const READING = 'Reading'; |
| 30 | 29 | const PLAN_TO_READ = 'Plan to Read'; |
@@ -160,12 +159,14 @@ discard block |
||
| 160 | 159 | self::COMPLETED => [], |
| 161 | 160 | ]; |
| 162 | 161 | |
| 163 | - foreach ($data as &$entry) { |
|
| 162 | + foreach ($data as &$entry) |
|
| 163 | + { |
|
| 164 | 164 | $key = $this->status_map[$entry['reading_status']]; |
| 165 | 165 | $output[$key][] = $entry; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - foreach ($output as &$val) { |
|
| 168 | + foreach ($output as &$val) |
|
| 169 | + { |
|
| 169 | 170 | $this->sortByName($val, 'manga'); |
| 170 | 171 | } |
| 171 | 172 | |
@@ -53,7 +53,8 @@ |
||
| 53 | 53 | * Anime constructor. |
| 54 | 54 | * @param ContainerInterface $container |
| 55 | 55 | */ |
| 56 | - public function __construct(ContainerInterface $container) { |
|
| 56 | + public function __construct(ContainerInterface $container) |
|
| 57 | + { |
|
| 57 | 58 | parent::__construct($container); |
| 58 | 59 | |
| 59 | 60 | $config = $container->get('config'); |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | /** |
| 20 | 20 | * Base trait for api interaction |
| 21 | 21 | */ |
| 22 | -trait GuzzleTrait {
|
|
| 22 | +trait GuzzleTrait { |
|
| 23 | 23 | /** |
| 24 | 24 | * The Guzzle http client object |
| 25 | 25 | * @var object |
@@ -289,7 +289,8 @@ |
||
| 289 | 289 | |
| 290 | 290 | $params = []; |
| 291 | 291 | |
| 292 | - switch($failure->failedRule) { |
|
| 292 | + switch($failure->failedRule) |
|
| 293 | + { |
|
| 293 | 294 | case 'Aura\Router\Rule\Allows': |
| 294 | 295 | $params = [ |
| 295 | 296 | 'http_code' => 405, |
@@ -43,8 +43,7 @@ discard block |
||
| 43 | 43 | use PHP_CodeSniffer\Files\File; |
| 44 | 44 | use PHP_CodeSniffer\Util\Common; |
| 45 | 45 | |
| 46 | -class ClosingLocationCommentSniff extends AbstractClosingCommentSniff |
|
| 47 | -{ |
|
| 46 | +class ClosingLocationCommentSniff extends AbstractClosingCommentSniff { |
|
| 48 | 47 | public $applicationRoot = '/application/'; |
| 49 | 48 | |
| 50 | 49 | /** |
@@ -73,8 +72,10 @@ discard block |
||
| 73 | 72 | public function process(File $phpcsFile, $stackPtr) |
| 74 | 73 | { |
| 75 | 74 | // We are only interested if this is the first open tag. |
| 76 | - if ($stackPtr !== 0) { |
|
| 77 | - if ($phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)) !== false) { |
|
| 75 | + if ($stackPtr !== 0) |
|
| 76 | + { |
|
| 77 | + if ($phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)) !== false) |
|
| 78 | + { |
|
| 78 | 79 | return; |
| 79 | 80 | } |
| 80 | 81 | } |
@@ -84,7 +85,8 @@ discard block |
||
| 84 | 85 | // removes the application root from the beginning of the file path |
| 85 | 86 | $locationPath = self::_getLocationPath($filePath, $this->_getAppRoot()); |
| 86 | 87 | // add an error, if application root doesn't exist in current file path |
| 87 | - if (false === $locationPath) { |
|
| 88 | + if (false === $locationPath) |
|
| 89 | + { |
|
| 88 | 90 | $error = 'Unable to find "' . $this->_getAppRoot() . '" in file path "' . $filePath . '". Please set your project\'s application root.'; |
| 89 | 91 | $phpcsFile->addError($error, count($tokens) - 1); |
| 90 | 92 | return; |
@@ -101,21 +103,28 @@ discard block |
||
| 101 | 103 | ) { |
| 102 | 104 | $token = $tokens[$currentToken]; |
| 103 | 105 | $tokenCode = $token['code']; |
| 104 | - if (T_COMMENT === $tokenCode) { |
|
| 106 | + if (T_COMMENT === $tokenCode) |
|
| 107 | + { |
|
| 105 | 108 | $commentString = self::_getCommentContent($token['content']); |
| 106 | - if (0 === strcmp($commentString, $commentTemplate)) { |
|
| 109 | + if (0 === strcmp($commentString, $commentTemplate)) |
|
| 110 | + { |
|
| 107 | 111 | $hasClosingLocationComment = true; |
| 108 | 112 | } |
| 109 | - } else if (T_WHITESPACE === $tokenCode) { |
|
| 113 | + } |
|
| 114 | + else if (T_WHITESPACE === $tokenCode) |
|
| 115 | + { |
|
| 110 | 116 | // Whitespaces are allowed between the closing file comment, |
| 111 | 117 | //other comments and end of file |
| 112 | - } else { |
|
| 118 | + } |
|
| 119 | + else |
|
| 120 | + { |
|
| 113 | 121 | $isNotAWhitespaceOrAComment = true; |
| 114 | 122 | } |
| 115 | 123 | $currentToken--; |
| 116 | 124 | } |
| 117 | 125 | |
| 118 | - if ( ! $hasClosingLocationComment) { |
|
| 126 | + if ( ! $hasClosingLocationComment) |
|
| 127 | + { |
|
| 119 | 128 | $error = 'No comment block marks the end of file instead of the closing PHP tag. Please add a comment block containing only "' . $commentTemplate . '".'; |
| 120 | 129 | $phpcsFile->addError($error, $currentToken); |
| 121 | 130 | } |
@@ -142,14 +151,17 @@ discard block |
||
| 142 | 151 | // removes the path to application root |
| 143 | 152 | // from the beginning of the file path |
| 144 | 153 | $appRootAt = strpos($filePath, $appRoot); |
| 145 | - if (false === $appRootAt) { |
|
| 154 | + if (false === $appRootAt) |
|
| 155 | + { |
|
| 146 | 156 | return false; |
| 147 | 157 | } |
| 148 | 158 | $localPath = substr($filePath, $appRootAt + strlen($appRoot)); |
| 149 | 159 | // ensures the location path to be a relative path starting with "./". |
| 150 | - if ( ! self::_stringStartsWith($localPath, './')) { |
|
| 160 | + if ( ! self::_stringStartsWith($localPath, './')) |
|
| 161 | + { |
|
| 151 | 162 | $localPath = './' . $localPath; |
| 152 | - } else if ( ! self::_stringStartsWith($localPath, '.') |
|
| 163 | + } |
|
| 164 | + else if ( ! self::_stringStartsWith($localPath, '.') |
|
| 153 | 165 | && self::_stringStartsWith($localPath, '/') |
| 154 | 166 | ) { |
| 155 | 167 | $localPath = '.' . $localPath; |
@@ -172,7 +184,8 @@ discard block |
||
| 172 | 184 | private function _getAppRoot() |
| 173 | 185 | { |
| 174 | 186 | $appRoot = Common::getConfigData('ci_application_root'); |
| 175 | - if (null === $appRoot) { |
|
| 187 | + if (null === $appRoot) |
|
| 188 | + { |
|
| 176 | 189 | $appRoot = $this->applicationRoot; |
| 177 | 190 | } |
| 178 | 191 | return $appRoot; |
@@ -32,8 +32,7 @@ discard block |
||
| 32 | 32 | use PHP_CodeSniffer\Sniffs\Sniff; |
| 33 | 33 | use PHP_CodeSniffer\Files\File; |
| 34 | 34 | |
| 35 | -class AbstractClosingCommentSniff implements Sniff |
|
| 36 | -{ |
|
| 35 | +class AbstractClosingCommentSniff implements Sniff { |
|
| 37 | 36 | /** |
| 38 | 37 | * As an abstract class, this sniff is not associated to any token. |
| 39 | 38 | */ |
@@ -66,11 +65,16 @@ discard block |
||
| 66 | 65 | */ |
| 67 | 66 | protected static function _getCommentContent ($comment) |
| 68 | 67 | { |
| 69 | - if (self::_stringStartsWith($comment, '#')) { |
|
| 68 | + if (self::_stringStartsWith($comment, '#')) |
|
| 69 | + { |
|
| 70 | 70 | $comment = substr($comment, 1); |
| 71 | - } else if (self::_stringStartsWith($comment, '//')) { |
|
| 71 | + } |
|
| 72 | + else if (self::_stringStartsWith($comment, '//')) |
|
| 73 | + { |
|
| 72 | 74 | $comment = substr($comment, 2); |
| 73 | - } else if (self::_stringStartsWith($comment, '/*')) { |
|
| 75 | + } |
|
| 76 | + else if (self::_stringStartsWith($comment, '/*')) |
|
| 77 | + { |
|
| 74 | 78 | $comment = substr($comment, 2, strlen($comment) - 2 - 2); |
| 75 | 79 | } |
| 76 | 80 | $comment = trim($comment); |
@@ -91,9 +95,11 @@ discard block |
||
| 91 | 95 | protected static function _stringStartsWith ($haystack, $needle) |
| 92 | 96 | { |
| 93 | 97 | $startsWith = false; |
| 94 | - if (strlen($needle) <= strlen($haystack)) { |
|
| 98 | + if (strlen($needle) <= strlen($haystack)) |
|
| 99 | + { |
|
| 95 | 100 | $haystackBeginning = substr($haystack, 0, strlen($needle)); |
| 96 | - if (0 === strcmp($haystackBeginning, $needle)) { |
|
| 101 | + if (0 === strcmp($haystackBeginning, $needle)) |
|
| 102 | + { |
|
| 97 | 103 | $startsWith = true; |
| 98 | 104 | } |
| 99 | 105 | } |
@@ -36,8 +36,7 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | use PHP_CodeSniffer\Files\File; |
| 38 | 38 | |
| 39 | -class ClosingFileCommentSniff extends AbstractClosingCommentSniff |
|
| 40 | -{ |
|
| 39 | +class ClosingFileCommentSniff extends AbstractClosingCommentSniff { |
|
| 41 | 40 | |
| 42 | 41 | /** |
| 43 | 42 | * Returns an array of tokens this test wants to listen for. |
@@ -65,8 +64,10 @@ discard block |
||
| 65 | 64 | public function process(File $phpcsFile, $stackPtr) |
| 66 | 65 | { |
| 67 | 66 | // We are only interested if this is the first open tag. |
| 68 | - if ($stackPtr !== 0) { |
|
| 69 | - if ($phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)) !== false) { |
|
| 67 | + if ($stackPtr !== 0) |
|
| 68 | + { |
|
| 69 | + if ($phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)) !== false) |
|
| 70 | + { |
|
| 70 | 71 | return; |
| 71 | 72 | } |
| 72 | 73 | } |
@@ -85,21 +86,28 @@ discard block |
||
| 85 | 86 | ) { |
| 86 | 87 | $token = $tokens[$currentToken]; |
| 87 | 88 | $tokenCode = $token['code']; |
| 88 | - if (T_COMMENT === $tokenCode) { |
|
| 89 | + if (T_COMMENT === $tokenCode) |
|
| 90 | + { |
|
| 89 | 91 | $commentString = self::_getCommentContent($token['content']); |
| 90 | - if (0 === strcmp($commentString, $commentTemplate)) { |
|
| 92 | + if (0 === strcmp($commentString, $commentTemplate)) |
|
| 93 | + { |
|
| 91 | 94 | $hasClosingFileComment = true; |
| 92 | 95 | } |
| 93 | - } else if (T_WHITESPACE === $tokenCode) { |
|
| 96 | + } |
|
| 97 | + else if (T_WHITESPACE === $tokenCode) |
|
| 98 | + { |
|
| 94 | 99 | // Whitespaces are allowed between the closing file comment, |
| 95 | 100 | // other comments and end of file |
| 96 | - } else { |
|
| 101 | + } |
|
| 102 | + else |
|
| 103 | + { |
|
| 97 | 104 | $isNotAWhitespaceOrAComment = true; |
| 98 | 105 | } |
| 99 | 106 | $currentToken--; |
| 100 | 107 | } |
| 101 | 108 | |
| 102 | - if ( ! $hasClosingFileComment) { |
|
| 109 | + if ( ! $hasClosingFileComment) |
|
| 110 | + { |
|
| 103 | 111 | $error = 'No comment block marks the end of file instead of the closing PHP tag. Please add a comment block containing only "' . $commentTemplate . '".'; |
| 104 | 112 | $phpcsFile->addError($error, $currentToken); |
| 105 | 113 | } |
@@ -32,8 +32,7 @@ discard block |
||
| 32 | 32 | * @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License |
| 33 | 33 | * @link http://pear.php.net/package/PHP_CodeSniffer |
| 34 | 34 | */ |
| 35 | -class ConstructorNameSniff extends AbstractScopeSniff |
|
| 36 | -{ |
|
| 35 | +class ConstructorNameSniff extends AbstractScopeSniff { |
|
| 37 | 36 | |
| 38 | 37 | |
| 39 | 38 | public $php5Constructors = '1'; |
@@ -71,18 +70,24 @@ discard block |
||
| 71 | 70 | |
| 72 | 71 | $isPhp4Constructor = strcasecmp($methodName, $className) === 0; |
| 73 | 72 | $isPhp5Constructor = strcasecmp($methodName, '__construct') === 0; |
| 74 | - if ($this->php5Constructors != '0') { |
|
| 75 | - if ($isPhp4Constructor) { |
|
| 73 | + if ($this->php5Constructors != '0') |
|
| 74 | + { |
|
| 75 | + if ($isPhp4Constructor) |
|
| 76 | + { |
|
| 76 | 77 | $error = "PHP4 style constructors are not allowed; use \"__construct\" instead"; |
| 77 | 78 | $phpcsFile->addError($error, $stackPtr); |
| 78 | 79 | } |
| 79 | - } else { |
|
| 80 | - if ($isPhp5Constructor) { |
|
| 80 | + } |
|
| 81 | + else |
|
| 82 | + { |
|
| 83 | + if ($isPhp5Constructor) |
|
| 84 | + { |
|
| 81 | 85 | $error = "PHP5 style constructors are not allowed; use \"$className\" instead"; |
| 82 | 86 | $phpcsFile->addError($error, $stackPtr); |
| 83 | 87 | } |
| 84 | 88 | } |
| 85 | - if ( ! $isPhp4Constructor && ! $isPhp5Constructor ) { |
|
| 89 | + if ( ! $isPhp4Constructor && ! $isPhp5Constructor ) |
|
| 90 | + { |
|
| 86 | 91 | return; |
| 87 | 92 | } |
| 88 | 93 | |
@@ -91,19 +96,24 @@ discard block |
||
| 91 | 96 | $parentClassName = $phpcsFile->findExtendedClassName($currScope); |
| 92 | 97 | $wrongConstructor = ''; |
| 93 | 98 | // prepares the error message and wrong constructor |
| 94 | - if ($this->php5Constructors != '0') { |
|
| 99 | + if ($this->php5Constructors != '0') |
|
| 100 | + { |
|
| 95 | 101 | $error = 'PHP4 style calls to parent constructors are not allowed.'; |
| 96 | 102 | $error = "$error Please use \"parent::__construct\" instead."; |
| 97 | - if (false !== $parentClassName) { |
|
| 103 | + if (false !== $parentClassName) |
|
| 104 | + { |
|
| 98 | 105 | $wrongConstructor = $parentClassName; |
| 99 | 106 | } |
| 100 | 107 | // Else $wrongConstructor will be empty |
| 101 | 108 | // and the test expression will always be false. |
| 102 | 109 | // It doesn't check that no parent method should be called |
| 103 | 110 | // when no parent class is defined. |
| 104 | - } else { |
|
| 111 | + } |
|
| 112 | + else |
|
| 113 | + { |
|
| 105 | 114 | $error = 'PHP5 style calls to parent constructors are not allowed.'; |
| 106 | - if (false !== $parentClassName) { |
|
| 115 | + if (false !== $parentClassName) |
|
| 116 | + { |
|
| 107 | 117 | $error = "$error Please use \"parent::$parentClassName\" instead."; |
| 108 | 118 | } |
| 109 | 119 | $wrongConstructor = '__construct'; |
@@ -116,7 +126,8 @@ discard block |
||
| 116 | 126 | $stackPtr, |
| 117 | 127 | $endFunctionIndex |
| 118 | 128 | ); |
| 119 | - while ($doubleColonIndex) { |
|
| 129 | + while ($doubleColonIndex) |
|
| 130 | + { |
|
| 120 | 131 | if ($tokens[($doubleColonIndex + 1)]['code'] === T_STRING |
| 121 | 132 | && $tokens[($doubleColonIndex + 1)]['content'] === $wrongConstructor |
| 122 | 133 | ) { |
@@ -35,8 +35,7 @@ discard block |
||
| 35 | 35 | use PHP_CodeSniffer\Sniffs\Sniff; |
| 36 | 36 | use PHP_CodeSniffer\Files\File; |
| 37 | 37 | |
| 38 | -class ValidClassNameSniff implements Sniff |
|
| 39 | -{ |
|
| 38 | +class ValidClassNameSniff implements Sniff { |
|
| 40 | 39 | |
| 41 | 40 | |
| 42 | 41 | /** |
@@ -73,7 +72,8 @@ discard block |
||
| 73 | 72 | = strtoupper($className[0]) . strtolower(substr($lcClassNameChunk,1)); |
| 74 | 73 | // ensures that the current class name |
| 75 | 74 | // and the expected class name are identical |
| 76 | - if (0 !== strcmp($className, $expectedClassName)) { |
|
| 75 | + if (0 !== strcmp($className, $expectedClassName)) |
|
| 76 | + { |
|
| 77 | 77 | $error = 'Class names should always have their first letter uppercase. Multiple words should be separated with an underscore, and not CamelCased. Please consider ' . $expectedClassName . ' instead of ' . $className . '.'; |
| 78 | 78 | $phpcsFile->addError($error, $stackPtr); |
| 79 | 79 | } |