Repository: phpactor/phpactor (php)

Issue:
error executing language-server
Hi!
I am trying to use phpactor together with nvim (native lspconfig) but it seems like I fail to run `phpactor language-server`.

```
$ phpactor language-server -vvv
Starting language server, use -vvv for verbose output
PHP Warning:  Use of undefined constant SIGINT - assumed 'SIGINT' (this will throw an Error in a future version of PHP) in /usr/share/php/phpactor/vendor/phpactor/language-server/lib/Core/Server/LanguageServer.php on line 101
Warning: Use of undefined constant SIGINT - assumed 'SIGINT' (this will throw an Error in a future version of PHP) in /usr/share/php/phpactor/vendor/phpactor/language-server/lib/Core/Server/LanguageServer.php on line 101
PHP Fatal error:  Uncaught TypeError: Argument 1 passed to Amp\Loop::onSignal() must be of the type int, string given, called in /usr/share/php/phpactor/vendor/phpactor/language-server/lib/Core/Server/LanguageServer.php on line 104 and defined in /usr/share/php/phpactor/vendor/amphp/amp/lib/Loop.php:241
Stack trace:
#0 /usr/share/php/phpactor/vendor/phpactor/language-server/lib/Core/Server/LanguageServer.php(104): Amp\Loop::onSignal()
#1 /usr/share/php/phpactor/vendor/phpactor/language-server-extension/lib/LanguageServer/Command/StartCommand.php(59): Phpactor\LanguageServer\Core\Server\LanguageServer->run()
#2 /usr/share/php/phpactor/vendor/symfony/console/Command/Command.php(299): Phpactor\Extension\LanguageServer\Command\StartCommand->execute()
#3 /usr/share/php/phpactor/vendor/symfony/console/Application.php(978): Symfony\Component\Console\Command\Command->run()
#4 /usr/share/php/phpactor/vendor/symfony/console/Application.php(295): Symfony\Component\Console\Application->doRunCommand()
#5 /usr/share/php/phpactor/lib/Applica in /usr/share/php/phpactor/vendor/amphp/amp/lib/Loop.php on line 241
Fatal error: Uncaught TypeError: Argument 1 passed to Amp\Loop::onSignal() must be of the type int, string given, called in /usr/share/php/phpactor/vendor/phpactor/language-server/lib/Core/Server/LanguageServer.php on line 104 and defined in /usr/share/php/phpactor/vendor/amphp/amp/lib/Loop.php:241
Stack trace:
#0 /usr/share/php/phpactor/vendor/phpactor/language-server/lib/Core/Server/LanguageServer.php(104): Amp\Loop::onSignal()
#1 /usr/share/php/phpactor/vendor/phpactor/language-server-extension/lib/LanguageServer/Command/StartCommand.php(59): Phpactor\LanguageServer\Core\Server\LanguageServer->run()
#2 /usr/share/php/phpactor/vendor/symfony/console/Command/Command.php(299): Phpactor\Extension\LanguageServer\Command\StartCommand->execute()
#3 /usr/share/php/phpactor/vendor/symfony/console/Application.php(978): Symfony\Component\Console\Command\Command->run()
#4 /usr/share/php/phpactor/vendor/symfony/console/Application.php(295): Symfony\Component\Console\Application->doRunCommand()
#5 /usr/share/php/phpactor/lib/Applica in /usr/share/php/phpactor/vendor/amphp/amp/lib/Loop.php on line 241
```

System Information as follows:

```
OS: CRUX 3.6.1
php: 7.4.18
composer: version 2.1.5 2021-07-23 10:35:47
```

This happens if i use the latest tagged archive 0.17.1 and also with current master.

I wrote a quick port to install phpactor:
```
# Description: PHP completion, refactoring, introspection tool and language server
# URL: https://github.com/phpactor/phpactor
# Maintainer:
# Depends on: composer

name=phpactor
version=0.17.1
release=1
source=(https://github.com/phpactor/phpactor/archive/$version/$name-$version.tar.gz)

build() {
  cd $name-$version
  #git clone https://github.com/phpactor/phpactor.git $name
  #cd $name

  composer install --no-interaction --no-dev --no-progress --prefer-dist

  mkdir -p $PKG/usr/share/php/$name
  cp -dr --no-preserve=ownership . $PKG/usr/share/php/$name
  mkdir -p $PKG/usr/bin
  ln -s /usr/share/php/phpactor/bin/phpactor $PKG/usr/bin/phpactor
}
```

Many thanks in advance, any hints would be appreciated :-)

Edit: missed maybe the most important command here :)
```
$ phpactor status
Version: "1194ce1 (3 weeks ago) Proofread-lsp-docs-1312
Filesystems: simple, composer
Working directory: /var/www/htdocs

Config files (missing is not bad):

  ✘ /home/tim/.config/phpactor/phpactor.json
  ✘ /home/tim/.config/phpactor/phpactor.yml
  ✘ /var/www/htdocs/.phpactor.json
  ✔ /var/www/htdocs/.phpactor.yml

Diagnostics:

  ✔ Composer detected - Phpactor could work faster without an index
  ✔ XDebug is disabled. XDebug has a negative effect on performance.
  ✘ Git not detected. Some operations which would have been better scoped to your project repository will now include vendor paths.
```

Pull request:
Require pnctl extension
Require pnctl fixes #1315 

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3331bc7d..c0dd3c26 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@ Changelog
 
 Bug fixes:
 
