Skip to content
Permalink
Browse files

Trying out PHP Scrutinizer

  • Loading branch information...
Thoulah committed Jun 22, 2019
1 parent cfb87b6 commit 23ec43d7bba93451cbc954a11788194cd325e772
Showing with 3,637 additions and 1,870 deletions.
  1. +1 −0 .codeclimate.yml
  2. +7 −0 .php_cs
  3. +220 −0 .scrutinizer.yml
  4. +0 −20 .travis.yml
  5. +14 −13 App.php
  6. +6 −0 composer.json
  7. +1,058 −91 composer.lock
  8. +150 −0 cs/Config.php
  9. +29 −28 mister42/Common.php
  10. +3 −2 mister42/Console.php
  11. +1 −0 mister42/Params.php
  12. +22 −21 mister42/Web.php
  13. +3 −2 mister42/assets.php
  14. +3 −1 mister42/assets/AppAsset.php
  15. +2 −0 mister42/assets/AppAssetCompress.php
  16. +4 −2 mister42/assets/CharCounterAsset.php
  17. +5 −3 mister42/assets/ClipboardJsAsset.php
  18. +3 −1 mister42/assets/HighlightAsset.php
  19. +4 −2 mister42/assets/Html2MarkdownAsset.php
  20. +4 −2 mister42/assets/InputFileAsset.php
  21. +3 −1 mister42/assets/LightboxAsset.php
  22. +10 −8 mister42/assets/TimePickerAsset.php
  23. +9 −7 mister42/commands/ArticlesController.php
  24. +19 −15 mister42/commands/CollectionController.php
  25. +31 −27 mister42/commands/FeedController.php
  26. +46 −39 mister42/commands/LyricsController.php
  27. +27 −20 mister42/controllers/ArticlesController.php
  28. +18 −12 mister42/controllers/CalculatorController.php
  29. +7 −4 mister42/controllers/FeedController.php
  30. +26 −21 mister42/controllers/MusicController.php
  31. +9 −6 mister42/controllers/MyController.php
  32. +7 −5 mister42/controllers/SiteController.php
  33. +34 −27 mister42/controllers/ToolsController.php
  34. +8 −6 mister42/controllers/WebhookController.php
  35. +14 −12 mister42/controllers/user/ProfileController.php
  36. +3 −2 mister42/mail/commentToAuthor.php
  37. +2 −1 mister42/mail/commentToCommenter.php
  38. +3 −2 mister42/mail/layouts/html.php
  39. +1 −0 mister42/mail/layouts/text.php
  40. +254 −254 mister42/messages/de/mr42.php
  41. +254 −254 mister42/messages/ru/mr42.php
  42. +10 −6 mister42/models/ActiveForm.php
  43. +3 −1 mister42/models/Console.php
  44. +16 −13 mister42/models/Formatter.php
  45. +2 −0 mister42/models/Icon.php
  46. +4 −3 mister42/models/Image.php
  47. +3 −1 mister42/models/Mailer.php
  48. +30 −26 mister42/models/Menu.php
  49. +25 −21 mister42/models/Pdf.php
  50. +33 −27 mister42/models/Video.php
  51. +5 −3 mister42/models/Webrequest.php
  52. +18 −15 mister42/models/articles/Articles.php
  53. +14 −12 mister42/models/articles/ArticlesComments.php
  54. +2 −0 mister42/models/articles/Query.php
  55. +1 −0 mister42/models/articles/Search.php
  56. +10 −7 mister42/models/articles/Tags.php
  57. +5 −3 mister42/models/calculator/Date.php
  58. +4 −2 mister42/models/calculator/Duration.php
  59. +9 −6 mister42/models/calculator/Office365.php
  60. +6 −3 mister42/models/calculator/Timezone.php
  61. +2 −0 mister42/models/calculator/Wpapsk.php
  62. +1 −0 mister42/models/feed/Feed.php
  63. +19 −17 mister42/models/feed/Sitemap.php
  64. +18 −14 mister42/models/music/Collection.php
  65. +3 −1 mister42/models/music/Lyrics1Artists.php
  66. +11 −9 mister42/models/music/Lyrics2Albums.php
  67. +13 −9 mister42/models/music/Lyrics3Tracks.php
  68. +2 −0 mister42/models/music/Lyrics4Lyrics.php
  69. +2 −0 mister42/models/music/LyricsArtistInfo.php
  70. +2 −0 mister42/models/music/LyricsQuery.php
  71. +5 −2 mister42/models/my/Contact.php
  72. +5 −3 mister42/models/site/Webmanifest.php
  73. +45 −42 mister42/models/tools/Barcode.php
  74. +10 −7 mister42/models/tools/Favicon.php
  75. +2 −1 mister42/models/tools/Oui.php
  76. +9 −7 mister42/models/tools/PhoneticAlphabet.php
  77. +1 −0 mister42/models/tools/PhoneticAlphabetNumeric.php
  78. +39 −30 mister42/models/tools/Qr.php
  79. +2 −0 mister42/models/tools/qr/Bitcoin.php
  80. +3 −1 mister42/models/tools/qr/Bookmark.php
  81. +3 −1 mister42/models/tools/qr/EmailMessage.php
  82. +2 −0 mister42/models/tools/qr/FreeInput.php
  83. +3 −1 mister42/models/tools/qr/Geographic.php
  84. +4 −2 mister42/models/tools/qr/Ical.php
  85. +2 −0 mister42/models/tools/qr/MMS.php
  86. +2 −0 mister42/models/tools/qr/MailTo.php
  87. +3 −1 mister42/models/tools/qr/MeCard.php
  88. +2 −0 mister42/models/tools/qr/Phone.php
  89. +1 −0 mister42/models/tools/qr/SMS.php
  90. +4 −2 mister42/models/tools/qr/Vcard.php
  91. +7 −5 mister42/models/tools/qr/WiFi.php
  92. +2 −0 mister42/models/tools/qr/YouTube.php
  93. +4 −1 mister42/models/user/Profile.php
  94. +20 −14 mister42/models/user/RecentTracks.php
  95. +2 −0 mister42/models/user/RegistrationForm.php
  96. +1 −0 mister42/models/user/User.php
  97. +2 −1 mister42/models/user/WeeklyArtist.php
  98. +3 −1 mister42/models/webhook/Github.php
  99. +5 −4 mister42/tests/ControllerTest.php
  100. +18 −17 mister42/tests/FormatterTest.php
  101. +7 −5 mister42/tests/ImageTest.php
  102. +13 −11 mister42/tests/VideoTest.php
  103. +2 −1 mister42/tests/_bootstrap.php
  104. +56 −49 mister42/views/articles/_comments.php
  105. +9 −5 mister42/views/articles/_formArticle.php
  106. +14 −10 mister42/views/articles/_formComment.php
  107. +37 −29 mister42/views/articles/_view.php
  108. +8 −6 mister42/views/articles/index.php
  109. +8 −5 mister42/views/articles/view.php
  110. +6 −5 mister42/views/calculator/date.php
  111. +8 −7 mister42/views/calculator/duration.php
  112. +12 −11 mister42/views/calculator/office365.php
  113. +8 −7 mister42/views/calculator/timezone.php
  114. +13 −8 mister42/views/calculator/weeknumbers.php
  115. +18 −13 mister42/views/calculator/wpapsk.php
  116. +19 −18 mister42/views/feed/rss.php
  117. +10 −7 mister42/views/feed/sitemap-articles.php
  118. +5 −4 mister42/views/feed/sitemap-lyrics.php
  119. +5 −3 mister42/views/feed/sitemap.php
  120. +16 −13 mister42/views/layouts/columns.php
  121. +24 −17 mister42/views/layouts/main.php
  122. +11 −7 mister42/views/layouts/recenttracks.php
  123. +15 −13 mister42/views/music/collection.php
  124. +17 −16 mister42/views/music/lyrics-album-pdf.php
  125. +6 −5 mister42/views/music/lyrics1artists.php
  126. +73 −57 mister42/views/music/lyrics2albums.php
  127. +28 −24 mister42/views/music/lyrics3tracks.php
  128. +1 −0 mister42/views/my/contact-success.php
  129. +9 −6 mister42/views/my/contact.php
  130. +15 −14 mister42/views/my/pi.php
  131. +1 −0 mister42/views/site/browserconfigxml.php
  132. +1 −0 mister42/views/site/error.php
  133. +10 −8 mister42/views/site/index.php
  134. +1 −0 mister42/views/site/offline.php
  135. +23 −17 mister42/views/site/php.php
  136. +15 −14 mister42/views/site/privacy.php
  137. +11 −10 mister42/views/site/robotstxt.php
  138. +13 −10 mister42/views/tools/barcode.php
  139. +16 −12 mister42/views/tools/favicon.php
  140. +11 −6 mister42/views/tools/headers.php
  141. +18 −11 mister42/views/tools/html-to-markdown.php
  142. +15 −10 mister42/views/tools/oui.php
  143. +13 −7 mister42/views/tools/password.php
  144. +3 −1 mister42/views/tools/phonetic-alphabet.php
  145. +10 −10 mister42/views/tools/qr.php
  146. +1 −1 mister42/views/tools/qr/bitcoin.php
  147. +1 −1 mister42/views/tools/qr/bookmark.php
  148. +1 −1 mister42/views/tools/qr/emailmessage.php
  149. +1 −1 mister42/views/tools/qr/freeinput.php
  150. +3 −1 mister42/views/tools/qr/geographic.php
  151. +3 −2 mister42/views/tools/qr/ical.php
  152. +1 −1 mister42/views/tools/qr/mailto.php
  153. +7 −3 mister42/views/tools/qr/mecard.php
  154. +1 −1 mister42/views/tools/qr/mms.php
  155. +1 −1 mister42/views/tools/qr/phone.php
  156. +5 −2 mister42/views/tools/qr/vcard.php
  157. +1 −0 mister42/views/tools/qr/wifi.php
  158. +2 −2 mister42/views/tools/qr/youtube.php
  159. +10 −5 mister42/views/user/admin/_profile.php
  160. +13 −10 mister42/views/user/profile/show.php
  161. +3 −1 mister42/views/user/registration/register.php
  162. +12 −9 mister42/views/user/security/login.php
  163. +12 −7 mister42/views/user/settings/profile.php
  164. +6 −3 mister42/widgets/Feed.php
  165. +12 −8 mister42/widgets/Item.php
  166. +10 −7 mister42/widgets/Lightbox.php
  167. +5 −3 mister42/widgets/RecentArticles.php
  168. +6 −4 mister42/widgets/RecentComments.php
  169. +16 −9 mister42/widgets/RecentTracks.php
  170. +6 −4 mister42/widgets/TagCloud.php
  171. +21 −18 mister42/widgets/TimePicker.php
  172. +11 −6 mister42/widgets/WeeklyArtistChart.php
  173. +3 −2 mr42/Web.php
  174. +9 −6 mr42/controllers/DownloadController.php
  175. +5 −3 mr42/controllers/PermalinkController.php
  176. +4 −2 mr42/controllers/RedirectController.php
  177. +2 −1 mr42/models/Articles.php
  178. +1 −0 webroot/index.php
