Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated kint-php to the latest version. #6

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.DS_Store
.idea
17 changes: 5 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,6 @@ This is the simplest usage, and will output an interactive debugger for the vari

This works the same way as the d (dump) command, except it will cause output to end immediately after the debugger is returned.

#### s (simple dump)

`{{ s(someTwigVariable) }}` or `{{ craft.kint.s(someTwigVariable) }}`

This works essentially the same way as the built-in Twig dump method, and returns a plain text debugging output.

#### sd (simple dump and die)

`{{ sd(someTwigVariable) }}` or `{{ craft.kint.sd(someTwigVariable) }}`

Same as above, but with output ending immediately after the plain text debugging output is returned.

#### time (point-in-time memory usage and timestamp)

`{{ time() }}` or `{{ craft.kint.time }}`
Expand Down Expand Up @@ -85,6 +73,11 @@ one central object to keep things clean.

* Added Twig functions `d`, `dd`, `s`, `sd`, and `time` for easier usage

### 1.1.1 -- 2017.05.20

* Updated Kint to latest Version
* Removed `s`, `sd` function because they are no longer supported by Kint

## Credit

* Thank you to Rokas Šleinius, the developer of Kint - he welcomes donations at [Kint's website](http://raveren.github.io/kint/)
Expand Down
20 changes: 18 additions & 2 deletions kint/KintPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,19 @@ public function init()
{
require_once __DIR__ . '/vendor/autoload.php';
$settings = craft()->plugins->getPlugin('kint')->getSettings();
\Kint::$theme = $settings->kintDisplayTheme;
\Kint_Renderer_Rich::$theme = $settings->kintDisplayTheme;
\Kint::$max_depth = $settings->kintMaxDepth;


/**
* ddd() was removed from kint core so we have to create it on our own and alias it in kint
* @param array ...$v
*/
function ddd(...$v){
d(...$v);
exit;
}
\Kint::$aliases[] = 'ddd';
}

public function getName()
Expand Down Expand Up @@ -67,7 +79,11 @@ protected function defineSettings()
return array(
'kintDisplayTheme' => array(
AttributeType::Mixed,
'default' => 'original'
'default' => 'original.css'
),
'kintMaxDepth' => array(
AttributeType::String,
'default' => '7'
)
);
}
Expand Down
17 changes: 17 additions & 0 deletions kint/KintPreRender.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

class R extends Kint_Renderer_Rich
{
public static $preRenderOutput;

public function preRender()
{
if (!self::$preRenderOutput) {
return self::$preRenderOutput = parent::preRender();
}

return parent::preRender();
}
}

Kint::$renderers[Kint::MODE_RICH] = 'R';
2 changes: 1 addition & 1 deletion kint/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require": {
"raveren/kint": "1.0.10"
"kint-php/kint": "^2.1"
}
}
45 changes: 26 additions & 19 deletions kint/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions kint/services/KintService.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@ public function dd($debug = null)
return ddd($debug);
}

public function s($debug = null)
{
return s($debug);
}

public function sd($debug = null)
{
return sd($debug);
}

public function time()
{
return d(microtime());
Expand Down
16 changes: 12 additions & 4 deletions kint/templates/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,20 @@
id: 'kintDisplayTheme',
name: 'kintDisplayTheme',
options: {
'original': 'Original',
'solarized': 'Solarized',
'solarized-dark': 'Solarized Dark',
'aante-light': 'Aante Light'
'original.css': 'Original',
'solarized.css': 'Solarized',
'solarized-dark.css': 'Solarized Dark',
'aante-light.css': 'Aante Light'
},
default: 'original',
value: settings.kintDisplayTheme,
first: true
}) }}

{{ forms.textField({
label: "Max parsing depth. A number between 0 (unlimited) and 7 (Default)",
id: 'kintMaxDepth',
name: 'kintMaxDepth',
default: '7',
value: settings.kintMaxDepth
}) }}
23 changes: 9 additions & 14 deletions kint/twigextensions/KintTwigExtension.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
namespace Craft;

require_once __DIR__ . '/../KintPreRender.php';

class KintTwigExtension extends \Twig_Extension
{
protected $env;
Expand All @@ -15,9 +17,8 @@ public function getFunctions()
return array(
'd' => new \Twig_Function_Method($this, 'd'),
'dd' => new \Twig_Function_Method($this, 'dd'),
's' => new \Twig_Function_Method($this, 's'),
'sd' => new \Twig_Function_Method($this, 'sd'),
'time' => new \Twig_Function_Method($this, 'time')
'time' => new \Twig_Function_Method($this, 'time'),
'preRender' => new \Twig_Function_Method($this, 'preRender'),
);
}

Expand All @@ -36,19 +37,13 @@ public function dd($debug)
return craft()->kint->dd($debug);
}

public function s($debug)
{
return craft()->kint->s($debug);
}

public function sd($debug)
{
return craft()->kint->sd($debug);
}

public function time()
{
return craft()->kint->time();
}

}
public function preRender()
{
echo \R::$preRenderOutput . '</div>';
}
}
10 changes: 0 additions & 10 deletions kint/variables/KintVariable.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,6 @@ public function dd($debug = null)
return craft()->kint->dd($debug);
}

public function s($debug = null)
{
return craft()->kint->s($debug);
}

public function sd($debug = null)
{
return craft()->kint->sd($debug);
}

public function time()
{
return craft()->kint->time();
Expand Down
2 changes: 1 addition & 1 deletion kint/vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

// autoload.php @generated by Composer

require_once __DIR__ . '/composer' . '/autoload_real.php';
require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit943034af40a42b62a96a2103a6352a4e::getLoader();
12 changes: 7 additions & 5 deletions kint/vendor/composer/ClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class ClassLoader

private $useIncludePath = false;
private $classMap = array();

private $classMapAuthoritative = false;
private $missingClasses = array();

public function getPrefixes()
{
Expand Down Expand Up @@ -322,20 +322,20 @@ public function findFile($class)
if (isset($this->classMap[$class])) {
return $this->classMap[$class];
}
if ($this->classMapAuthoritative) {
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
return false;
}

$file = $this->findFileWithExtension($class, '.php');

// Search for Hack files if we are running on HHVM
if ($file === null && defined('HHVM_VERSION')) {
if (false === $file && defined('HHVM_VERSION')) {
$file = $this->findFileWithExtension($class, '.hh');
}

if ($file === null) {
if (false === $file) {
// Remember that this class does not exist.
return $this->classMap[$class] = false;
$this->missingClasses[$class] = true;
}

return $file;
Expand Down Expand Up @@ -399,6 +399,8 @@ private function findFileWithExtension($class, $ext)
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
return $file;
}

return false;
}
}

Expand Down
2 changes: 1 addition & 1 deletion kint/vendor/composer/LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

Copyright (c) 2015 Nils Adermann, Jordi Boggiano
Copyright (c) 2016 Nils Adermann, Jordi Boggiano

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
Loading