Skip to content

Commit 7039cf9

Browse files
committed
chevere 4
1 parent 35c08c8 commit 7039cf9

13 files changed

+36
-29
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
}
1818
],
1919
"require": {
20-
"chevere/chevere": "^4.0.x-dev"
20+
"chevere/chevere": "^4.0.x-dev",
21+
"kevinlebrun/colors.php": "^1.0"
2122
},
2223
"require-dev": {
2324
"phpstan/phpstan": "^1.9",

src/Highlights/Traits/AssertKeyTrait.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
namespace Chevere\VarDump\Highlights\Traits;
1515

16-
use Chevere\Throwable\Exceptions\OutOfRangeException;
16+
use OutOfRangeException;
1717
use function Chevere\Message\message;
1818

1919
trait AssertKeyTrait
@@ -28,9 +28,11 @@ protected function assertKey(string $key): void
2828
{
2929
if (! array_key_exists($key, $this->palette())) {
3030
throw new OutOfRangeException(
31-
message('Invalid key %keyName%, expecting one of the following palette keys: %keys%')
32-
->withCode('%keyName%', $key)
33-
->withCode('%keys%', implode(', ', array_keys($this->palette())))
31+
(string) message(
32+
'Invalid key `%keyName%`, expecting one of the following palette keys: `%keys%`',
33+
keyName: $key,
34+
keys: implode(', ', array_keys($this->palette())),
35+
)
3436
);
3537
}
3638
}

src/Interfaces/HighlightInterface.php

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

1414
namespace Chevere\VarDump\Interfaces;
1515

16-
use Chevere\Throwable\Exceptions\OutOfRangeException;
1716
use Chevere\Type\Interfaces\TypeInterface;
1817

1918
/**
@@ -43,7 +42,6 @@ interface HighlightInterface
4342
* Constructs a highlight instance specified by `$key`.
4443
*
4544
* @see `VarDumpHighlightInterface::KEYS`
46-
* @throws OutOfRangeException
4745
*/
4846
public function __construct(string $key);
4947

src/Processors/Traits/ProcessorTrait.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
namespace Chevere\VarDump\Processors\Traits;
1515

16-
use Chevere\Throwable\Exceptions\InvalidArgumentException;
1716
use Chevere\Type\Type;
1817
use Chevere\VarDump\Interfaces\VarDumperInterface;
18+
use InvalidArgumentException;
1919
use function Chevere\Message\message;
2020

2121
trait ProcessorTrait
@@ -66,11 +66,13 @@ private function assertType(): void
6666
$type = new Type($this->type());
6767
if (! $type->validate($this->varDumper->dumpable()->var())) {
6868
throw new InvalidArgumentException(
69-
message('Instance of %className% expects a type %expected% for the return value of %method%, type %provided% returned')
70-
->withCode('%className%', static::class)
71-
->withCode('%expected%', $this->type())
72-
->withCode('%method%', $this->varDumper::class . '::var()')
73-
->withCode('%provided%', get_debug_type($this->varDumper->dumpable()->var()))
69+
(string) message(
70+
'Instance of `%className%` expects a type `%expected%` for the return value of `%method%`, type `%provided%` returned',
71+
className: static::class,
72+
expected: $this->type(),
73+
method: $this->varDumper::class . '::var()',
74+
provided: get_debug_type($this->varDumper->dumpable()->var()),
75+
)
7476
);
7577
}
7678
}

src/VarDumpInstance.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
namespace Chevere\VarDump;
1515

16-
use Chevere\Throwable\Exceptions\LogicException;
1716
use Chevere\VarDump\Interfaces\VarDumpInterface;
17+
use LogicException;
1818
use function Chevere\Message\message;
1919

