Comments (3)
I relaxed the logic for union types in completions, go to, hovers etc . (03be2af), they should work as you expect.
But reponse()->json()
will still be underlined as a warning - it'll be fixed when I integrate laravel extension (hopefully soon).
Thanks.
from tenkawa-php-language-server.
That's how union type A|B
work: language server does not know if $x
is actually A
or actually B
. Since method is only on A
, it is ignored as it may be inaccessible. You need an explicit check:
/**
* @var A|B
*/
$x = ...
if ($x instanceof A) {
$x->test();
}
For A&B
, an object can't be an instance of two unrelated classes at the same time so this type is an error. However, if B
was an interface it would work:
<?php
class A
{
public function test()
{
}
}
interface B
{
}
/**
* @var A&B
*/
$x = ...
$x->test();
Tenkawa is very strict about this. I guess it could make sense to relax this behaviour a bit, but I need give it some more thought.
Anyway, thank you for reporting this. If you find any more issues, feel free to report them as well.
btw I can recommend an article Union Types vs. Intersection Types
from tenkawa-php-language-server.
Usually, Go to definition code was presented in vendor, which not override-able by this project owner.
For example, the laravel framework's response()
helper method, it defines to return @return \Illuminate\Http\Response|\Illuminate\Contracts\Routing\ResponseFactory
, and like i example upon this comment, the class before |
does not contain json
method, but after one does, when i write reponse()->json()
, i think i shouldn't to check it like this:
$response = response();
if ($response instanceof \Illuminate\Contracts\Routing\ResponseFactory) {
return $response->json(['success' => true]);
}
from tenkawa-php-language-server.
Related Issues (14)
- slow indexing
- No indexing with LanguageClient-neovim HOT 5
- Snippets and suggestions to slow HOT 6
- annotation supports not complete HOT 4
- Allow to change phpstan rule level HOT 6
- Auto import of open bracket on complete HOT 1
- Possible to add additional stubs or build project-specific index? HOT 3
- Problems in loaded and import HOT 1
- Make server as TCP Server
- VSCode: I cannot run the server because "I don't have the sqlite ext enabled" but I have it HOT 10
- Refactoring Issues on windows HOT 1
- Go to definition it doesn't update metadata HOT 5
- PHP 7.4 Exception - ReflextionType::__toString() is deprecated HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tenkawa-php-language-server.