Skip to content

Commit 84b5f37

Browse files
committed
Fix documentation
Adjust code for the loaders change quotes
1 parent d6de4bc commit 84b5f37

File tree

6 files changed

+75
-20
lines changed

6 files changed

+75
-20
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ With composer simply
2121
then call the script you need
2222

2323
##Manually
24-
Clone this repository somewhere your your build plan can be accessed, composer install (required for the class loader only)
24+
Clone this repository somewhere your your build plan can be accessed, composer install is prefered but there is a non composer class loader which will be used if composer is not installed.
2525
Then call the script you need
2626

2727

@@ -40,7 +40,7 @@ exit code 0 and no output indicates success
4040

4141
php vendor/bin/phpunitDiffFilter /tmp/diff.txt report/coverage.xml 90
4242

43-
Will fail (exit status 1) if less than 90% of the code committed is covered by a test.
43+
Will fail (exit status 2) if less than 90% of the code committed is covered by a test.
4444
This requires phpunit to be run on the branch first!
4545

4646
##phpcs
@@ -51,7 +51,7 @@ All of the commands can read from stdin with placeholder `-`
5151

5252
phpcs can be run with any options you normally have for example `--standard=PSR2`
5353

54-
This will exit with code 1 if any of the new/edited code fails the code standards check. The output is kept so you can see what the offending lines are and what the error is.
54+
This will exit with code 2 if any of the new/edited code fails the code standards check. The output is kept so you can see what the offending lines are and what the error is.
5555

5656

5757
##phpmd
@@ -62,4 +62,4 @@ All of the commands can read from stdin with placeholder `-`
6262

6363
phpcs can be run with any options you normally have for example `cleancode,codesize,controversial`
6464

65-
This will exit with code 1 if any of the new/edited code fails the code standards check. The output is kept so you can see what the offending lines are and what the error is.
65+
This will exit with code 2 if any of the new/edited code fails the code standards check. The output is kept so you can see what the offending lines are and what the error is.

bin/phpcsDiffFilter

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,34 @@
11
#!/usr/bin/env php
22
<?php
3+
$locations = [
4+
__DIR__ . '/../vendor/autoload.php',
5+
__DIR__ . '/vendor/autoload.php',
6+
__DIR__ . '/../autoload.php'
7+
];
38

4-
foreach (array(__DIR__ . '/../../autoload.php', __DIR__ . '/../vendor/autoload.php', __DIR__ . '/vendor/autoload.php') as $file) {
9+
$found = false;
10+
11+
foreach ($locations as $file) {
512
if (file_exists($file)) {
613
require_once($file);
7-
14+
$found = true;
815
break;
916
}
1017
}
1118

19+
if (!$found) {
20+
error_log(
21+
"Can't find the autoload file," .
22+
"please make sure 'composer install' has been run"
23+
);
24+
25+
exit(1);
26+
}
27+
1228
if (!isset($argv[1], $argv[2])) {
13-
echo "Missing arguments, please call with diff and check file" . PHP_EOL;
29+
error_log(
30+
"Missing arguments, please call with diff and check file"
31+
);
1432
exit(1);
1533
}
1634

bin/phpmdDiffFilter

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,34 @@
11
#!/usr/bin/env php
22
<?php
3+
$locations = [
4+
__DIR__ . '/../vendor/autoload.php',
5+
__DIR__ . '/vendor/autoload.php',
6+
__DIR__ . '/../autoload.php'
7+
];
38

4-
foreach (array(__DIR__ . '/../../autoload.php', __DIR__ . '/../vendor/autoload.php', __DIR__ . '/vendor/autoload.php') as $file) {
9+
$found = false;
10+
11+
foreach ($locations as $file) {
512
if (file_exists($file)) {
613
require_once($file);
7-
14+
$found = true;
815
break;
916
}
1017
}
1118

19+
if (!$found) {
20+
error_log(
21+
"Can't find the autoload file," .
22+
"please make sure 'composer install' has been run"
23+
);
24+
25+
exit(1);
26+
}
27+
1228
if (!isset($argv[1], $argv[2])) {
13-
echo "Missing arguments, please call with diff and check file" . PHP_EOL;
29+
error_log(
30+
"Missing arguments, please call with diff and check file"
31+
);
1432
exit(1);
1533
}
1634

bin/phpunitDiffFilter

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,34 @@
11
#!/usr/bin/env php
22
<?php
3+
$locations = [
4+
__DIR__ . '/../vendor/autoload.php',
5+
__DIR__ . '/vendor/autoload.php',
6+
__DIR__ . '/../autoload.php'
7+
];
38

4-
foreach (array(__DIR__ . '/../../autoload.php', __DIR__ . '/../vendor/autoload.php', __DIR__ . '/vendor/autoload.php') as $file) {
9+
$found = false;
10+
11+
foreach ($locations as $file) {
512
if (file_exists($file)) {
613
require_once($file);
7-
14+
$found = true;
815
break;
916
}
1017
}
1118

19+
if (!$found) {
20+
error_log(
21+
"Can't find the autoload file," .
22+
"please make sure 'composer install' has been run"
23+
);
24+
25+
exit(1);
26+
}
27+
1228
if (!isset($argv[1], $argv[2])) {
13-
echo "Missing arguments, please call with diff and check file" . PHP_EOL;
29+
error_log(
30+
"Missing arguments, please call with diff and check file"
31+
);
1432
exit(1);
1533
}
1634

src/DiffFileLoader.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,17 @@ public function __construct($fileName)
2121
{
2222
$this->fileLocation = $fileName;
2323
$this->diff = new DiffFileState();
24+
2425
}
2526

2627
public function getChangedLines()
2728
{
28-
$handle = @fopen($this->fileLocation, "r");
29-
30-
if (!$handle) {
29+
if (!is_readable($this->fileLocation)) {
3130
throw new InvalidArgumentException("Can't read file");
3231
}
3332

33+
$handle = fopen($this->fileLocation, 'r');
34+
3435
while (($line = fgets($handle)) !== false) {
3536
// process the line read.
3637
$lineHandle = $this->getLineHandle($line);

tests/DiffFileLoadTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,26 @@ public function getResults()
2727
{
2828
return [
2929
'newFile' => [
30-
__DIR__ . "/fixtures/newFile.txt",
30+
__DIR__ . '/fixtures/newFile.txt',
3131
[
3232
'changedFile.php' => [1,2,3]
3333
]
3434
],
3535
'lineChange' => [
36-
__DIR__ . "/fixtures/change.txt",
36+
__DIR__ . '/fixtures/change.txt',
3737
[
3838
'changedFile.php' => [3]
3939
]
4040
],
4141
'multipleFiles' => [
42-
__DIR__ . "/fixtures/multiple.txt",
42+
__DIR__ . '/fixtures/multiple.txt',
4343
[
4444
'changedFile.php' => [3],
4545
'newFile.php' => [1,2,3]
4646
]
4747
],
4848
'removeFile' => [
49-
__DIR__ . "/fixtures/removeFile.txt",
49+
__DIR__ . '/fixtures/removeFile.txt',
5050
[]
5151
],
5252
];

0 commit comments

Comments
 (0)