Skip to content
This repository was archived by the owner on Oct 30, 2024. It is now read-only.

Commit 3ab4844

Browse files
authored
Merge pull request repejota#96 from repejota/feature/lint-squiz
Feature/lint squiz
2 parents 5f8e2b9 + 704cf79 commit 3ab4844

18 files changed

Lines changed: 288 additions & 169 deletions

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ before_script:
1717
- make deps
1818
script:
1919
- mkdir -p build/logs
20-
- make lint-php
21-
- make lint-psr2
20+
- make lint
2221
- make test
2322
after_script:
2423
- php vendor/bin/coveralls

README.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ phpnats
33

44
**Travis**
55

6-
* Master: [![Build Status](https://travis-ci.org/repejota/phpnats.png?branch=master)](https://travis-ci.org/repejota/phpnats)
7-
* Develop: [![Build Status](https://travis-ci.org/repejota/phpnats.png?branch=develop)](https://travis-ci.org/repejota/phpnats)
6+
| Master | Develop |
7+
| ------------- | ------------- |
8+
| [![Build Status](https://travis-ci.org/repejota/phpnats.png?branch=master)](https://travis-ci.org/repejota/phpnats) | [![Build Status](https://travis-ci.org/repejota/phpnats.png?branch=develop)](https://travis-ci.org/repejota/phpnats) |
89

910
**Coverage**
1011

11-
* Master: [![Coverage Status](https://coveralls.io/repos/repejota/phpnats/badge.svg?branch=master)](https://coveralls.io/r/repejota/phpnats?branch=master)
12-
* Develop: [![Coverage Status](https://coveralls.io/repos/repejota/phpnats/badge.svg?branch=develop)](https://coveralls.io/r/repejota/phpnats?branch=develop)
12+
| Master | Develop |
13+
| ------------- | ------------- |
14+
| [![Coverage Status](https://coveralls.io/repos/repejota/phpnats/badge.svg?branch=master)](https://coveralls.io/r/repejota/phpnats?branch=master) | [![Coverage Status](https://coveralls.io/repos/repejota/phpnats/badge.svg?branch=develop)](https://coveralls.io/r/repejota/phpnats?branch=develop) |
1315

1416
Introduction
1517
------------
@@ -88,23 +90,33 @@ Developer's Information
8890

8991
### Releases
9092

91-
[Latest stable](https://github.com/repejota/phpnats/tree/master)
92-
[Latest dev](https://github.com/repejota/phpnats/tree/develop)
93+
* [Latest stable](https://github.com/repejota/phpnats/tree/master)
94+
* [Latest dev](https://github.com/repejota/phpnats/tree/develop)
95+
96+
* [PHPNats on Packagist](https://packagist.org/packages/repejota/nats)
9397

9498
### Tests
9599

96100
Tests are in the `tests` folder.
97-
To run them, you need `PHPUnit` and execute `make test`.
101+
To run them, you need `PHPUnit` and execute `make test-tdd`.
98102

99103
We also have a BDD test suite under the `spec` folder.
100-
To run the suite, you need `PHPSpec` and execute `make bdd`.
104+
To run the suite, you need `PHPSpec` and execute `make test-bdd`.
105+
106+
You can also execute the all suites ( TDD + BDD ) with `make test`.
101107

102108
### Code Quality
103109

104110
We are using [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer/docs)
105111
to ensure our code follow an high quality standard.
106112

107-
To perform an analysis of the code execute `make cs`.
113+
To perform an analysis of the code execute `make lint`.
114+
115+
There is currently three steps when we lint our code:
116+
117+
* First we lint with php itself `php -l`
118+
* Then we lint with PSR2 standard
119+
* And finally we lint with a custom [ruleset.xml](https://github.com/repejota/phpnats/blob/feature/lint-squiz/ruleset.xml) that checks dockblocks and different performance tips.
108120

109121

110122
Creators

examples/connect.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
<?php
2-
require_once __DIR__ . "/../vendor/autoload.php";
2+
require_once __DIR__.'/../vendor/autoload.php';
33

44
$connectionOptions = new \Nats\ConnectionOptions();
5-
$connectionOptions
6-
->setHost('localhost')
7-
->setPort(4222);
5+
$connectionOptions->setHost('localhost')->setPort(4222);
86
$c = new Nats\Connection($connectionOptions);
97
$c->connect();
108
$c->close();

examples/connectauth.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
<?php
2-
require_once __DIR__ . "/../vendor/autoload.php";
2+
require_once __DIR__.'/../vendor/autoload.php';
33

44
$connectionOptions = new \Nats\ConnectionOptions();
5-
$connectionOptions
6-
->setHost('localhost')
7-
->setPort(4222)
8-
->setUser("foo")
9-
->setPass("bar");
5+
$connectionOptions->setHost('localhost')->setPort(4222)->setUser('foo')->setPass('bar');
106
$c = new Nats\Connection($connectionOptions);
117
$c->connect();
128
$c->close();

examples/ping.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
<?php
2-
require_once __DIR__ . "/../vendor/autoload.php";
2+
require_once __DIR__.'/../vendor/autoload.php';
33

44
$connectionOptions = new \Nats\ConnectionOptions();
5-
$connectionOptions
6-
->setHost('localhost')
7-
->setPort(4222);
5+
$connectionOptions->setHost('localhost')->setPort(4222);
86

9-
echo "Server: nats://" . $connectionOptions->getHost() . ":" . $connectionOptions->getPort() . PHP_EOL;
7+
echo 'Server: nats://'.$connectionOptions->getHost().':'.$connectionOptions->getPort().PHP_EOL;
108

119
$c = new Nats\Connection($connectionOptions);
1210
$c->connect();

examples/pubsub/pub.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
<?php
2-
require_once __DIR__ . "/../../vendor/autoload.php";
2+
require_once __DIR__.'/../../vendor/autoload.php';
33

44
$connectionOptions = new \Nats\ConnectionOptions();
5-
$connectionOptions
6-
->setHost('localhost')
7-
->setPort(4222);
5+
$connectionOptions->setHost('localhost')->setPort(4222);
86
$c = new Nats\Connection($connectionOptions);
97
$c->connect();
108

119
$c->reconnect();
1210

13-
$c->publish("foo", "bar");
14-
$c->publish("foo", "bar");
15-
$c->publish("foo", "bar");
16-
$c->publish("foo", "bar");
17-
$c->publish("foo", "bar");
11+
$c->publish('foo', 'bar');
12+
$c->publish('foo', 'bar');
13+
$c->publish('foo', 'bar');
14+
$c->publish('foo', 'bar');
15+
$c->publish('foo', 'bar');

examples/pubsub/sub.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
<?php
2-
require_once __DIR__ . "/../../vendor/autoload.php";
2+
require_once __DIR__.'/../../vendor/autoload.php';
33

44
$connectionOptions = new \Nats\ConnectionOptions();
5-
$connectionOptions
6-
->setHost('localhost')
7-
->setPort(4222);
5+
$connectionOptions->setHost('localhost')->setPort(4222);
86
$c = new Nats\Connection($connectionOptions);
97
$c->connect();
108

119
$callback = function ($payload) {
1210
printf("Data: %s\r\n", $payload);
1311
};
1412

15-
$sid = $c->subscribe("foo", $callback);
13+
$sid = $c->subscribe('foo', $callback);
1614

1715
$c->wait(2);
1816

examples/reqres/req.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
require_once __DIR__ . "/../../vendor/autoload.php";
2+
require_once __DIR__.'/../../vendor/autoload.php';
33

44
$connectionOptions = new \Nats\ConnectionOptions();
55
$connectionOptions->setHost('localhost')->setPort(4222);

examples/reqres/res.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
<?php
2-
require_once __DIR__ . "/../../vendor/autoload.php";
2+
require_once __DIR__.'/../../vendor/autoload.php';
33

44
$connectionOptions = new \Nats\ConnectionOptions();
5-
$connectionOptions
6-
->setHost('localhost')
7-
->setPort(4222);
5+
$connectionOptions->setHost('localhost')->setPort(4222);
86
$c = new Nats\Connection($connectionOptions);
97
$c->connect();
108

119
$sid = $c->subscribe(
12-
"sayhello",
10+
'sayhello',
1311
function ($res) {
14-
$res->reply("Hello, " . $res->getBody() . " !!!");
12+
$res->reply('Hello, '.$res->getBody().' !!!');
1513
}
1614
);
1715

ruleset.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,34 @@
22
<ruleset name="Custom Standard">
33
<description>php-nats Coding Standards for Inline Documentation and Comments</description>
44

5+
<rule ref="Squiz.Functions">
6+
<!-- Conflicts with PSR2 -->
7+
<exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpaceBeforeEquals" />
8+
<exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpaceAfterDefault" />
9+
</rule>
10+
11+
<rule ref="Squiz.Files">
12+
<!-- Avoid to check for .inc files ... always use .php -->
13+
<exclude name="Squiz.Files.FileExtension.ClassFound" />
14+
</rule>
15+
16+
<rule ref="Squiz.WhiteSpace">
17+
<!-- Conflict with PSR2 -->
18+
<exclude name="Squiz.WhiteSpace.FunctionClosingBraceSpace.SpacingBeforeClose" />
19+
</rule>
20+
21+
<rule ref="Squiz.NamingConventions">
22+
<!-- Do not use underscore prefix for anything private -->
23+
<exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore" />
24+
<exclude name="Squiz.NamingConventions.ValidFunctionName.PrivateNoUnderscore" />
25+
</rule>
26+
527
<rule ref="Squiz.Commenting">
28+
<exclude name="Squiz.WhiteSpace.FunctionSpacing.After" />
29+
<exclude name="Squiz.Commenting.LongConditionClosingComment.Missing" />
30+
<exclude name="Squiz.Commenting.ClosingDeclarationComment.Missing" />
31+
<!-- Don't need file doc comments -->
32+
<exclude name="Squiz.Commenting.FileComment.Missing" />
633
<!-- It is too early for PHP7 features to be required -->
734
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing" />
835
</rule>

0 commit comments

Comments
 (0)