-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
44 changed files
with
1,380 additions
and
348 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the awesomite/var-dumper package. | ||
* | ||
* (c) Bartłomiej Krukowski <bartlomiej@krukowski.me> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use Awesomite\VarDumper\LightVarDumper; | ||
|
||
require __DIR__ . DIRECTORY_SEPARATOR . 'init.php'; | ||
|
||
global $argc, $argv; | ||
$function = function ($a, $b) use ($argc, $argv) { | ||
}; | ||
|
||
$dumper = new LightVarDumper(); | ||
$dumper->dump($function); | ||
|
||
/* | ||
Output: | ||
object(Closure) #3 {[ | ||
$name => “{closure}” | ||
$filename => “(...)/examples/closure.php” | ||
$startLine => 17 | ||
$endLine => 18 | ||
$use => | ||
array(2) { | ||
[argc] => 1 | ||
[argv] => array(1) {“examples/closure.php”} | ||
} | ||
]} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the awesomite/var-dumper package. | ||
* | ||
* (c) Bartłomiej Krukowski <bartlomiej@krukowski.me> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use Awesomite\VarDumper\LightVarDumper; | ||
|
||
require __DIR__ . DIRECTORY_SEPARATOR . 'init.php'; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
class DivideByZeroException extends \Exception | ||
{ | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
class Divider | ||
{ | ||
public function divide($a, $b) | ||
{ | ||
if (0 === $b) { | ||
throw new DivideByZeroException('Cannot divide by zero'); | ||
} | ||
|
||
return $a/$b; | ||
} | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
class Controller | ||
{ | ||
public static function execute($class, $method, ...$params) | ||
{ | ||
(new $class())->$method(...$params); | ||
} | ||
} | ||
|
||
try { | ||
Controller::execute(Divider::class, 'divide', 10, 0); | ||
} catch (\Exception $exception) { | ||
$dumper = new LightVarDumper(); | ||
$dumper->dump($exception); | ||
} | ||
|
||
/* | ||
Output: | ||
object(DivideByZeroException) #2 {[ | ||
[message] => “Cannot divide by zero” | ||
[code] => 0 | ||
[file] => “(...)/examples/exception-variadic.php:31” | ||
[previous] => NULL | ||
[trace] => | ||
1. (...)/examples/exception-variadic.php:45 Divider->divide( | ||
a: 10 | ||
b: 0 | ||
) | ||
2. (...)/examples/exception-variadic.php:50 Controller::execute( | ||
class: “Divider” | ||
method: “divide” | ||
params: array(2) {10, 0} | ||
) | ||
]} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the awesomite/var-dumper package. | ||
* | ||
* (c) Bartłomiej Krukowski <bartlomiej@krukowski.me> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use Awesomite\VarDumper\LightVarDumper; | ||
|
||
require __DIR__ . DIRECTORY_SEPARATOR . 'init.php'; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
class DivideByZeroException extends \Exception | ||
{ | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
class Divider | ||
{ | ||
public function divide($a, $b) | ||
{ | ||
if (0 === $b) { | ||
throw new DivideByZeroException('Cannot divide by zero'); | ||
} | ||
|
||
return $a/$b; | ||
} | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
class Calculator | ||
{ | ||
public static function execute($action, $numberA, $numberB) | ||
{ | ||
if ('divide' == $action) { | ||
$divider = new Divider(); | ||
|
||
return $divider->divide($numberA, $numberB); | ||
} | ||
} | ||
} | ||
|
||
try { | ||
$calculator = new Calculator(); | ||
$calculator->execute('divide', 5, 0); | ||
} catch (\Exception $exception) { | ||
$dumper = new LightVarDumper(); | ||
$dumper->dump($exception); | ||
} | ||
|
||
/* | ||
Output: | ||
object(DivideByZeroException) #4 {[ | ||
[message] => “Cannot divide by zero” | ||
[code] => 0 | ||
[file] => “(...)/examples/exception.php:31” | ||
[previous] => NULL | ||
[trace] => | ||
1. (...)/examples/exception.php:48 Divider->divide( | ||
a: 5 | ||
b: 0 | ||
) | ||
2. (...)/examples/exception.php:55 Calculator::execute( | ||
action: “divide” | ||
numberA: 5 | ||
numberB: 0 | ||
) | ||
]} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the awesomite/var-dumper package. | ||
* | ||
* (c) Bartłomiej Krukowski <bartlomiej@krukowski.me> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
if (\version_compare(PHP_VERSION, '5.6') >= 0) { | ||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'exception-variadic.php'; | ||
} else { | ||
echo "PHP >= 5.6 required\n"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
/** | ||
* @internal | ||
*/ | ||
class AbstractConfig | ||
abstract class AbstractConfig | ||
{ | ||
protected $maxChildren; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the awesomite/var-dumper package. | ||
* | ||
* (c) Bartłomiej Krukowski <bartlomiej@krukowski.me> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Awesomite\VarDumper\Helpers; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class FileNameDecorator | ||
{ | ||
const MAX_FILE_NAME_DEPTH = 3; | ||
|
||
/** | ||
* @param string $fileName | ||
* @param null|int $maxDepth | ||
* | ||
* @return string | ||
*/ | ||
public static function decorateFileName($fileName, $maxDepth = null) | ||
{ | ||
$maxDepth = \is_null($maxDepth) | ||
? static::MAX_FILE_NAME_DEPTH | ||
: $maxDepth; | ||
|
||
$relativeTo = $fileName; | ||
for ($i = 0; $i < $maxDepth; $i++) { | ||
$relativeTo = \dirname($relativeTo); | ||
} | ||
|
||
if ($relativeTo === $fileName) { | ||
return $fileName; | ||
} | ||
|
||
$exploded = \explode(DIRECTORY_SEPARATOR, $fileName); | ||
$newParts = \array_slice($exploded, -$maxDepth, $maxDepth); | ||
\array_unshift($newParts, '(...)'); | ||
|
||
return \implode(DIRECTORY_SEPARATOR, $newParts); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.