Repository: phpactor/phpactor (php)

Issue:
`new MyClass()->method()` without parentheses breaks parsing
I checked if tolerant parser has at least PR supporting it but no one seems to be interested in such support.

https://wiki.php.net/rfc/new_without_parentheses

Pull request:
gh-2811: PHP8.4: New without parenthesis
Fixes #2811 

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 73210b6a..3812691b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@ Changelog
 
 Features:
 
+  - Support new expression without parenthesis #2811
   - Support vscode evaluatable expressions #2905 @zobo
 
 ## 2024-11-28.1
diff --git a/composer.lock b/composer.lock
index 18d40318..3154520c 100644
--- a/composer.lock
+++ b/composer.lock
@@ -1816,12 +1816,12 @@
             "source": {
                 "type": "git",
                 "url": "https://github.com/phpactor/tolerant-php-parser.git",
-                "reference": "3bd51bd63a2aa47e9c686c21b8833eb67d2c4808"
+                "reference": "8a42bdf799fd8868c85f6c6926014fefa5454ffc"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/phpactor/tolerant-php-parser/zipball/3bd51bd63a2aa47e9c686c21b8833eb67d2c4808",
-                "reference": "3bd51bd63a2aa47e9c686c21b8833eb67d2c4808",
+                "url": "https://api.github.com/repos/phpactor/tolerant-php-parser/zipball/8a42bdf799fd8868c85f6c6926014fefa5454ffc",
+                "reference": "8a42bdf799fd8868c85f6c6926014fefa5454ffc",
                 "shasum": ""
             },
             "require": {
@@ -1854,7 +1854,7 @@
             "support": {
                 "source": "https://github.com/phpactor/tolerant-php-parser/tree/main"
             },
-            "time": "2024-09-03T16:49:23+00:00"
+            "time": "2025-01-13T20:19:07+00:00"
         },
         {
             "name": "psr/container",
@@ -8226,17 +8226,17 @@
     "aliases": [],
     "minimum-stability": "dev",
     "stability-flags": {
-        "phpactor/language-server": 20,
+        "dms/phpunit-arraysubset-asserts": 20,
         "jetbrains/phpstorm-stubs": 20,
-        "phpactor/tolerant-php-parser": 20,
-        "dms/phpunit-arraysubset-asserts": 20
+        "phpactor/language-server": 20,
+        "phpactor/tolerant-php-parser": 20
     },
     "prefer-stable": true,
     "prefer-lowest": false,
     "platform": {
         "php": "^8.1"
     },
-    "platform-dev": [],
+    "platform-dev": {},
     "platform-overrides": {
         "php": "8.1.0"
     },
diff --git a/doc/lsp/vim-lsp.rst b/doc/lsp/vim-lsp.rst
index 9ca2263f..d148bd73 100644
--- a/doc/lsp/vim-lsp.rst
+++ b/doc/lsp/vim-lsp.rst
@@ -32,7 +32,7 @@ If you want to profile Phpactor for debugging purposes:
 - ``:LspPhpactorBlackfireStart``: Start :ref:`developing_blackfire_profiling` (if enabled with :ref:`param_blackfire.enabled`)
 - ``:LspPhpactorBlackfireFinish``: Finish profiling and get the profiling URL
 
-.. code-block:: lua
+.. code-block:: text
 
     -- requires plenary (which is required by telescope)
     local Float = require "plenary.window.float"
diff --git a/lib/WorseReflection/Core/Inference/Resolver/MemberAccessExpressionResolver.php b/lib/WorseReflection/Core/Inference/Resolver/MemberAccessExpressionResolver.php
index 093dfaad..0787ab84 100644
--- a/lib/WorseReflection/Core/Inference/Resolver/MemberAccessExpressionResolver.php
+++ b/lib/WorseReflection/Core/Inference/Resolver/MemberAccessExpressionResolver.php
@@ -22,6 +22,8 @@ class MemberAccessExpressionResolver implements Resolver
 
         $class = $resolver->resolveNode($frame, $node->dereferencableExpression);
 
-        return $this->nodeContextFromMemberAccess->infoFromMemberAccess($resolver, $frame, $class->type(), $node);
+        $r = $this->nodeContextFromMemberAccess->infoFromMemberAccess($resolver, $frame, $class->type(), $node);
+
+        return $r;
     }
 }


Test patch:
diff --git a/lib/WorseReflection/Tests/Inference/new/new-no-parenthesis.test b/lib/WorseReflection/Tests/Inference/new/new-no-parenthesis.test
new file mode 100644
index 00000000..76df2f32
--- /dev/null
+++ b/lib/WorseReflection/Tests/Inference/new/new-no-parenthesis.test
@@ -0,0 +1,10 @@
+<?php
+
+class Foo {
+    public function bar(): string
+    {
+    return 'asd';
+    }
+}
+
+wrAssertType('string', new Foo()->bar());