Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Padawan does not autocomplete when inside a multi-line associative array #23

Open
allan-simon opened this issue Dec 20, 2015 · 8 comments
Labels
Milestone

Comments

@allan-simon
Copy link

I have the following code

<?php

class A {
    public function foo(){}
}

$a = new A();
// place X
[
    'a' => $a // place Y
];

If i try now to type $a-> at place X it will work, but if it try to type -> at place Y, it will not
if the array is a multiline normal one , it does work , same for multiline function call

@allan-simon allan-simon changed the title Padawan does not autocomplete when inside an array Padawan does not autocomplete when inside a multi-line associative array Dec 20, 2015
@mkusher mkusher added the bug label Dec 20, 2015
@mkusher
Copy link
Member

mkusher commented Dec 20, 2015

Hello, thanks for the bug report. This happens because of using hacked php-parser. It is unable to parse line like 'a' => $a->

@allan-simon
Copy link
Author

hmmm ok, actually if i put it on one line , then it's able to parse it correctly

by the way, now that php7 has a AST (and a lib to access it) , would it make things easier ? (like the people from this project https://github.com/etsy/phan/ are doing)

@allan-simon
Copy link
Author

more on the bug itself, do you think it would be hard to fix, i.e if i could try my hand on it ?

@mkusher
Copy link
Member

mkusher commented Dec 20, 2015

@allan-simon I haven't tried it yet, but I think at least it would be faster. What about fixing this bug, right now I have not enough time and would be able to fix it only after holidays.
The problem lives here https://github.com/mkusher/padawan.php/blob/master/src/Parser/ErrorFreePhpParser.php
but if it is possible to use https://github.com/nikic/PHP-Parser/blob/master/doc/component/Error.markdown then maybe it will be easy to solve

@allan-simon
Copy link
Author

I've added some debug in ErrorFreePhpParser, and what I can see is that most of the time the exception which get returned is

Syntax error, unexpected EOF, expecting T_STRING or T_VARIABLE or '{' or '$' on line 1

even for [ 'a' => $a-> ] (for which autocompletion works

but for

[
     'a' => $a->
]

I got :

"Syntax error, unexpected T_DOUBLE_ARROW on line 1"

@allan-simon
Copy link
Author

oh I see what you mean, as it handles on a line per line basis , hence why it works when the beginning of the array is on the same line, and for other type of multiline statement

@mkusher mkusher added this to the 0.4 milestone Apr 5, 2016
@golaod
Copy link

golaod commented Sep 8, 2016

Is there a chance to fix it?

@mkusher
Copy link
Member

mkusher commented Sep 8, 2016

@golaod there should be fix in a parser logic, I'm not sure how easy it is. Currently I'm working on https://github.com/mkusher/padawan.php/pulls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants