Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • Jun 10 00:53
    kibblewhite edited #814
  • Jun 10 00:47
    kibblewhite edited #814
  • Jun 10 00:45
    kibblewhite edited #814
  • Jun 10 00:45
    kibblewhite edited #814
  • Jun 10 00:44
    kibblewhite edited #814
  • Jun 10 00:43
    kibblewhite edited #814
  • Jun 10 00:41
    kibblewhite edited #814
  • Jun 10 00:34
    kibblewhite opened #814
  • Jun 08 15:08
    rickmedlin opened #813
  • Jun 06 12:29
    james090500 commented #779
  • Jun 04 04:50
    ghuntley opened #812
  • Jun 04 00:41
    h4de5 commented #462
  • May 29 15:17
    tskorupka commented #805
  • May 27 08:52
    Geekimo commented #779
  • May 18 15:35
    amasotti commented #779
  • May 14 01:24
    JoabioVilela commented #544
  • May 12 22:19
    gonzad26 opened #811
  • May 03 12:02
    rk0cc commented #809
  • Apr 30 16:22
    apfelchips commented #807
  • Apr 30 16:10
    apfelchips commented #807
Felix Becker
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.
i can provide the LSP logs too if you like
@kapitanluffy:matrix.org hello?
Sorry. I checked if I can access gitter via matrix but it seemed weird. :sweat_smile: