kint-php / kint-smarty Goto Github PK
View Code? Open in Web Editor NEWKint plugin for Smarty integration
License: MIT License
Kint plugin for Smarty integration
License: MIT License
Notes from the original PR
if (!\in_array($className, $supportedClasses)) {
Having separate methods and using an if/else with instanceof
helps a lot with psalm, and is more performant too. (In my crude tests) See DOMDocumentPlugin
for an example
$o = $this->parser->parse($var->value, $o); // simply replace with its value
$o->type = 'Smarty Variable :: ' . $o->type;
Like I said in the PR, you should make a separate variable for it to prevent trouble in future. References can be a bitch, trust me!
If you're going to just take the value, I'd just move the trigger to after completion, and then loop through $o->representations
until you find it and then you don't need to parse it in here at all.
In a perfect world you'd make a separate object class for this and override getType
or getValueShort
to return the underlying values. That'd let you do all sorts of fancy stuff, and plugins reading type directly would still work. Not to mention it would be more accurate.
For a "quick 'n dirty" that's fine though (And probably more performant)
$o->classname = $className; // TODO this is necessary for TraceFrameObject.php:95 to not throw an error`
$o->type = $className;
An InstanceObject
is what you want for objects. It has a classname property that would have clued you in here. Type is 'object'. Hash is used for recursion detection. (That could bite you in the ass some day)
Quick copy paste of the start of InstanceObject for reference:
<?php
namespace Kint\Object;
class InstanceObject extends BasicObject
{
public $type = 'object';
public $classname;
public $hash;
public $filename;
public $startline;
public $hints = array('object');
public function getType()
{
return $this->classname;
}
public function transplant(BasicObject $old)
{
parent::transplant($old);
if ($old instanceof self) {
$this->classname = $old->classname;
$this->hash = $old->hash;
$this->filename = $old->filename;
$this->startline = $old->startline;
}
}
$this->parser->haltParse();
If you move the trigger to after completion and don't halt the parse then you'll get class statics and methods on these too, from the other plugins. Should just be overall less work
I'd add the tostring blacklist thing here, so you don't need to halt the parse. Might want to move it into a static method on the plugin but that's probably overkill.
Anyway, looks like you have the gist. Feel free to shoot me questions if you have any more
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.