+  - [wr] Fix arrow function completion #1303
   - [dl] Fixed off-by-one error with plain text goto definition
   - [fw] Ensure inotify is stopped before shutting down
   - [wr] properly deconstruct array in foreach
@@ -23,6 +24,7 @@ Bug fixes:
 
 Improvements:
 
+  - [wr] require `ext-pnctl` (language server would crash otherwise)
   - [wr] handle static properly #967
   - [ls] include list of diagnostic providers in status report
   - [ct] add retutn type to generated method if it would immediately return
diff --git a/composer.json b/composer.json
index a1ef9c37..8314d33e 100644
--- a/composer.json
+++ b/composer.json
@@ -4,6 +4,7 @@
     "license": "MIT",
     "require": {
         "php": "^7.4 || ^8.0",
+        "ext-pcntl": "*",
         "composer/package-versions-deprecated": "^1.0",
         "composer/xdebug-handler": "^2.0",
         "symfony/yaml": "^5.1",
diff --git a/composer.lock b/composer.lock
index 0bcdd1b8..2a6b3a18 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "657b3348581591928a5615350961e496",
+    "content-hash": "37da4707423e6718ee5af72918be280b",
     "packages": [
         {
             "name": "amphp/amp",
@@ -1213,12 +1213,12 @@
             "source": {
                 "type": "git",
                 "url": "https://github.com/JetBrains/phpstorm-stubs.git",
-                "reference": "ef3d725bf1bf35473444778b8f5c161deee6858b"
+                "reference": "4b95f4f68c050574d4f448223e2643ddf06d45da"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/JetBrains/phpstorm-stubs/zipball/ef3d725bf1bf35473444778b8f5c161deee6858b",
-                "reference": "ef3d725bf1bf35473444778b8f5c161deee6858b",
+                "url": "https://api.github.com/repos/JetBrains/phpstorm-stubs/zipball/4b95f4f68c050574d4f448223e2643ddf06d45da",
+                "reference": "4b95f4f68c050574d4f448223e2643ddf06d45da",
                 "shasum": ""
             },
             "require-dev": {
@@ -1254,7 +1254,7 @@
             "support": {
                 "source": "https://github.com/JetBrains/phpstorm-stubs/tree/master"
             },
-            "time": "2022-04-14T13:08:58+00:00"
+            "time": "2022-04-22T10:30:48+00:00"
         },
         {
             "name": "kelunik/certificate",
@@ -7630,7 +7630,8 @@
     "prefer-stable": true,
     "prefer-lowest": false,
     "platform": {
-        "php": "^7.4 || ^8.0"
+        "php": "^7.4 || ^8.0",
+        "ext-pcntl": "*"
     },
     "platform-dev": [],
     "platform-overrides": {
diff --git a/lib/WorseReflection/Core/Inference/Walker/FunctionLikeWalker.php b/lib/WorseReflection/Core/Inference/Walker/FunctionLikeWalker.php
index 4796514c..341f4cf1 100644
--- a/lib/WorseReflection/Core/Inference/Walker/FunctionLikeWalker.php
+++ b/lib/WorseReflection/Core/Inference/Walker/FunctionLikeWalker.php
@@ -4,6 +4,7 @@ namespace Phpactor\WorseReflection\Core\Inference\Walker;
 
 use Microsoft\PhpParser\MissingToken;
 use Microsoft\PhpParser\Node;
+use Microsoft\PhpParser\Node\Expression\ArrowFunctionCreationExpression;
 use Phpactor\WorseReflection\Core\Inference\FrameResolver;
 use Phpactor\WorseReflection\Core\Inference\Frame;
 use Microsoft\PhpParser\FunctionLike;
@@ -31,6 +32,7 @@ class FunctionLikeWalker extends AbstractWalker
             FunctionDeclaration::class,
             MethodDeclaration::class,
             AnonymousFunctionCreationExpression::class,
+            ArrowFunctionCreationExpression::class,
         ];
     }
 
@@ -39,7 +41,8 @@ class FunctionLikeWalker extends AbstractWalker
         assert(
             $node instanceof MethodDeclaration ||
             $node instanceof FunctionDeclaration ||
-            $node instanceof AnonymousFunctionCreationExpression
+            $node instanceof AnonymousFunctionCreationExpression ||
+            $node instanceof ArrowFunctionCreationExpression
         );
 
         $frame = $frame->new($node->getNodeKindName() . '#' . $this->functionName($node));
@@ -49,7 +52,7 @@ class FunctionLikeWalker extends AbstractWalker
     }
 
     /**
-     * @param MethodDeclaration|FunctionDeclaration|AnonymousFunctionCreationExpression $node
+     * @param MethodDeclaration|FunctionDeclaration|AnonymousFunctionCreationExpression|ArrowFunctionCreationExpression $node
      */
     private function walkFunctionLike(FrameResolver $resolver, Frame $frame, FunctionLike $node): void
     {


Test patch:
diff --git a/lib/WorseReflection/Tests/Inference/function/arrow_function.test b/lib/WorseReflection/Tests/Inference/function/arrow_function.test
new file mode 100644
index 00000000..f7c4b295
--- /dev/null
+++ b/lib/WorseReflection/Tests/Inference/function/arrow_function.test
@@ -0,0 +1,3 @@
+<?php
+
+fn (string $foo) => wrAssertType('string', $foo);