Skip to content

Commit 5476497

Browse files
Cleanup
1 parent 381ae36 commit 5476497

File tree

4 files changed

+43
-9
lines changed

4 files changed

+43
-9
lines changed

src/Differ.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,27 @@ final class Differ
2525

2626
/**
2727
* @param DiffOutputBuilderInterface $outputBuilder
28+
*
29+
* @throws InvalidArgumentException
2830
*/
2931
public function __construct($outputBuilder = null)
3032
{
3133
if ($outputBuilder instanceof DiffOutputBuilderInterface) {
3234
$this->outputBuilder = $outputBuilder;
3335
} elseif (null === $outputBuilder) {
34-
$this->outputBuilder = new UnifiedDiffOutputBuilder();
36+
$this->outputBuilder = new UnifiedDiffOutputBuilder;
3537
} elseif (\is_string($outputBuilder)) {
3638
// PHPUnit 6.1.4, 6.2.0, 6.2.1, 6.2.2, and 6.2.3 support
37-
// @ see https://github.com/sebastianbergmann/phpunit/issues/2734#issuecomment-314514056
38-
// @ deprecated
39+
// @see https://github.com/sebastianbergmann/phpunit/issues/2734#issuecomment-314514056
40+
// @deprecated
3941
$this->outputBuilder = new UnifiedDiffOutputBuilder($outputBuilder);
4042
} else {
41-
throw new \InvalidArgumentException(\sprintf(
42-
'Expected builder to be an instance of DiffOutputBuilderInterface, <null> or a string, got %s.',
43-
\is_object($outputBuilder) ? 'instance of "' . \get_class($outputBuilder) . '"' : \gettype($outputBuilder) . ' "' . $outputBuilder . '"'
44-
));
43+
throw new InvalidArgumentException(
44+
\sprintf(
45+
'Expected builder to be an instance of DiffOutputBuilderInterface, <null> or a string, got %s.',
46+
\is_object($outputBuilder) ? 'instance of "' . \get_class($outputBuilder) . '"' : \gettype($outputBuilder) . ' "' . $outputBuilder . '"'
47+
)
48+
);
4549
}
4650
}
4751

src/Exception/Exception.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of sebastian/diff.
4+
*
5+
* (c) Sebastian Bergmann <sebastian@phpunit.de>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
11+
namespace SebastianBergmann\Diff;
12+
13+
interface Exception
14+
{
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of sebastian/diff.
4+
*
5+
* (c) Sebastian Bergmann <sebastian@phpunit.de>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
11+
namespace SebastianBergmann\Diff;
12+
13+
class InvalidArgumentException extends \InvalidArgumentException implements Exception
14+
{
15+
}

tests/DifferTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,15 +1028,15 @@ public function testConstructorString()
10281028

10291029
public function testConstructorInvalidArgInt()
10301030
{
1031-
$this->expectException(\InvalidArgumentException::class);
1031+
$this->expectException(InvalidArgumentException::class);
10321032
$this->expectExceptionMessageRegExp('/^Expected builder to be an instance of DiffOutputBuilderInterface, <null> or a string, got integer "1"\.$/');
10331033

10341034
new Differ(1);
10351035
}
10361036

10371037
public function testConstructorInvalidArgObject()
10381038
{
1039-
$this->expectException(\InvalidArgumentException::class);
1039+
$this->expectException(InvalidArgumentException::class);
10401040
$this->expectExceptionMessageRegExp('/^Expected builder to be an instance of DiffOutputBuilderInterface, <null> or a string, got instance of "SplFileInfo"\.$/');
10411041

10421042
new Differ(new \SplFileInfo(__FILE__));

0 commit comments

Comments
 (0)