Skip to content

Commit

Permalink
Merge 85beb08 into 6e52303
Browse files Browse the repository at this point in the history
  • Loading branch information
bkrukowski committed Feb 26, 2019
2 parents 6e52303 + 85beb08 commit 5b67d01
Show file tree
Hide file tree
Showing 68 changed files with 1,836 additions and 460 deletions.
6 changes: 6 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ HEADER;
return PhpCsFixer\Config::create()
->setRules(array(
'@PSR2' => true,
'@Symfony' => true,
'array_syntax' => array('syntax' => 'long'),
'no_unused_imports' => true,
'yoda_style' => true,
Expand All @@ -27,6 +28,11 @@ return PhpCsFixer\Config::create()
'native_function_invocation' => true,
'header_comment' => array('header' => $header),
'phpdoc_align' => true,
'phpdoc_order' => true,
'phpdoc_types_order' => true,
'return_assignment' => true,
'concat_space' => array('spacing' => 'one'),
'cast_spaces' => array('space' => 'none'),
))
->setFinder($finder)
;
58 changes: 41 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,27 @@ cache:
- $(composer global config --list | grep "\[cache-files-dir\]" | cut -d " " -f 3 | tr -d '()')

php:
- 7.3
- 7.2
- 7.1
- 7.0
- 5.6
- 5.5
- 5.4
- hhvm
- hhvm-3.3
- hhvm-3.6
- hhvm-3.9
- hhvm-3.12
- hhvm-3.15
- hhvm-3.18
- nightly
- hhvm-nightly
- hhvm

env:
matrix:
- DEPENDENCIES="high"
- DEPENDENCIES="low"

matrix:
allow_failures:
- php: nightly
- php: hhvm-nightly

include:
- php: 5.3
dist: precise
Expand All @@ -55,14 +50,33 @@ matrix:
- php: hhvm-3.18
env: DEPENDENCIES="hhvm_high"

- php: hhvm-nightly
env: DEPENDENCIES="hhvm_high"

install:

- mv .git ~.git
- if [[ "$DEPENDENCIES" = 'high' ]]; then travis_retry composer update --no-interaction --prefer-stable; fi
- if [[ "$DEPENDENCIES" = 'hhvm_high' ]]; then bin/composer-set-config.php php $(php -d hhvm.php7.all=1 -r "echo PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION;") && travis_retry composer update --no-interaction --prefer-stable; fi
- if [[ "$DEPENDENCIES" = 'low' ]]; then travis_retry composer update --no-interaction --prefer-stable --prefer-lowest; fi
- |
export IS_HHVM=$(php -r "echo defined('HHVM_VERSION') ? 'true' : 'false';")
- if [[ "$IS_HHVM" = 'false' ]] && [[ "$DEPENDENCIES" = 'high' ]]; then travis_retry composer update --no-interaction --prefer-stable; fi
- if [[ "$IS_HHVM" = 'false' ]] && [[ "$DEPENDENCIES" = 'low' ]]; then travis_retry composer update --no-interaction --prefer-stable --prefer-lowest; fi
- |
if [[ "$IS_HHVM" = 'true' ]]; then
bin/composer-set-config.php $(php -r "echo HHVM_VERSION;") platform hhvm;
if [[ "$DEPENDENCIES" = 'hhvm_high' ]]; then
bin/composer-set-config.php $(php -d hhvm.php7.all=1 -r "echo PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION;") platform php;
else
bin/composer-set-config.php $(php --r "echo PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION;") platform php;
fi;
cat composer.json
if [[ "$DEPENDENCIES" = 'low' ]]; then
export COMPOSER_FLAGS="--prefer-lowest";
else
export COMPOSER_FLAGS="--prefer-lowest";
fi;
travis_retry docker run --rm --tty --volume $PWD:/app composer update --no-interaction --prefer-stable ${COMPOSER_FLAGS};
fi
- |
if [[ ${TRAVIS_PHP_VERSION:0:3} == "7.1" ]]; then
export PHP_CS_FIXER="./dev-tools/vendor/bin/php-cs-fixer";
Expand All @@ -79,13 +93,19 @@ install:

before_script:
- vendor/bin/phpunit-4.8-fixer
- if [[ "$DEPENDENCIES" = 'hhvm_high' ]]; then echo 'hhvm.php7.all=1' >> /etc/hhvm/php.ini; fi
- if [[ "$DEPENDENCIES" = 'low' ]]; then export PHP_ARGS=$(php -r "echo '-d error_reporting=', E_ALL ^ (E_DEPRECATED | E_USER_DEPRECATED);"); else export PHP_ARGS=''; fi
- export PHP_ARGS='';
- if [[ "$IS_HHVM" = 'true' ]]; then echo 'hhvm.php7.all=1' >> /etc/hhvm/php.ini; echo 'hhvm.enable_hip_hop_syntax=1' >> /etc/hhvm/php.ini; fi
- |
if [[ "$DEPENDENCIES" = 'hhvm_high' ]]; then
echo 'hhvm.php7.all=1' >> /etc/hhvm/php.ini;
export PHP_ARGS=$(php -r "echo '-d error_reporting=', E_ALL ^ E_WARNING;");
fi
- if [[ "$DEPENDENCIES" = 'low' ]]; then export PHP_ARGS=$(php -r "echo '-d error_reporting=', E_ALL ^ (E_DEPRECATED | E_USER_DEPRECATED);"); fi