@@ -25,6 +25,7 @@ ratings:
- "**.js"
- "**.php"
exclude_paths:
- cs/
- mister42/assets/
- mister42/commands/
- mister42/messages/
@@ -0,0 +1,7 @@
<?php
return mister42\cs\Config::create()
->setCacheFile(__DIR__ . '/../../.cache/yii/mister42/php_cs.cache')
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__)
);
@@ -0,0 +1,220 @@
build:
nodes:
tests: true
analysis:
tests:
override:
- php-scrutinizer-run
tests:
override:
command: "true"
filter:
dependency_paths:
- "$HOME/vendor"
excluded_paths:
- "cs/"
- "tests/"
checks:
php:
verify_property_names: true
verify_argument_usable_as_reference: true
verify_access_scope_valid: true
variable_existence: true
useless_calls: true
use_statement_alias_conflict: true
unused_variables: true
unused_properties: true
unused_parameters: true
unused_methods: true
unreachable_code: true
too_many_arguments: true
symfony_request_injection: true
switch_fallthrough_commented: true
sql_injection_vulnerabilities: true
simplify_boolean_return: true
security_vulnerabilities: true
return_in_constructor: true
return_doc_comments: true
return_doc_comment_if_not_inferrable: true
require_scope_for_methods: true
require_php_tag_first: true
remove_extra_empty_lines: true
property_assignments: true
properties_in_camelcaps: true
precedence_mistakes: true
precedence_in_conditions: true
phpunit_assertions: true
parse_doc_comments: true
parameters_in_camelcaps: true
parameter_non_unique: true
parameter_doc_comments: true
param_doc_comment_if_not_inferrable: true
overriding_private_members: true
overriding_parameter: true
non_commented_empty_catch_block: true
no_trait_type_hints: true
no_trailing_whitespace: true
no_short_variable_names:
minimum: '3'
no_short_open_tag: true
no_short_method_names:
minimum: '3'
no_property_on_interface: true
no_non_implemented_abstract_methods: true
no_long_variable_names:
maximum: '20'
no_goto: true
no_exit: true
no_eval: true
no_error_suppression: true
no_debug_code: true
naming_conventions:
local_variable: '^[a-z][a-zA-Z0-9]*$'
abstract_class_name: ^Abstract|Factory$
utility_class_name: 'Utils?$'
constant_name: '^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$'
property_name: '^[a-z][a-zA-Z0-9]*$'
method_name: '^(?:[a-z]|__)[a-zA-Z0-9]*$'
parameter_name: '^[a-z][a-zA-Z0-9]*$'
interface_name: '^[A-Z][a-zA-Z0-9]*Interface$'
type_name: '^[A-Z][a-zA-Z0-9]*$'
exception_name: '^[A-Z][a-zA-Z0-9]*Exception$'
isser_method_name: '^(?:is|has|should|may|supports)'
more_specific_types_in_doc_comments: true
missing_arguments: true
method_calls_on_non_object: true
instanceof_class_exists: true
foreach_usable_as_reference: true
foreach_traversable: true
fix_use_statements:
remove_unused: true
preserve_multiple: false
preserve_blanklines: false
order_alphabetically: true
fix_line_ending: true
fix_doc_comments: true
encourage_shallow_comparison: true
duplication: true
deprecated_code_usage: true
deadlock_detection_in_loops: true
comparison_always_same_result: true
code_rating: true
closure_use_not_conflicting: true
closure_use_modifiable: true
check_method_contracts:
verify_interface_like_constraints: true
verify_documented_constraints: true
verify_parent_constraints: true
catch_class_exists: true
call_to_parent_method: true
avoid_superglobals: true
avoid_length_functions_in_loops: true
avoid_entity_manager_injection: true
avoid_duplicate_types: true
avoid_closing_tag: true
assignment_of_null_return: true
argument_type_checks: true
coding_style:
php:
indentation:
general:
use_tabs: true
size: 4
switch:
indent_case: true
spaces:
general:
linefeed_character: newline
before_parentheses:
function_declaration: false
closure_definition: true
function_call: false
if: true
for: true
while: true
switch: true
catch: true
array_initializer: false
around_operators:
assignment: true
logical: true
equality: true
relational: true
bitwise: true
additive: true
multiplicative: true
shift: true
unary_additive: false
concatenation: true
negation: false
before_left_brace:
class: true
function: true
if: true
else: true
for: true
while: true
do: true
switch: true
try: true
catch: true
finally: true
before_keywords:
else: true
while: true
catch: true
finally: true
within:
brackets: false
array_initializer: false
grouping: false
function_call: false
function_declaration: false
if: false
for: false
while: false
switch: false
catch: false
type_cast: false
ternary_operator:
before_condition: true
after_condition: true
before_alternative: true
after_alternative: true
in_short_version: false
other:
before_comma: false
after_comma: true
before_semicolon: false
after_semicolon: true
after_type_cast: true
braces:
classes_functions:
class: end-of-line
function: end-of-line
closure: end-of-line
if:
opening: end-of-line
always: false
else_on_new_line: false
for:
opening: end-of-line
always: false
while:
opening: end-of-line
always: false
do_while:
opening: end-of-line
always: false
while_on_new_line: false
switch:
opening: end-of-line
try:
opening: end-of-line
catch_on_new_line: false
finally_on_new_line: false
upper_lower_casing:
keywords:
general: lower
constants:
true_false_null: lower

