Skip to content

Commit 229d77f

Browse files
committed
Support for Laravel
1 parent f115e7c commit 229d77f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+852
-138
lines changed

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,8 @@
103103
},
104104

105105
"scripts-descriptions": {
106+
},
107+
108+
"extra": {
106109
}
107110
}

phpcs.xml.dist

Lines changed: 59 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22
<ruleset name="Base Coding Standard">
33

4-
<description>Base Coding Standard</description>
4+
<description>Base Coding Standard - PSR12</description>
55

66
<!-- README: http://edorian.github.io/php-coding-standard-generator/#phpcs -->
77

@@ -11,9 +11,11 @@
1111
<!-- Exclude Composer vendor directory. -->
1212
<exclude-pattern>*/vendor/*</exclude-pattern>
1313

14+
1415
<!-- You can hard-code custom php.ini settings into your custom standard. -->
1516
<ini name="memory_limit" value="256M"/>
1617

18+
1719
<!-- Call with arguments -->
1820
<arg name="encoding" value="utf-8"/>
1921
<arg name="extensions" value="php"/>
@@ -35,13 +37,15 @@
3537
<severity>0</severity>
3638
</rule>
3739

40+
3841
<!-- Don't hide tokenizer exceptions -->
3942
<rule ref="Internal.Tokenizer.Exception">
4043
<type>error</type>
4144
</rule>
4245

46+
4347
<!-- Include the whole PSR-2 standard -->
44-
<rule ref="PSR2">
48+
<rule ref="PSR12">
4549
<!-- To address at a later point in time. -->
4650
<exclude name="Generic.Files.LineLength.TooLong"/>
4751

@@ -58,6 +62,7 @@
5862

5963
<rule ref="Squiz.Arrays.ArrayDeclaration">
6064
<exclude name="Squiz.Arrays.ArrayDeclaration.KeySpecified"/>
65+
<exclude name="Squiz.Arrays.ArrayDeclaration.NoKeySpecified"/>
6166
<exclude name="Squiz.Arrays.ArrayDeclaration.ValueNoNewline"/>
6267
</rule>
6368

@@ -117,15 +122,9 @@
117122
<!-- Checks the declaration of the class and its inheritance is correct -->
118123
<rule ref="Squiz.Classes.ClassDeclaration"/>
119124

120-
<!-- All classes keywords should be lowercase -->
121-
<rule ref="Squiz.Classes.LowercaseClassKeywords"/>
122-
123125
<!-- Tests self member references -->
124126
<rule ref="Squiz.Classes.SelfMemberReference"/>
125127

126-
<!-- Test class names are camel-cased properly -->
127-
<rule ref="Squiz.Classes.ValidClassName"/>
128-
129128

130129
<!-- ============================ -->
131130
<!-- === Code Analysis Sniffs === -->
@@ -157,6 +156,8 @@
157156
<!-- ========================= -->
158157

159158
<rule ref="Squiz.Commenting.BlockComment">
159+
<exclude name="Squiz.Commenting.BlockComment.HasEmptyLineBefore"/>
160+
<exclude name="Squiz.Commenting.BlockComment.NoEmptyLineBefore"/>
160161
<exclude name="Squiz.Commenting.BlockComment.NoEmptyLineAfter"/>
161162
<exclude name="Squiz.Commenting.BlockComment.SingleLine"/>
162163
<exclude name="Squiz.Commenting.BlockComment.CloserSameLine"/>
@@ -165,6 +166,7 @@
165166
<exclude name="Squiz.Commenting.BlockComment.NoNewLine"/>
166167
<exclude name="Squiz.Commenting.BlockComment.WrongStart"/>
167168
</rule>
169+
168170
<rule ref="Squiz.Commenting.DocCommentAlignment"/>
169171
<rule ref="Squiz.Commenting.EmptyCatchComment"/>
170172
<rule ref="Squiz.Commenting.LongConditionClosingComment"/>
@@ -218,9 +220,6 @@
218220
<!-- Inline controls (IF, ELSE, FOR, WHILE) must have brackets -->
219221
<rule ref="Generic.ControlStructures.InlineControlStructure"/>
220222

221-
<!-- Ensures that switch statements are defined according to PSR2. -->
222-
<rule ref="PSR2.ControlStructures.SwitchDeclaration"/>
223-
224223
<!-- The keyword elseif SHOULD be used instead of else if so that all control keywords look like single words. -->
225224
<rule ref="PSR2.ControlStructures.ElseIfDeclaration">
226225
<type>error</type>
@@ -249,6 +248,9 @@
249248
</properties>
250249
</rule>
251250

251+
<!-- Force whitespace after `!` -->
252+
<rule ref="Generic.Formatting.SpaceAfterNot"/>
253+
252254

253255
<!-- ======================== -->
254256
<!-- === Functions Sniffs === -->
@@ -315,6 +317,12 @@
315317

316318
<rule ref="Generic.PHP.DisallowShortOpenTag.EchoFound"/>
317319

320+
<!-- Forbid global functions -->
321+
<rule ref="Squiz.Functions.GlobalFunction"/>
322+
323+
<!-- Forbid `global` -->
324+
<rule ref="Squiz.PHP.GlobalKeyword"/>
325+
318326
<!-- Discourage unsafe functions -->
319327
<rule ref="Generic.PHP.ForbiddenFunctions">
320328
<properties>
@@ -326,6 +334,28 @@
326334
<element key="print" value="echo"/>
327335
<element key="is_null" value="null"/>
328336
<element key="create_function" value="null"/>
337+
<element key="dd" value="null"/>
338+
<element key="show_source" value="highlight_file"/>
339+
<element key="pos" value="current"/>
340+
<element key="settype" value="null"/>
341+
<element key="eval" value="null"/>
342+
<element key="strchr" value="strstr"/>
343+
<element key="chop" value="rtrim"/>
344+
<element key="close" value="closedir"/>
345+
<element key="compact" value="null"/>
346+
<element key="delete" value="unset"/>
347+
<element key="doubleval" value="floatval"/>
348+
<element key="extract" value="null"/>
349+
<element key="fputs" value="fwrite"/>
350+
<element key="ini_alter" value="ini_set"/>
351+
<element key="is_double" value="is_float"/>
352+
<element key="is_integer" value="is_int"/>
353+
<element key="is_long" value="is_int"/>
354+
<element key="is_null" value="null"/>
355+
<element key="is_real" value="is_float"/>
356+
<element key="is_writeable" value="is_writable"/>
357+
<element key="join" value="implode"/>
358+
<element key="key_exists" value="array_key_exists"/>
329359
</property>
330360
</properties>
331361
</rule>
@@ -343,9 +373,15 @@
343373
<!-- Ensures all calls to builtin PHP functions are lowercase. -->
344374
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
345375

346-
<!-- Checks that all PHP types are lowercase. -->
376+
<!-- Forbid backtick operator -->
377+
<rule ref="Generic.PHP.BacktickOperator"/>
378+
379+
<!-- Force PHP 7 param and return types to be lowercased -->
347380
<rule ref="Generic.PHP.LowerCaseType"/>
348381

382+
<!-- Forbid dead code -->
383+
<rule ref="Squiz.PHP.NonExecutableCode"/>
384+
349385

350386
<!-- ==================== -->
351387
<!-- === Scope Sniffs === -->
@@ -377,10 +413,17 @@
377413
</properties>
378414
</rule>
379415

416+
<rule ref="Squiz.Strings.DoubleQuoteUsage"/>
380417
<rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar">
381-
<type>warning</type>
418+
<message>Variable "%s" not allowed in double quoted string; use sprintf(), vsprintf() or concatenation instead</message>
382419
</rule>
383420

421+
<!-- Forbid braces around string in `echo` -->
422+
<rule ref="Squiz.Strings.EchoedStrings"/>
423+
424+
<!-- Forbid blank line after function opening brace -->
425+
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
426+
384427

385428
<!-- ============================== -->
386429
<!-- === Version Control Sniffs === -->
@@ -426,6 +469,9 @@
426469
</properties>
427470
</rule>
428471

472+
<!-- Require there be no space between increment/decrement operator and its operand -->
473+
<rule ref="Generic.WhiteSpace.IncrementDecrementSpacing"/>
474+
429475
<!-- Object operators must be indented 4 spaces if they are the first thing on a line. -->
430476
<rule ref="PEAR.WhiteSpace.ObjectOperatorIndent"/>
431477

@@ -472,35 +518,14 @@
472518
<!-- === Namespace and Use Declarations Sniffs === -->
473519
<!-- ============================================= -->
474520

475-
<!-- There must be one blank line after the namespace declaration. -->
476-
<rule ref="PSR2.Namespaces.NamespaceDeclaration"/>
477-
478-
<!-- Ensures USE blocks are declared according to PSR2. -->
479-
<rule ref="PSR2.Namespaces.UseDeclaration"/>
480-
481521

482522
<!-- ======================================== -->
483523
<!-- === Classes, Properties, and Methods === -->
484524
<!-- ======================================== -->
485-
<rule ref="PSR12.Classes.ClassInstantiation"/>
486525

487526
<!-- Private properties MUST not be prefixed with an underscore -->
488527
<rule ref="PSR2.Classes.PropertyDeclaration.Underscore">
489528
<type>error</type>
490529
</rule>
491530

492-
<!-- Only one argument per line in multi-line function calls -->
493-
<rule ref="PEAR.Functions.FunctionCallSignature">
494-
<properties>
495-
<property name="allowMultipleArguments" value="false"/>
496-
</properties>
497-
</rule>
498-
499-
<!-- Private methods MUST not be prefixed with an underscore -->
500-
<rule ref="PSR2.Methods.MethodDeclaration.Underscore">
501-
<type>error</type>
502-
</rule>
503-
504-
<rule ref="PSR12.Keywords.ShortFormTypeKeywords"/>
505-
506531
</ruleset>

src/Builder/ContainerBuilder.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
/**
1919
* Class ContainerBuilder
20-
*
21-
* @package BinaryCube\CarrotMQ\Builder
2220
*/
2321
class ContainerBuilder extends Component
2422
{
@@ -84,7 +82,7 @@ public function build(array $config)
8482
*
8583
* @return $this
8684
*/
87-
protected function createConnections(Container $container, array $config)
85+
protected function createConnections(Container $container, array $config)
8886
{
8987
$connections = $config['connections'];
9088

@@ -105,7 +103,7 @@ protected function createConnections(Container $container, array $config)
105103
*
106104
* @return $this
107105
*/
108-
protected function createTopics(Container $container, array $config)
106+
protected function createTopics(Container $container, array $config)
109107
{
110108
$topics = $config['topics'];
111109
$defaultConfig = [
@@ -123,7 +121,7 @@ protected function createTopics(Container $container, array $config)
123121

124122
if (
125123
empty($topic['connection']) ||
126-
!$container->connections()->has($topic['connection'])
124+
! $container->connections()->has($topic['connection'])
127125
) {
128126
throw new \RuntimeException(
129127
\vsprintf(
@@ -156,7 +154,7 @@ protected function createTopics(Container $container, array $config)
156154
*
157155
* @return $this
158156
*/
159-
protected function createQueues(Container $container, array $config)
157+
protected function createQueues(Container $container, array $config)
160158
{
161159
$queues = $config['queues'];
162160
$defaultConfig = [
@@ -174,7 +172,7 @@ protected function createQueues(Container $container, array $config)
174172

175173
if (
176174
empty($queue['connection']) ||
177-
!$container->connections()->has($queue['connection'])
175+
! $container->connections()->has($queue['connection'])
178176
) {
179177
throw new \RuntimeException(
180178
\vsprintf(
@@ -220,7 +218,7 @@ protected function createPublishers(Container $container, array $config)
220218

221219
if (
222220
empty($publisher['topic']) ||
223-
!$container->topics()->has($publisher['topic'])
221+
! $container->topics()->has($publisher['topic'])
224222
) {
225223
throw new \RuntimeException(
226224
\vsprintf(
@@ -266,7 +264,7 @@ protected function createConsumers(Container $container, array $config)
266264

267265
if (
268266
empty($consumer['queue']) ||
269-
!$container->queues()->has($consumer['queue'])
267+
! $container->queues()->has($consumer['queue'])
270268
) {
271269
throw new \RuntimeException(
272270
\vsprintf(
@@ -295,7 +293,7 @@ function () {
295293
$processor = new $processor();
296294
}
297295

298-
if (!($processor instanceof Processor)) {
296+
if (! ($processor instanceof Processor)) {
299297
throw new \LogicException(
300298
\vsprintf(
301299
"Can't create processor, '%s' must extend from %s or its child class.",

src/Builder/MessageBuilder.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
/**
88
* Class MessageBuilder
9-
*
10-
* @package BinaryCube\CarrotMQ\Builder
119
*/
1210
class MessageBuilder
1311
{

src/CarrotMQ.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
/**
99
* Class CarrotMQ
10-
*
11-
* @package BinaryCube\CarrotMQ
1210
*/
1311
class CarrotMQ extends Component
1412
{

src/Collection/BaseList.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
/**
66
* Class BaseList
7-
*
8-
* @package BinaryCube\CarrotMQ\Collection
97
*/
108
class BaseList
119
{

src/Collection/ConnectionList.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
/**
88
* Class ConnectionList
99
*
10-
* @package BinaryCube\CarrotMQ\Collection
11-
*
1210
* @method Connection[] __invoke()
1311
* @method $this add(string $id, Connection $item)
1412
* @method $this remove(string $id)
@@ -19,4 +17,5 @@
1917
*/
2018
class ConnectionList extends BaseList
2119
{
20+
//
2221
}

src/Collection/ConsumerList.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
/**
88
* Class ConsumerList
99
*
10-
* @package BinaryCube\CarrotMQ\Collection
11-
*
1210
* @method Consumer[] __invoke()
1311
* @method $this add(string $id, Consumer $item)
1412
* @method $this remove(string $id)
@@ -19,4 +17,5 @@
1917
*/
2018
class ConsumerList extends BaseList
2119
{
20+
//
2221
}

src/Collection/ExtensionList.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
/**
88
* Class ExtensionList
99
*
10-
* @package BinaryCube\CarrotMQ\Collection
11-
*
1210
* @method Extension[] __invoke()
1311
* @method $this add(string $id, Extension $item)
1412
* @method $this remove(string $id)
@@ -19,4 +17,5 @@
1917
*/
2018
class ExtensionList extends BaseList
2119
{
20+
//
2221
}

src/Collection/PublisherList.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
/**
88
* Class PublisherList
99
*
10-
* @package BinaryCube\CarrotMQ\Collection
11-
*
1210
* @method Publisher[] __invoke()
1311
* @method $this add(string $id, Publisher $item)
1412
* @method $this remove(string $id)
@@ -19,4 +17,5 @@
1917
*/
2018
class PublisherList extends BaseList
2119
{
20+
//
2221
}

0 commit comments

Comments
 (0)