Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 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
@felixfbecker
I know
what’s your point?
Phil Nelson
@phil-nelson
I thought when you said you'd accept a PR that you were thinking it would be worth doing on the server side
Felix Becker
@felixfbecker
no, sorry
but the server needs to register what files to watch, implement didChangeWatchedFiles, remove the old state for the changed documents from the index and reindex those documents
Phil Nelson
@phil-nelson
ah right I see. I'll look into it after I get my head around how the indexing works to see if it makes sense to do for my signatureHelp PR
Felix Becker
@felixfbecker
I mean, it should definitely be a different PR
Phil Nelson
@phil-nelson
yeah
Felix Becker
@felixfbecker
did you read my review comment on the signature help PR?
Phil Nelson
@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
@felixfbecker
for now, it’s probably enough to store SignatureHelp or a dead simple structure in the Definition class
Phil Nelson
@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
@felixfbecker
No, I was thinking to add it as a field to the Definition class
like hovers are stored
Phil Nelson
@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
@felixfbecker
looks great!
you should open a PR :)
see what CI says
Phil Nelson
@phil-nelson
will do, thanks for the help/feedback so far :)
Felix Becker
@felixfbecker
always awesome to see when someone takes the time to dig into the code and contribute!
Phil Nelson
@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
@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
@felixfbecker
Sounds like you should just start your search at the parent node
Phil Nelson
@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
@felixfbecker
But every node has a parent node prop
so just start “traversing up” at the parent?
Khadija-Yusuf
@Khadija-Yusuf
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
@teasp00n
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?
Nufflee
@Nufflee
hello
image.png
this is kinda offtopic but does anyone know how to achieve that the active parameter is underlined and bold in signature help? like here ^^^
Nufflee
@Nufflee
oh, and im sorry for that issue, it was an accident and i forgot to address it before
Filipe Luis 
@flschaves_twitter
hey guys, whats going on
Ivan Yonchovski
@yyoncho
@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
@felixfbecker
@yyoncho sorry I don’t understand your question. What do you mean with “do”?
Ivan Yonchovski
@yyoncho
*My question is do php server RUN in in parallel with html language server for .html files?
Felix Becker
@felixfbecker
That totally depends on the client
Ivan Yonchovski
@yyoncho
I mean in vscode, sorry for being unclear.
Felix Becker
@felixfbecker
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
@yyoncho
Do php server handle embedded php in .html?
AFAIK vscode could run multiple servers for one file.
Felix Becker
@felixfbecker
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