This file was deleted.

27 App.php
@@ -1,21 +1,22 @@
<?php
class App {
public function __construct(bool $debug = false, bool $unitTest = false) {
header_remove("X-Powered-By");
if ($debug) :
header_remove('X-Powered-By');
if ($debug) {
error_reporting(-1);
define('YII_DEBUG', true);
define('YII_ENABLE_ERROR_HANDLER', !$unitTest);
endif;
}
$loader = require __DIR__.'/../vendor/autoload.php';
$loader->setPsr4('mr42\\', __DIR__.'/mr42/');
$loader->setPsr4('mister42\\', __DIR__.'/mister42/');
require __DIR__.'/../vendor/yiisoft/yii2/Yii.php';
$loader = require __DIR__ . '/../vendor/autoload.php';
$loader->setPsr4('mr42\\', __DIR__ . '/mr42/');
$loader->setPsr4('mister42\\', __DIR__ . '/mister42/');
require __DIR__ . '/../vendor/yiisoft/yii2/Yii.php';
if ($unitTest)
if ($unitTest) {
return new yii\web\Application($this->loadConfig(['mister42'], 'Web'));
}
$app = (php_sapi_name() === 'cli')
? new yii\console\Application($this->loadConfig(['mister42'], 'Console'))
: new yii\web\Application($this->getConfig());
@@ -28,18 +29,18 @@ private function getConfig(): array {
switch (yii\helpers\ArrayHelper::getValue($_SERVER, 'SERVER_NAME')) :
case 'mister42.me':
return $this->loadConfig(['mister42'], 'Web');
default:
default:
return $this->loadConfig(['mister42', 'mr42'], 'Web');
endswitch;
}
private function loadConfig(array $dir, string $confFile): array {
$config = ($dir[1] ?? $dir[0])."\\{$confFile}";
$config = ($dir[1] ?? $dir[0]) . "\\{$confFile}";
$common = "{$dir[0]}\\Common";
return yii\helpers\ArrayHelper::merge(
(new $config)->getValues(),
(new $common)->getValues()
(new $config())->getValues(),
(new $common())->getValues()
);
}
}
@@ -36,8 +36,14 @@
"zenorocha/clipboardjs": "^2.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "~2.15.0",
"yiisoft/yii2-debug": "*"
},
"autoload-dev": {
"psr-4": {
"mister42\\cs\\": "cs"
}
},
"replace": {
"yiisoft/yii2-bootstrap": "*"
},

0 comments on commit 23ec43d

Please sign in to comment.
You can’t perform that action at this time.