Giter VIP home page Giter VIP logo

kint-smarty's People

Contributors

raveren avatar

Watchers

 avatar  avatar  avatar

kint-smarty's Issues

PR Notes

Notes from the original PR

CI stuff:

  • php-cs-fixer is handy. You can write whatever dirty nonesense you want and it will fix it all for you
  • Of all the static PHP analyzers I tried, psalm was the best. (And it's very good. Caught a lot of bugs)
  • Those plus unit tests work great in CI

The plugin:

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

register_extension.inc.php

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.