Skip to content

Commit caca71b

Browse files
committed
typos
1 parent da7b860 commit caca71b

17 files changed

+55
-41
lines changed

src/Highlights/HtmlHighlight.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ public function __construct(
2828
private string $key
2929
) {
3030
$this->assertKey($key);
31-
$this->class = $this->palette()[$this->key]
32-
?? '';
31+
$this->class = $this->palette()[$this->key] ?? '';
3332
}
3433

3534
public function highlight(string $dump): string

src/Interfaces/ObjectReferencesInterface.php renamed to src/Interfaces/ObjectIdsInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* Describes the component in charge of holding object references.
2020
* @extends VectoredInterface<int>
2121
*/
22-
interface ObjectReferencesInterface extends VectoredInterface
22+
interface ObjectIdsInterface extends VectoredInterface
2323
{
2424
/**
2525
* @return array<int> $array

src/Interfaces/OutputInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function setUp(WriterInterface $writer, array $trace): void;
2929
/**
3030
* Ends the output.
3131
*/
32-
public function tearDown(): void;
32+
public function finalize(): void;
3333

3434
/**
3535
* Writes the caller file using the target formatter.
@@ -48,7 +48,7 @@ public function trace(): array;
4848
public function caller(): string;
4949

5050
/**
51-
* This method is executed before `tearDown()`.
51+
* This method is executed before `finalize()`.
5252
*/
5353
public function prepare(): void;
5454
}

src/Interfaces/VarDumperInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,5 @@ public function depth(): int;
110110
*/
111111
public function withProcess(): self;
112112

113-
public function objectReferences(): ObjectReferencesInterface;
113+
public function objectReferences(): ObjectIdsInterface;
114114
}

src/ObjectReferences.php renamed to src/ObjectIds.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
namespace Chevere\VarDump;
1515

1616
use Chevere\DataStructure\Traits\VectorTrait;
17-
use Chevere\VarDump\Interfaces\ObjectReferencesInterface;
17+
use Chevere\VarDump\Interfaces\ObjectIdsInterface;
1818

