Skip to content

Commit a7cb6bc

Browse files
authored
php-file-iterator-2 (#56)
Update dependencies - drop support for php < 7.1 because of php-file-iterator - drop support for hhvm - update php-file-iterator to 2.0.1 - update phpunit to 7.3.1 - add kherge/box 2.7.5 for packaging phar - add composer scripts to ease development
1 parent 1489117 commit a7cb6bc

File tree

11 files changed

+66
-72
lines changed

11 files changed

+66
-72
lines changed

.travis.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
dist: trusty
22
language: php
33
php:
4-
- 5.6
5-
- 7.0
64
- 7.1
75
- 7.2
8-
- hhvm
96
before_script:
107
- composer install
118
script:

box.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@
1616
"name": "*.php",
1717
"path": [
1818
"composer",
19+
"herrera-io/json",
20+
"herrera-io/phar-update",
1921
"monolog/monolog",
22+
"myclabs/deep-copy",
23+
"phpseclib/phpseclib",
2024
"phpunit/php-file-iterator",
25+
"psr/log",
2126
"symfony/console",
2227
"symfony/polyfill-mbstring",
23-
"myclabs/deep-copy",
24-
"psr/log"
28+
"symfony/polyfill-ctype"
2529
],
2630
"notPath": [
2731
"Tests",

composer.json

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,40 @@
1111
}
1212
],
1313
"require": {
14-
"phpunit/php-file-iterator": "~1.4",
14+
"php": "^7.1",
15+
"phpunit/php-file-iterator": "~2.0",
1516
"monolog/monolog": "~1.7",
1617
"symfony/console": "~2.1|~3.0|~4.0"
1718
},
1819
"require-dev": {
19-
"phpunit/phpunit": "5.7.*",
20-
"phpmd/phpmd": "1.5.*",
21-
"squizlabs/php_codesniffer": "1.*",
20+
"phpunit/phpunit": "~7.3",
21+
"phpmd/phpmd": "1.5.*|~2.6",
22+
"squizlabs/php_codesniffer": "1.*|~3.3",
2223
"phploc/phploc": "*",
23-
"sebastian/phpcpd": "*"
24+
"sebastian/phpcpd": "*",
25+
"kherge/box": "~2.7"
2426
},
2527
"autoload": {
2628
"psr-0": {"PHPCodeBrowser\\": "src/"}
2729
},
28-
"bin": [ "bin/phpcb" ]
30+
"bin": [ "bin/phpcb" ],
31+
"scripts": {
32+
"demo": [
33+
"@clean",
34+
"php -c php.ini vendor/bin/phpunit -c phpunit.xml.dist",
35+
"phpcpd -q --log-pmd=build/logs/pmd-cpd.xml src || true",
36+
"phpmd src xml cleancode,codesize,controversial,design,naming,unusedcode --reportfile build/logs/pmd.xml || true",
37+
"phpcs -q --standard=PSR2 --report-checkstyle=build/logs/checkstyle.xml src || true",
38+
"@browser"
39+
],
40+
"nope": [
41+
"@clean",
42+
"pdepend --quiet --dependency-xml=build/logs/pdepend.xml src || true",
43+
"phploc -q --log-xml=build/logs/phploc.xml src || true",
44+
"@browser"
45+
],
46+
"clean": "rm -rf build/logs/* build/code-browser",
47+
"browser": "bin/phpcb -l build/logs -o build/code-browser -s src",
48+
"phar": "php -d phar.readonly=0 vendor/bin/box build"
49+
}
2950
}

phpunit.xml.dist

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
convertWarningsToExceptions="true"
99
processIsolation="false"
1010
stopOnFailure="false"
11-
syntaxCheck="false"
1211
bootstrap="./vendor/autoload.php"
1312
>
1413
<testsuites>
@@ -26,28 +25,14 @@
2625
</whitelist>
2726
</filter>
2827

29-
<!--<filter>-->
30-
<!--<whitelist>-->
31-
<!--<directory suffix='.php'>src</directory>-->
32-
<!--</whitelist>-->
33-
<!--</filter>-->
28+
<logging>
29+
<!--<log type="coverage-html" target="build/coverage" lowUpperBound="35" highLowerBound="70"/>-->
30+
<log type="coverage-clover" target="build/logs/clover.xml"/>
31+
<log type="junit" target="build/logs/junit.xml"/>
32+
</logging>
3433

35-
<logging>
36-
<log type="coverage-html" target="build/coverage" title="PHP_CodeBrowser"
37-
charset="UTF-8" yui="true" highlight="true"
38-
lowUpperBound="35" highLowerBound="70"/>
39-
<log type="coverage-clover" target="build/logs/clover.xml"/>
40-
<log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="false"/>
41-
</logging>
34+
<php>
35+
<ini name="error_reporting" value="E_ALL"/>
36+
</php>
4237

43-
<php>
44-
<!--TODO: Remove this when E_STRICT stops crashing the tests -->
45-
<!--<ini name="error_reporting" value="E_ALL"/>-->
46-
</php>
47-
48-
<filter>
49-
<whitelist>
50-
<directory>src</directory>
51-
</whitelist>
52-
</filter>
5338
</phpunit>

src/PHPCodeBrowser/CLIController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050
namespace PHPCodeBrowser;
5151

