Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • Jul 14 17:40
    NSExceptional edited #819
  • Jul 14 17:39
    NSExceptional opened #819
  • Jul 11 04:14
    matkatmusic opened #818
  • Jul 08 10:26
    atanu1761 opened #817
  • Jun 28 09:55
    AbdulRafaySalsoftNew opened #816
  • Jun 28 08:06
    lihaomyname opened #815
  • Jun 24 09:04
    kevikanon commented #801
  • Jun 22 23:34
    TimHuey commented #779
  • Jun 22 23:13
    saeed410 commented #779
  • Jun 22 11:49
    salimibrogimov commented #779
  • Jun 22 09:23
    salimibrogimov commented #779
  • Jun 22 09:16
    salimibrogimov commented #779
  • Jun 22 09:15
    salimibrogimov commented #779
  • Jun 17 11:15
    laoneo commented #509
  • Jun 16 12:58
    kibblewhite commented #814
  • Jun 16 12:57
    kibblewhite closed #814
  • Jun 16 12:57
    kibblewhite commented #814
  • Jun 10 00:53
    kibblewhite edited #814
  • Jun 10 00:47
    kibblewhite edited #814
  • Jun 10 00:45
    kibblewhite edited #814
Phil Nelson
yeah I've been looking into that. I'm not familiar with how the indexing works, this is a bit of a learning curve for me. I'm trying to figure out what we would store. Would it be a mapping of fqnd FunctionLike nodes (i.e. "[Foo][Bar][methodName] => Node") or store more specific signature information, like "[Foo][Bar][methodName] => [SignatureHelp]")
but for static analysis I don't thikn the SignatureHelp objects would be very useful, so perhaps some other objects that are more useful.
Felix Becker
for now, it’s probably enough to store SignatureHelp or a dead simple structure in the Definition class
Phil Nelson
@felixfbecker this needs a lot of tidying up but before I continue is this along the lines of what you're thinking? https://github.com/felixfbecker/php-language-server/compare/master...phil-nelson:signatureHelp-index
basically I made the TreeAnalyzer collect SignatureInformation and added that to the index, stored as fqn => SignatureInformation, then in the SignatureHelpProvider I can now just use $index->getSignatureInformation($fqn)
I still have to tidy things up/add doc blocks/make it wait for the index to finish in the same way Hover does if it doesn't find anything - but wanted to first check with you that this is what you were thinking
Felix Becker
No, I was thinking to add it as a field to the Definition class
like hovers are stored
Phil Nelson
@felixfbecker ok thanks - I've updated that branch if you have a chance to have a look for any more feedback
Felix Becker
looks great!
you should open a PR :)
see what CI says
Phil Nelson
will do, thanks for the help/feedback so far :)
Felix Becker
always awesome to see when someone takes the time to dig into the code and contribute!
Phil Nelson
@felixfbecker @jens1o this is a messy fix for the issue I found being discussed in #465:
diff --git a/src/DefinitionResolver.php b/src/DefinitionResolver.php
index 72bdce4..5a8f077 100644
--- a/src/DefinitionResolver.php
+++ b/src/DefinitionResolver.php
@@ -571,12 +571,25 @@ class DefinitionResolver

             // If we get to a ForeachStatement, check the keys and values
             if ($n instanceof Node\Statement\ForeachStatement) {
-                if ($n->foreachKey instanceof Node\Expression\Variable
+                $isForeachCollection = false;
+                if ($n->forEachCollectionName) {
+                    if ($n->forEachCollectionName === $var) {
+                        $isForeachCollection = true;                                                                                                                                           
+                    } else {                                                                                                                                                                   
+                        foreach ($n->forEachCollectionName->getDescendantNodes() as $childNode) {                                                                                              
+                            if ($childNode === $var) {                                                                                                                                         
+                                $isForeachCollection = true;                                                                                                                                   
+                                break;
+                            }
+                        }
+                    }
+                }
+                if (!$isForeachCollection && $n->foreachKey instanceof Node\Expression\Variable
                     && $n->foreachKey->expression->getName() === $name
                 ) {
                     return $n->foreachKey;
-                if ($n->foreachValue
+                if (!$isForeachCollection && $n->foreachValue
                     && $n->foreachValue->expression instanceof Node\Expression\Variable
                     && $n->foreachValue->expression->getName() === $name
@jens1o are you able to apply the above to test your case by any chance?
Phil Nelson
the issue is that if the foreach item being iterated matches the foreach value, it gets into a loop trying to resolve that variable. So when traversing the AST "up" we need to find out if we got there from the foreach collection, or from inside the foreach loop. If we got there from the collection, we don't want to try and match the foreach key/value
Felix Becker
Sounds like you should just start your search at the parent node
Phil Nelson
the problem is I can't see a way to know when to do that, the collection being iterated in the ForeachStatementnode does not have an identifiable type like the ForeachKey or ForeachValue, it's just an Expression. So when traversing up, we don't know if we got to the ForeachStatement from within the loop or from the collection
Felix Becker
But every node has a parent node prop
so just start “traversing up” at the parent?
Hello people its my first time learning php language today and I came across sum of two arrays php. If you could help me I would appreciate.Thank you.
Troy Patrick
hey guys. cheers for your work on this project :)
i have a codebase that when I use this I hit the physical memory limit on my system. this is sub optimal :p are there any plans to cap memory usage for the in memory cache and implement some LRU eviction policy or something like that?
this is kinda offtopic but does anyone know how to achieve that the active parameter is underlined and bold in signature help? like here ^^^
oh, and im sorry for that issue, it was an accident and i forgot to address it before
Filipe Luis 
hey guys, whats going on
Ivan Yonchovski
@felixfbecker I have a quick question regarding the PHP server - I am working on emacs-lsp and I am working on multi server support for single file. My question is do php server in in parallel with html language server for .html files? Thanks.
Felix Becker
@yyoncho sorry I don’t understand your question. What do you mean with “do”?
Ivan Yonchovski
*My question is do php server RUN in in parallel with html language server for .html files?
Felix Becker
That totally depends on the client
Ivan Yonchovski
I mean in vscode, sorry for being unclear.
Felix Becker
For example, VS Code can run different extensions that run different language servers for different files side by side
The PHP language server will respond to requests in .php files, the HTML language server will respond to requests in .html files
Ivan Yonchovski
Do php server handle embedded php in .html?
AFAIK vscode could run multiple servers for one file.
Felix Becker
The PHP server responds to requests on .php files, providing code intelligence for the PHP code (not the HTML code)
The file needs to end with .php
Ivan Yonchovski
Ok, thanks!
I'm unable to use ignore in php debug
"name": "Listen for XDebug - Web 4",
"type": "php",
"request": "launch",
"port": 9000,
"log": true,
** / vendor / ** /*.php
without spaces
I'm trying with this glob pattern
any idea?
Ben Jackson
Hi there, i’m implementing a client for php-language-server and i’m a bit stumped as to why i’m not getting completions im very simple (single file) projects, but get fully working semantic engine in complex projects such as php-language-server itself (or the projects in validation/frameworks). Am i doing something dense? I get the same behaviour give or take in VScode so i don’t think it is my LSP client. For example, i would expect completion suggestions for $test-> in the following code simple.php:

$what = 'test';

class Test {
  function do_something( $thing ) {
  print_r( $thing );
    echo "\n";

$test = new Test();

Full log file:
DEBUG     The xdebug extension is loaded (2.7.0beta1)

DEBUG     Process restarting (PHPLS_ALLOW_XDEBUG=internal|2.7.0beta1|1|*|*)
DEBUG     Running '/usr/local/Cellar/php/7.3.0/bin/php' '-n' '-c' '/private/var/folders/s3/v5q17n8532x05nn495s125yh0000gn/T/rOWtFa' '/Users/ben/.vscode/extensions/felixfbecker.php-intellisense-2.3.10/vendor/felixfbecker/language-server/bin/php-language-server.php' '--tcp=' '--memory-limit=4095M'

DEBUG     Restarted (43 ms). The xdebug extension is not loaded

[Info  - 7:47:17 PM] 1 files total
[Info  - 7:47:17 PM] Indexing project for definitions and static references
Parsing file:///Users/ben/Development/YouCompleteMe/php-tesy/simple.php
[Info  - 7:47:17 PM] Indexing project for dynamic references
[Info  - 7:47:17 PM] 0 Packages
[Info  - 7:47:17 PM] All 1 PHP files parsed in 0 seconds. 148 MiB allocated.