[WR] tolerant-php-parser warning
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?
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.
Hmm, that works for me (assuming you are running it on Phpactor\Application\Transformer.
- If you did not run it on
Phpactor\Application\Transformercould you include the source code on which you did run it? - Can you run the command again but with the
--verboseflag and post the stack trace?
Can you provide any further information on this?
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 !
Pff. No idea works for me. Which operating system do you use? Which version of PHP?
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.
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).