19-
final class ObjectReferences implements ObjectReferencesInterface
19+
final class ObjectIds implements ObjectIdsInterface
2020
{
2121
use VectorTrait;
2222

src/Outputs/ConsoleOutput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ final class ConsoleOutput extends Output
2020
{
2121
private string $outputHr;
2222

23-
public function tearDown(): void
23+
public function finalize(): void
2424
{
2525
$this->writer()->write("\n" . $this->outputHr . "\n");
2626
}

src/Outputs/HtmlOutput.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ final class HtmlOutput extends Output
127127

128128
private static bool $isStyleWritten = false;
129129

130-
public function tearDown(): void
130+
public function finalize(): void
131131
{
132132
$this->writer()->write('</pre>');
133133
if ($this->hasHeader) {
@@ -160,14 +160,16 @@ public function prepare(): void
160160
public function writeCallerFile(FormatInterface $format): void
161161
{
162162
$highlight = $this->getCallerFile($format);
163-
if ($highlight === '') {
164-
return;
165-
}
166163
$this->writer()->write(
167164
<<<HTML
168165
{$highlight}
169166
170167
HTML
171168
);
172169
}
170+
171+
public function isStyleWritten(): bool
172+
{
173+
return self::$isStyleWritten;
174+
}
173175
}

src/Outputs/Output.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use Chevere\VarDump\Interfaces\FormatInterface;
1717
use Chevere\VarDump\Interfaces\OutputInterface;
18+
use Chevere\VarDump\Interfaces\VarDumperInterface;
1819
use Chevere\Writer\Interfaces\WriterInterface;
1920

2021
abstract class Output implements OutputInterface
@@ -45,9 +46,6 @@ final public function setUp(WriterInterface $writer, array $trace): void
4546
public function writeCallerFile(FormatInterface $format): void
4647
{
4748
$highlight = $this->getCallerFile($format);
48-
if ($highlight === '') {
49-
return;
50-
}
5149
$this->writer()->write(
5250
<<<PLAIN
5351
@@ -70,12 +68,17 @@ final public function caller(): string
7068
protected function getCallerFile(FormatInterface $format): string
7169
{
7270
$item = $this->trace[0] ?? null;
71+
// @codeCoverageIgnoreStart
7372
if (! isset($item['file'])) {
74-
return '';
73+
return '@';
7574
}
75+
// @codeCoverageIgnoreEnd
7676
$fileLine = $item['file'] . ':' . $item['line'];
7777

78-
return $format->highlight('_file', $fileLine);
78+
return $format->highlight(
79+
VarDumperInterface::FILE,
80+
$fileLine
81+
);
7982
}
8083

8184
final protected function writer(): WriterInterface

src/Outputs/PlainOutput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ final class PlainOutput extends Output
1717
{
1818
private string $outputHr = '------------------------------------------------------------';
1919

20-
public function tearDown(): void
20+
public function finalize(): void
2121
{
2222
$this->writer()->write("\n" . $this->outputHr . "\n");
2323
}

src/Processors/ObjectProcessor.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,8 @@ private function getProperties(
150150
}
151151
$isUnset = false;
152152
if (! $property->isInitialized($object)) {
153-
if ($property->hasDefaultValue()) {
154-
$value = $property->getDefaultValue();
155-
} else {
156-
$value = '';
157-
$isUnset = true;
158-
}
153+
$value = '';
154+
$isUnset = true;
159155
} else {
160156
$value = $property->getValue($this->var);
161157
}

src/VarDumper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Chevere\DataStructure\Vector;
1818
use Chevere\Parameter\Interfaces\TypeInterface;
1919
use Chevere\VarDump\Interfaces\FormatInterface;
20-
use Chevere\VarDump\Interfaces\ObjectReferencesInterface;
20+
use Chevere\VarDump\Interfaces\ObjectIdsInterface;
2121
use Chevere\VarDump\Interfaces\ProcessorInterface;
2222
use Chevere\VarDump\Interfaces\VarDumpableInterface;
2323
use Chevere\VarDump\Interfaces\VarDumperInterface;
@@ -40,12 +40,12 @@ public function __construct(
4040
private WriterInterface $writer,
4141
private FormatInterface $format,
4242
private VarDumpableInterface $dumpable,
43-
private ObjectReferencesInterface $objectReferences,
43+
private ObjectIdsInterface $objectReferences,
4444
) {
4545
$this->knownObjectsId = new Vector();
4646
}
4747

48-
public function objectReferences(): ObjectReferencesInterface
48+
public function objectReferences(): ObjectIdsInterface
4949
{
5050
return $this->objectReferences;
5151
}

src/VarOutput.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
final class VarOutput implements VarOutputInterface
2222
{
23-
private ObjectReferences $objectReferences;
23+
private ObjectIds $objectReferences;
2424

2525
/**
2626
* @param array<array<string, mixed>> $trace
@@ -38,14 +38,14 @@ public function process(OutputInterface $output, mixed ...$variables): void
3838
$output->prepare();
3939
$output->writeCallerFile($this->format);
4040
$this->handleArgs(...$variables);
41-
$output->tearDown();
41+
$output->finalize();
4242
}
4343

4444
private function handleArgs(mixed ...$variables): void
4545
{
4646
$aux = 0;
4747
foreach ($variables as $name => $value) {
48-
$this->objectReferences = new ObjectReferences();
48+
$this->objectReferences = new ObjectIds();
4949
$aux++;
5050
if (is_int($name)) {
5151
$name = $aux;

tests/ObjectReferencesTest.php renamed to tests/ObjectIdsTest.php

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

1414
namespace Chevere\Tests;
1515

16-
use Chevere\VarDump\ObjectReferences;
16+
use Chevere\VarDump\ObjectIds;
1717
use PHPUnit\Framework\TestCase;
1818

19-
final class ObjectReferencesTest extends TestCase
19+
final class ObjectIdsTest extends TestCase
2020
{
2121
public function testToArray(): void
2222
{
23-
$objectReferences = new ObjectReferences();
23+
$objectReferences = new ObjectIds();
2424
$this->assertSame([], $objectReferences->toArray());
2525
$objectReferences->push(1);
2626
$this->assertSame([1], $objectReferences->toArray());
2727
}
2828

2929
public function testPushHas(): void
3030
{
31-
$objectReferences = new ObjectReferences();
31+
$objectReferences = new ObjectIds();
3232
$objectReferences->push(1);
3333
$this->assertTrue($objectReferences->has(1));
3434
$objectReferences->push(1);

tests/Processors/ObjectProcessorTest.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ public function testObjectProperty(): void
7575
$className = $object::class;
7676
$id = strval(spl_object_id($object));
7777
$pubId = strval(spl_object_id($object->public));
78-
$varDumper = $this->getVarDumper($object);
7978
$dump = <<<EOT
8079
{$className}#{$id}
8180
public code int 101 (length=3)
@@ -90,10 +89,22 @@ public function testObjectProperty(): void
9089
private circularReference uninitialized
9190
private deep uninitialized
9291
EOT;
92+
$varDumper = $this->getVarDumper($object);
9393
$this->assertSame(
9494
$dump,
9595
$varDumper->writer()->__toString()
9696
);
97+
$dump = <<<EOT
98+
{$className}#{$id}
99+
public code int 102 (length=3)
100+
public public stdClass#{$pubId}
101+
EOT;
102+
$object->code = 102;
103+
$varDumper = $this->getVarDumper($object);
104+
$this->assertStringStartsWith(
105+
$dump,
106+
$varDumper->writer()->__toString()
107+
);
97108
}
98109

99110
public function testCircularReferences(): void

tests/Traits/VarDumperTrait.php

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

1616
use Chevere\VarDump\Formats\PlainFormat;
1717
use Chevere\VarDump\Interfaces\VarDumperInterface;
18-
use Chevere\VarDump\ObjectReferences;
18+
use Chevere\VarDump\ObjectIds;
1919
use Chevere\VarDump\VarDumpable;
2020
use Chevere\VarDump\VarDumper;
2121
use Chevere\Writer\StreamWriter;
@@ -29,7 +29,7 @@ private function getVarDumper($var): VarDumperInterface
2929
new StreamWriter(streamTemp()),
3030
new PlainFormat(),
3131
new VarDumpable($var),
32-
new ObjectReferences()
32+
new ObjectIds()
3333
))->withProcess();
3434
}
3535

tests/VarDumperTest.php

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

1616
use Chevere\VarDump\Formats\PlainFormat;
1717
use Chevere\VarDump\Interfaces\VarDumperInterface;
18-
use Chevere\VarDump\ObjectReferences;
18+
use Chevere\VarDump\ObjectIds;
1919
use Chevere\VarDump\VarDumpable;
2020
use Chevere\VarDump\VarDumper;
2121
use Chevere\Writer\StreamWriter;
@@ -38,7 +38,7 @@ public function testConstruct(): void
3838
writer: $writer,
3939
format: $format,
4040
dumpable: $dumpable,
41-
objectReferences: new ObjectReferences()
41+
objectReferences: new ObjectIds()
4242
);
4343
$this->assertSame($writer, $varDumper->writer());
4444
$this->assertSame($format, $varDumper->format());

tests/VarOutputTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,12 @@ public function testHtmlOutput(): void
7979
trace: $trace,
8080
format: new HtmlFormat(),
8181
);
82-
$varOutput->process(new HtmlOutput(), name: null);
82+
$htmlOutput = new HtmlOutput();
83+
$this->assertFalse($htmlOutput->isStyleWritten());
84+
$varOutput->process($htmlOutput, name: null);
8385
$parsed = $this->getParsed($trace, 'output-html');
8486
$this->assertSame($parsed, $writer->__toString());
87+
$this->assertTrue($htmlOutput->isStyleWritten());
8588
}
8689

8790
private function getParsed(array $trace, string $name): string

0 commit comments

Comments
 (0)