Skip to content

Commit

Permalink
Merge ad131ff into d080ec3
Browse files Browse the repository at this point in the history
  • Loading branch information
bkrukowski committed Nov 21, 2019
2 parents d080ec3 + ad131ff commit d2b6178
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 32 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## [1.4.0] - ????-??-??

Output format of printed `Closure` has been changed. New format:

```
object(Closure) #3 {[
[name] => “{closure}”
[filename] => “(...)/var-dumper/examples/closure.php”
[startLine] => 18
[endLine] => 19
[use] => array(2) {[x] => 5, [y] => 6}
]}
```

## [1.3.0] - 2019-11-16

* Internal refactor, do not call `ob_*` functions
Expand Down Expand Up @@ -89,6 +104,7 @@ $reflectionProp->getValue($obj);

This version contains the same source code as [0.12.0].

[1.4.0]: https://github.com/awesomite/var-dumper/compare/v1.3.0...v1.4.0
[1.3.0]: https://github.com/awesomite/var-dumper/compare/v1.2.1...v1.3.0
[1.2.1]: https://github.com/awesomite/var-dumper/compare/v1.2.0...v1.2.1
[1.2.0]: https://github.com/awesomite/var-dumper/compare/v1.1.0...v1.2.0
Expand Down
27 changes: 13 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,16 @@ $dumper->dump($function);
```

```
object(Closure) #1 {[
$name => “{closure}”
$filename => “(...)/var-dumper/examples/closure.php”
$startLine => 7
$endLine => 8
$use =>
array(2) {
[firstName] => “Mary”
[lastName] => “Watson”
}
object(Closure) #3 {[
[name] => “{closure}”
[filename] => “(...)/var-dumper/examples/closure.php”
[startLine] => 7
[endLine] => 8
[use] =>
array(2) {
[firstName] => “Mary”
[lastName] => “Watson”
}
]}
```

Expand All @@ -171,11 +171,10 @@ use Awesomite\VarDumper\LightVarDumper;

$dumper = new LightVarDumper();
$dumper->dump(array(
\M_LOG2E,
\PHP_INT_MAX,
\M_PI,
M_LOG2E,
PHP_INT_MAX,
M_PI,
));

```

```
Expand Down
20 changes: 10 additions & 10 deletions examples/closure.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@
Output:
object(Closure) #1 {[
$name => “{closure}”
$filename => “(...)/var-dumper/examples/closure.php”
$startLine => 18
$endLine => 19
$use =>
array(2) {
[firstName] => “Mary”
[lastName] => “Watson”
}
object(Closure) #3 {[
[name] => “{closure}”
[filename] => “(...)/var-dumper/examples/closure.php”
[startLine] => 18
[endLine] => 19
[use] =>
array(2) {
[firstName] => “Mary”
[lastName] => “Watson”
}
]}
*/
6 changes: 5 additions & 1 deletion src/Subdumpers/ClosureDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ public function dump($closure)
$result = new Parts();
$result->appendPart($header);

$body = ObjectBigDumper::dumpProperties($this->decorateProperties($this->getProperties($closure)), $this->container);
$properties = array();
foreach ($this->decorateProperties($this->getProperties($closure)) as $property) {
$properties[$property->getName()] = $property->getValue();
}
$body = ArrayBigDumper::dumpBody($properties, $this->container);
$body->addIndent($this->container->getConfig()->getIndent());
$result->appendPart($body);

Expand Down
12 changes: 5 additions & 7 deletions tests/LightVarDumperProviders/ProviderDump.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,17 @@ private function getClosure()
$dump
= <<<'DUMP'
object(Closure) #%digit% {[
$name => “Awesomite\VarDumper\LightVarDumperProviders\{closure}”
$filename => “(...)/tests/LightVarDumperProviders/ProviderDump.php”
$startLine => %digit%
$endLine => %digit%
$closureScopeClass => “Awesomite\VarDumper\LightVarDumperProviders\ProviderDump”
[name] => “Awesomite\VarDumper\LightVarDumperProviders\{closure}”
[filename] => “(...)/tests/LightVarDumperProviders/ProviderDump.php”
[startLine] => %digit%
[endLine] => %digit%
[closureScopeClass] => “Awesomite\VarDumper\LightVarDumperProviders\ProviderDump”
]}
DUMP;

$replace = array(
'%digit%' => '[0-9]{1,}',
'%file%' => '.*',
'%any%' => '.*',
);
$regex = '#^' . \preg_quote($dump, '#') . '$#ms';
$regex = \str_replace(\array_keys($replace), \array_values($replace), $regex);
Expand Down

0 comments on commit d2b6178

Please sign in to comment.