52-
use File_Iterator_Factory;
52+
use SebastianBergmann\FileIterator\Factory as FileIteratorFactory;
5353
use Monolog\Logger;
5454
use PHPCodeBrowser\Helper\IOHelper;
5555
use PHPCodeBrowser\View\ViewReview;
@@ -273,7 +273,7 @@ public function run()
273273
if (isset($this->projectSource)) {
274274
foreach ($this->projectSource as $source) {
275275
if (is_dir($source)) {
276-
$factory = new File_Iterator_Factory;
276+
$factory = new FileIteratorFactory;
277277

278278
$suffixes = array_merge(
279279
$this->phpSuffixes,

src/PHPCodeBrowser/IssueXml.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949

5050
namespace PHPCodeBrowser;
5151

52+
use SebastianBergmann\FileIterator\Factory as FileIteratorFactory;
5253
use \DOMDocument;
5354
use \DOMNode;
5455
use \DOMNodeList;
@@ -120,7 +121,7 @@ public function __construct($version = '1.0', $encoding = 'UTF-8')
120121
*/
121122
public function addDirectory($directory)
122123
{
123-
$factory = new \File_Iterator_Factory();
124+
$factory = new FileIteratorFactory;
124125
$iterator = $factory->getFileIterator($directory, 'xml');
125126

126127
foreach ($iterator as $current) {

src/PHPCodeBrowser/Tests/AbstractTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
* @link http://www.phpunit.de/
6262
* @since Class available since 0.1.0
6363
*/
64-
class AbstractTestCase extends \PHPUnit_Framework_TestCase
64+
class AbstractTestCase extends \PHPUnit\Framework\TestCase
6565
{
6666
/**
6767
* Merged cruisecontrol XML error file

src/PHPCodeBrowser/Tests/ApplicationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Class ApplicationTest
99
* @package PHPCodeBrowser\Tests
1010
*/
11-
class ApplicationTest extends \PHPUnit_Framework_TestCase
11+
class ApplicationTest extends \PHPUnit\Framework\TestCase
1212
{
1313
/**
1414
* @var Application

src/PHPCodeBrowser/Tests/FileTest.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class FileTest extends AbstractTestCase
8585
*/
8686
public function __construct()
8787
{
88+
parent::__construct();
8889
$this->issues = array(
8990
new Issue('/some/file/name.php', 39, 39, 'Checkstyle', 'm3', 'error'),
9091
new Issue('/some/file/name.php', 50, 52, 'Checkstyle', 'm4', 'warning'),
@@ -138,13 +139,10 @@ public function testIssueAdding()
138139
*/
139140
public function testAddingIssueToWrongFile()
140141
{
142+
$this->expectException(\InvalidArgumentException::class);
143+
141144
$issue = new Issue('/the/wrong/file/name.php', 39, 39, 'Checkstyle', 'm3', 'error');
142-
try {
143-
$this->file->addIssue($issue);
144-
$this->fail();
145-
} catch (\InvalidArgumentException $e) {
146-
// Expected
147-
}
145+
$this->file->addIssue($issue);
148146
}
149147

150148

@@ -244,12 +242,9 @@ public function testMergeWith()
244242
*/
245243
public function testMergeWithDifferentFile()
246244
{
247-
try {
248-
$this->file->mergeWith(new File('/the/wrong/file/name.php'));
249-
$this->fail();
250-
} catch (\InvalidArgumentException $e) {
251-
// Expected
252-
}
245+
$this->expectException(\InvalidArgumentException::class);
246+
247+
$this->file->mergeWith(new File('/the/wrong/file/name.php'));
253248
}
254249

255250
/**

src/PHPCodeBrowser/Tests/Helper/IOHelperTest.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -208,16 +208,13 @@ public function testCopyFile()
208208
*/
209209
public function testLoadFileWithNonexistentFile()
210210
{
211+
$this->expectException(\Exception::class);
212+
211213
$sourceFile = PHPCB_TEST_OUTPUT . '/doesNotExist';
212214
if (file_exists($sourceFile)) {
213215
unlink(PHPCB_TEST_OUTPUT . '/doesNotExist');
214216
}
215-
try {
216-
$this->ioHelper->loadFile($sourceFile);
217-
$this->fail();
218-
} catch (\Exception $e) {
219-
// expected
220-
}
217+
$this->ioHelper->loadFile($sourceFile);
221218
}
222219

223220

@@ -228,19 +225,16 @@ public function testLoadFileWithNonexistentFile()
228225
*/
229226
public function testCopyFileNonExisting()
230227
{
228+
$this->expectException(\Exception::class);
229+
231230
$file = PHPCB_TEST_OUTPUT . '/tmpfile';
232231
$dstDir = PHPCB_TEST_OUTPUT . '/tmpdir';
233232

234233
if (file_exists($file)) {
235234
unlink($file);
236235
}
237236

238-
try {
239-
$this->ioHelper->copyFile($file, $dstDir);
240-
} catch (\Exception $e) {
241-
return;
242-
}
243-
$this->fail('Expected exception was not thrown.');
237+
$this->ioHelper->copyFile($file, $dstDir);
244238
}
245239

246240
/**

0 commit comments

Comments
 (0)