Giter Site home page Giter Site logo

js-scanner's People

Contributors

oscarotero avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

royalwang

js-scanner's Issues

Add "_" to gettext functions list

Hello,

Would it be possible to add "_" to the list of functions handled by JsScanner, same way as in PHPScanner?
I opened a PR including the addition in case you agree.

Best,

Juliette

PHP 8 compatibility

Hello,

we are trying to install the package via composer, however it seems not compatible with php8. Is there a new compatible version on the way?

Regards
Enrico

Wrong logic to get function name from js on difficult expressions.

Hello, trying to parse big legacy mess of code for extracting translations.
But while this process getting errors on some difficult expressions, by example:

Fatal error: Uncaught Error: Call to undefined method Peast\Syntax\Node\MemberExpression::getName() in ./vendor/gettext/js-scanner/src/JsNodeVisitor.php:90

return $callee->getProperty()->getName();

Some broken examples
// occured: Peast\Syntax\Node\StringLiteral::getName()
// source: var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.element') || 0xeac7;
// problem: Symbol['for']('react.element');

// occured: Peast\Syntax\Node\BinaryExpression::getName()
// source: reset: function(e){var t=this.dimension();return this.$element.removeClass("collapse")[t](e||"auto")[0].offsetWidth,this.$element[e!==null?"addClass":"removeClass"]("collapse"),this}
// problem: reset = $element[e!==null?"addClass":"removeClass"]("collapse")

// occured: Peast\Syntax\Node\ConditionalExpression::getName()
// source: reset: function(e){var t=this.dimension();return this.$element.removeClass("collapse")[t](e||"auto")[0].offsetWidth,this.$element[e!==null?"addClass":"removeClass"]("collapse"),this}
// problem: this.$element[e!==null?"addClass":"removeClass"]("collapse")

That problem looks like global , because can be reproduced many times with many of code variations.

FYI: For fast fix i'm used this hack:

switch ($callee->getType()) {
    case 'Identifier':
        return $callee->getName();
    case 'MemberExpression':
        if (!method_exists($callee->getProperty(), 'getName')) {
            return null;
        }
        return $callee->getProperty()->getName();
    default:
        return null;
}

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.