script:
- if [[ "$RUN_CS_FIXER" = "true" ]]; then php -n ${PHP_CS_FIXER} --diff --dry-run -v --allow-risky=yes fix; fi
- php ${PHP_ARGS} vendor/bin/phpunit ${PHPUNIT_EXCLUDE}
- MODE_SPEED_TEST=true php ${PHP_ARGS} vendor/bin/phpunit ${PHPUNIT_EXCLUDE}
- php ${PHP_ARGS} vendor/bin/phpunit ${PHPUNIT_EXCLUDE} -v
- MODE_SPEED_TEST=true php ${PHP_ARGS} vendor/bin/phpunit ${PHPUNIT_EXCLUDE} -v
- |
if [[ ${TRAVIS_PHP_VERSION:0:3} == "7.1" ]]; then
wget https://github.com/infection/infection/releases/download/0.10.3/infection.phar;
Expand All @@ -97,10 +117,14 @@ script:
fi
- php examples/big-dump.php
- php examples/binary-string.php
- php examples/closure.php
- php examples/custom-indent.php
- php examples/debug-info.php
- php examples/dumper.php
- php examples/exception.php
- php examples/pre-exception-variadic.php
- php examples/object.php
- php examples/simple-array.php

after_script:
- mv ~.git .git
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## [1.3.0] - ????-??-??

* Internal refactor, do not call `ob_*` functions
* Added dedicated dumpers for `Closure` and `Throwable`
* Added the following methods (default value for both of them is equal to `3`):
* `Awesomite\VarDumper\InternalVarDumper::setMaxFileNameDepth`
* `Awesomite\VarDumper\LightVarDumper::setMaxFileNameDepth`

## [1.2.1] - 2018-10-01

Function [`ini_set`](http://php.net/manual/en/function.ini-set.php) expects second argument as string,
Expand Down Expand Up @@ -81,6 +89,7 @@ $reflectionProp->getValue($obj);

This version contains the same source code as [0.12.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
[1.1.0]: https://github.com/awesomite/var-dumper/compare/v1.0.3...v1.1.0
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2017 - 2018 Bartłomiej Krukowski
Copyright (c) 2017 - 2019 Bartłomiej Krukowski

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
[![Coverage Status](https://coveralls.io/repos/github/awesomite/var-dumper/badge.svg?branch=master)](https://coveralls.io/github/awesomite/var-dumper?branch=master)
[![Build Status](https://travis-ci.org/awesomite/var-dumper.svg?branch=master)](https://travis-ci.org/awesomite/var-dumper)

[![SensioLabsInsight](https://insight.sensiolabs.com/projects/3a354f9a-85e6-47d6-aa9a-407ba293ad05/mini.png)](https://insight.sensiolabs.com/projects/3a354f9a-85e6-47d6-aa9a-407ba293ad05)

## Why?

To set limit size of printed variable and produce more readable output than built-in [`var_dump`](http://php.net/manual/en/function.var-dump.php) function.
Expand Down
20 changes: 17 additions & 3 deletions bin/composer-set-config.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
#!/usr/bin/env php
<?php

$handle = function ($scriptName, $key, $value) {
/**
* @param $value
* @param ...$keys
*/
$handle = function ($value, $_) {
$jsonPath = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'composer.json';
$json = \json_decode(\file_get_contents($jsonPath), true);
if (!isset($json['config'])) {
$json['config'] = array();
}
$json['config'][$key] = $value;

$config = &$json['config'];

foreach (\array_slice(\func_get_args(), 2, -1) as $currentKey) {
if (!isset($config[$currentKey])) {
$config[$currentKey] = array();
}
$config = &$config[$currentKey];
}

$config[\array_slice(\func_get_args(), -1, 1)[0]] = $value;

$options = JSON_UNESCAPED_UNICODE;
if (\defined('JSON_PRETTY_PRINT')) {
Expand All @@ -17,4 +31,4 @@
};

global $argv;
\call_user_func_array($handle, $argv);
\call_user_func_array($handle, \array_slice($argv, 1));
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"symfony/console": "^2.7 || ^3.0 || ^4.0",
"sebastian/comparator": ">=1.2.3",
"awesomite/phpunit-4.8-fixer": "^1.0",
"symfony/var-dumper": "^2.7 || ^3.0 || ^4.0"
"symfony/var-dumper": "^2.7 || ^3.0 || ^4.0",
"doctrine/instantiator": "1.0.2"
},
"conflict": {
"symfony/var-dumper": "<2.7.16 || >=2.8.0 <2.8.9 || >=3.0.0 <3.0.9 || >=3.1.0 <3.1.3 || >=5.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/big-dump.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private function prepareLipsum()
private function prepareArray()
{
$array = array();
for ($i = 0; $i < 10; $i++) {
for ($i = 0; $i < 10; ++$i) {
$array[\implode('', \range(0, $i))] = $i;
}
$array['greeting'] = 'Welcome!';
Expand Down
39 changes: 39 additions & 0 deletions examples/closure.php
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”}
}
]}
*/
4 changes: 3 additions & 1 deletion examples/debug-info.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@

/**
* @internal
*
* @see http://php.net/manual/en/language.oop5.magic.php#object.debuginfo
*/
class MyClass
{
public function __debugInfo()
{
return array(
'key'=> 'value',
'key' => 'value',
'some' => 'output',
);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/dumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
require_once __DIR__ . DIRECTORY_SEPARATOR . 'init.php';

/**
* The following class is just an example how to use LightVarDumper
* The following class is just an example how to use LightVarDumper.
*/
class Dumper
{
Expand Down
77 changes: 77 additions & 0 deletions examples/exception-variadic.php
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}
)
]}
*/

0 comments on commit 5b67d01

Please sign in to comment.