Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F803890
D458.id1188.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Feb 26, 9:00 AM
Size
9 KB
Mime Type
text/x-diff
Expires
Thu, Feb 27, 9:00 AM (10 h, 25 m)
Engine
blob
Format
Raw Data
Handle
576613
Attached To
D458: INP-1852 - Create the "\kUtil::varDumpColorized" method
D458.id1188.diff
View Options
Index: composer.json
===================================================================
--- composer.json
+++ composer.json
@@ -5,7 +5,8 @@
"paragonie/random_compat": "^2.0",
"symfony/polyfill-php55": "^1.19",
"symfony/polyfill-php56": "^1.19",
- "mtdowling/cron-expression": "dev-master"
+ "mtdowling/cron-expression": "dev-master",
+ "symfony/var-dumper": "^2.8"
},
"require-dev": {
"behat/mink": "^1.7",
Index: composer.lock
===================================================================
--- composer.lock
+++ composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "e44d657cbe6f1c15496b087609a60d98",
+ "content-hash": "ed3e41c072b20c049f7ff525cdb8a3b1",
"packages": [
{
"name": "ircmaxell/password-compat",
@@ -157,6 +157,86 @@
"time": "2022-02-16T17:07:03+00:00"
},
{
+ "name": "symfony/polyfill-mbstring",
+ "version": "v1.19.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-mbstring.git",
+ "reference": "b5f7b932ee6fa802fc792eabd77c4c88084517ce"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/b5f7b932ee6fa802fc792eabd77c4c88084517ce",
+ "reference": "b5f7b932ee6fa802fc792eabd77c4c88084517ce",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "suggest": {
+ "ext-mbstring": "For best performance"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "1.19-dev"
+ },
+ "thanks": {
+ "name": "symfony/polyfill",
+ "url": "https://github.com/symfony/polyfill"
+ }
+ },
+ "autoload": {
+ "files": [
+ "bootstrap.php"
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Mbstring\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony polyfill for the Mbstring extension",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "mbstring",
+ "polyfill",
+ "portable",
+ "shim"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.19.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2020-10-23T09:01:57+00:00"
+ },
+ {
"name": "symfony/polyfill-php55",
"version": "v1.19.0",
"source": {
@@ -382,6 +462,77 @@
}
],
"time": "2020-10-21T09:57:48+00:00"
+ },
+ {
+ "name": "symfony/var-dumper",
+ "version": "v2.8.52",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/var-dumper.git",
+ "reference": "91abb1e39d14fb7773d25de9c711949ea8502ac1"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/var-dumper/zipball/91abb1e39d14fb7773d25de9c711949ea8502ac1",
+ "reference": "91abb1e39d14fb7773d25de9c711949ea8502ac1",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.9",
+ "symfony/polyfill-mbstring": "~1.0"
+ },
+ "conflict": {
+ "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0"
+ },
+ "require-dev": {
+ "ext-iconv": "*",
+ "twig/twig": "~1.34|~2.4"
+ },
+ "suggest": {
+ "ext-iconv": "To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).",
+ "ext-symfony_debug": ""
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.8-dev"
+ }
+ },
+ "autoload": {
+ "files": [
+ "Resources/functions/dump.php"
+ ],
+ "psr-4": {
+ "Symfony\\Component\\VarDumper\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony mechanism for exploring and dumping PHP variables",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "debug",
+ "dump"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/var-dumper/tree/v2.8.50"
+ },
+ "time": "2018-11-11T11:18:13+00:00"
}
],
"packages-dev": [
Index: core/kernel/globals.php
===================================================================
--- core/kernel/globals.php
+++ core/kernel/globals.php
@@ -12,6 +12,10 @@
* See http://www.in-portal.org/license for copyright notices and details.
*/
+use Symfony\Component\VarDumper\Cloner\VarCloner;
+use Symfony\Component\VarDumper\Dumper\CliDumper;
+use Symfony\Component\VarDumper\Dumper\HtmlDumper;
+
defined('FULL_PATH') or die('restricted access!');
class kUtil {
@@ -1024,6 +1028,86 @@
return $result;
}
+ /**
+ * Returns colorized var dump.
+ *
+ * @param mixed $var Variable.
+ * @param string $context Context.
+ * @param boolean $return Return value.
+ *
+ * @return string|void
+ */
+ public static function varDumpColorized($var, $context, $return = true)
+ {
+ static $dumper, $cloner, $context_streams = array();
+
+ if ( $dumper === null && $cloner === null ) {
+ $cloner = new VarCloner();
+ $dumper = PHP_SAPI == 'cli' ? new CliDumper() : new HtmlDumper();
+
+ if ( $dumper instanceof HtmlDumper ) {
+ // Use $dumper->setTheme('light'); instead in later version of VarDumper library.
+ $light_theme = array(
+ 'default' => implode(
+ ' ',
+ array(
+ 'background:none;',
+ 'color:#CC7832;',
+ 'line-height:1.2em;',
+ 'font:12px Menlo, Monaco, Consolas, monospace;',
+ 'word-wrap: break-word;',
+ 'white-space: pre-wrap;',
+ 'position:relative;',
+ 'z-index:99999;',
+ 'word-break: break-all;',
+ )
+ ),
+ 'num' => 'font-weight:bold; color:#1299DA',
+ 'const' => 'font-weight:bold',
+ 'str' => 'font-weight:bold; color:#629755;',
+ 'note' => 'color:#6897BB',
+ 'ref' => 'color:#6E6E6E',
+ 'public' => 'color:#262626',
+ 'protected' => 'color:#262626',
+ 'private' => 'color:#262626',
+ 'meta' => 'color:#B729D9',
+ 'key' => 'color:#789339',
+ 'index' => 'color:#1299DA',
+ 'ellipsis' => 'color:#CC7832',
+ 'ns' => 'user-select:none;',
+ );
+ $dumper->setStyles($light_theme);
+ }
+ else {
+ if ( \function_exists('stream_isatty') && stream_isatty(STDOUT) ) {
+ $dumper->setColors(true);
+ }
+
+ if ( \function_exists('posix_isatty') && posix_isatty(STDOUT) ) {
+ $dumper->setColors(true);
+ }
+ }
+ }
+
+ if ( !array_key_exists($context, $context_streams) ) {
+ $context_streams[$context] = fopen('php://memory', 'r+b');
+ }
+
+ $stream = $context_streams[$context];
+ rewind($stream);
+
+ $dumper->dump($cloner->cloneVar($var), $stream);
+
+ // Don't close the stream !!!
+ $ret = stream_get_contents($stream, ftell($stream), 0);
+
+ if ( $return ) {
+ return $ret;
+ }
+
+ echo $ret;
+ }
+
}
/**
Event Timeline
Log In to Comment