2020
final class VarDumpInstance
@@ -30,7 +30,7 @@ public static function get(): VarDumpInterface
3030
{
3131
if (! isset(self::$instance)) {
3232
throw new LogicException(
33-
message('No VarDump instance present')
33+
(string) message('No instance')
3434
);
3535
}
3636

src/VarDumpable.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313

1414
namespace Chevere\VarDump;
1515

16-
use Chevere\Throwable\Exceptions\LogicException;
1716
use Chevere\VarDump\Interfaces\ProcessorInterface;
1817
use Chevere\VarDump\Interfaces\VarDumpableInterface;
1918
use Chevere\VarDump\Interfaces\VarDumperInterface;
19+
use LogicException;
2020
use function Chevere\Message\message;
2121
use function Chevere\Type\getType;
2222

@@ -57,15 +57,19 @@ private function assertSetProcessorName(): void
5757
$processorName = VarDumperInterface::PROCESSORS[$this->type] ?? null;
5858
if (! isset($processorName)) {
5959
throw new LogicException(
60-
message('No processor for variable of type %type%')
61-
->withCode('%type%', $this->type)
60+
(string) message(
61+
'No processor for variable of type `%type%`',
62+
type: $this->type
63+
)
6264
);
6365
}
6466
if (! is_subclass_of($processorName, ProcessorInterface::class, true)) {
6567
throw new LogicException(
66-
message('Processor %processorName% must implement the %interfaceName% interface')
67-
->withCode('%processorName%', $processorName)
68-
->withCode('%interfaceName%', ProcessorInterface::class)
68+
(string) message(
69+
'Processor `%processorName%` must implement the `%interfaceName%` interface',
70+
processorName: $processorName,
71+
interfaceName: ProcessorInterface::class,
72+
)
6973
);
7074
}
7175
$this->processorName = $processorName;

src/functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
// @codeCoverageIgnoreStart
1515

1616
namespace Chevere\VarDump {
17-
use Chevere\Throwable\Exceptions\LogicException;
1817
use Chevere\VarDump\Formats\ConsoleFormat;
1918
use Chevere\VarDump\Formats\HtmlFormat;
2019
use Chevere\VarDump\Formats\PlainFormat;
@@ -26,6 +25,7 @@
2625
use Chevere\Writer\StreamWriter;
2726
use Chevere\Writer\Writers;
2827
use Chevere\Writer\WritersInstance;
28+
use LogicException;
2929
use function Chevere\Writer\streamFor;
3030

3131
function varDumpPlain(): VarDumpInterface

tests/Highlights/ConsoleHighlightTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
namespace Chevere\Tests\Highlights;
1515

1616
use Chevere\String\StringModify;
17-
use Chevere\Throwable\Exceptions\OutOfRangeException;
1817
use Chevere\Type\Interfaces\TypeInterface;
1918
use Chevere\VarDump\Highlights\ConsoleHighlight;
2019
use Chevere\VarDump\Interfaces\HighlightInterface;
2120
use Chevere\VarDump\Interfaces\VarDumperInterface;
2221
use Colors\Color;
22+
use OutOfRangeException;
2323
use PHPUnit\Framework\TestCase;
2424

2525
final class ConsoleHighlightTest extends TestCase

tests/Highlights/HtmlHighlightTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
namespace Chevere\Tests\Highlights;
1515

16-
use Chevere\Throwable\Exceptions\OutOfRangeException;
1716
use Chevere\VarDump\Highlights\HtmlHighlight;
1817
use Chevere\VarDump\Interfaces\HighlightInterface;
18+
use OutOfRangeException;
1919
use PHPUnit\Framework\TestCase;
2020

2121
final class HtmlHighlightTest extends TestCase

tests/Processors/ArrayProcessorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function testInvalidArgument(): void
2727
{
2828
$this->expectException(InvalidArgumentException::class);
2929
$this->expectExceptionMessage(
30-
'type array for the return value of ' . VarDumper::class . '::var()'
30+
'type `array` for the return value of `' . VarDumper::class . '::var()`'
3131
);
3232
new ArrayProcessor($this->getVarDumper(null));
3333
}

tests/Processors/ObjectProcessorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
use Chevere\Tests\src\DummyClass;
1717
use Chevere\Tests\Traits\VarDumperTrait;
18-
use Chevere\Throwable\Exceptions\InvalidArgumentException;
1918
use Chevere\VarDump\Processors\ObjectProcessor;
19+
use InvalidArgumentException;
2020
use PHPUnit\Framework\TestCase;
2121
use stdClass;
2222

tests/Processors/StringProcessorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
namespace Chevere\Tests\Processors;
1515

1616
use Chevere\Tests\Traits\VarDumperTrait;
17-
use Chevere\Throwable\Exceptions\InvalidArgumentException;
1817
use Chevere\VarDump\Processors\StringProcessor;
18+
use InvalidArgumentException;
1919
use PHPUnit\Framework\TestCase;
2020

2121
final class StringProcessorTest extends TestCase

tests/VarDumpInstanceTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313

1414
namespace Chevere\Tests;
1515

16-
use Chevere\Throwable\Exceptions\LogicException;
17-
use function Chevere\VarDump\varDumpConsole;
1816
use Chevere\VarDump\VarDumpInstance;
17+
use LogicException;
1918
use PHPUnit\Framework\TestCase;
19+
use function Chevere\VarDump\varDumpConsole;
2020

2121
final class VarDumpInstanceTest extends TestCase
2222
{

0 commit comments

Comments
 (0)