phpactor icon indicating copy to clipboard operation
phpactor copied to clipboard

[WR] tolerant-php-parser warning

Open lhyaax opened this issue 9 years ago • 7 comments

my environment: ubuntu16.04 + php7.1 + vim8 I try run,

phpactor class:reflect lib/Application/Transformer.php

PHP Warning:  Unexpected character in input:  '' (ASCII=27) state=0 in vendor/microsoft/tolerant-php-parser/src/PhpTokenizer.php on line 61
...                                                                       
  [Symfony\Component\Debug\Exception\ContextErrorException]              
  Notice: Undefined property: Microsoft\PhpParser\MissingToken::$parent 

what's wrong with tolerant-php-parser?

lhyaax avatar Aug 21 '17 03:08 lhyaax

I solved it, the problem is the character of the file vendor/microsoft/tolerant-php-parser/src/PhpTokenizer.php, I edit it with vim, and save it, it's work.

lhyaax avatar Aug 21 '17 04:08 lhyaax

Hmm, that works for me (assuming you are running it on Phpactor\Application\Transformer.

  • If you did not run it on Phpactor\Application\Transformer could you include the source code on which you did run it?
  • Can you run the command again but with the --verbose flag and post the stack trace?

dantleech avatar Aug 21 '17 06:08 dantleech

Can you provide any further information on this?

dantleech avatar Aug 24 '17 19:08 dantleech

I remove ~/.vim/plugged/phpactor

.vimrc like this ... Plug 'phpactor/phpactor', { 'for': 'php', 'do': 'composer install' } ... After reinstall phpactor

#cd  ~/.vim/plugged/phpactor
#phpactor class:reflect lib/Application/Transformer.php
PHP Warning:  Unexpected character in input:  '' (ASCII=24) state=0 in /home/u/.vim/plugged/phpactor/vendor/microsoft/tolerant-php-parser/src/PhpTokenizer.php on line 61                                                                      
  [Symfony\Component\Debug\Exception\ContextErrorException]              
  Notice: Undefined property: Microsoft\PhpParser\MissingToken::$parent  

I edit PhpTokenizer.php on line 61 ,

        //$tokens = \token_get_all($content);
        $tokens = \token_get_all('');

run

#phpactor class:reflect lib/Application/Transformer.php                                       
  [Phpactor\WorseReflection\Core\Exception\ClassNotFound]    
  Unable to locate class "Phpactor\Application\Transformer" 

edit again

        //$tokens = \token_get_all($content);
        $tokens = \token_get_all($content);

run

#phpactor class:reflect lib/Application/Transformer.php
class:Phpactor\Application\Transformer
class_namespace:Phpactor\Application
class_name:Transformer
methods:
  __construct:
    name:__construct
    abstract:
    visibility:public
    parameters:
      transform:
        name:transform
        has_type:1
        type:CodeTransform
        has_default:
        default:
    static:0
    type:
    synopsis:public function __construct(Phpactor\CodeTransform\CodeTransform $transform)
    docblock:
  transform:
    name:transform
    abstract:
    visibility:public
    parameters:
      src:
        name:src
        has_type:1
        type:string
        has_default:
        default:
      transformations:
        name:transformations
        has_type:1
        type:array
        has_default:
        default:
    static:0
    type:
    synopsis:public function transform(string $src, array $transformations)
    docblock:
properties:
  transform:
    name:transform
    visibility:private
    static:0
    info:private Phpactor\CodeTransform\CodeTransform $transform
  filesystemHelper:
    name:filesystemHelper
    visibility:private
    static:0
    info:private Phpactor\Application\Helper\FilesystemHelper $filesystemHelper
constants:

work well !

lhyaax avatar Aug 25 '17 04:08 lhyaax

Pff. No idea works for me. Which operating system do you use? Which version of PHP?

dantleech avatar Aug 25 '17 21:08 dantleech

i received the same notice on macOS Sierra with PHP 7.0. upgrading to PHP 7.1 (as suggested by https://github.com/Microsoft/tolerant-php-parser/blob/master/docs/GettingStarted.md) resolved the issue.

julesferreira avatar Nov 18 '17 02:11 julesferreira

As TolerantParser doesn't officially support 7.0 and 7.0 is not maintained now, closing. (although I do use PHP7.0 here without issues).

dantleech avatar Dec 04 '17 20:12 dantleech