PhpStorm - Inspections about NULL valueReference — What does this symbol mean in PHP?How to make phpstorm display line numbers by default?Word wrapping in phpstormReference - What does this error mean in PHP?Can IntelliJ IDEA encapsulate all of the functionality of WebStorm and PHPStorm through plugins?Nullable return types in PHP7Unable to Resolve Symbol on SQL code (PhpStorm issue)Why does PhpStorm report an “Argument type does not match” error?PhpStorm validation Error for custom static methodWhy does PhpStorm allow for null return type on function using yield?
Find the radius of the hoop.
How did they film the Invisible Man being invisible, in 1933?
Do home values typically rise and fall at a consistent percent?
I just started should I accept a farewell lunch for a coworker I don't know?
How to securely dispose of a smartphone?
Why would anyone even use a Portkey?
How is this practical and very old scene shot?
Movie with Zoltar in a trailer park named Paradise and a boy playing a video game then being recruited by aliens to fight in space
Put my student loan in parents’ second mortgage - help?
Most important new papers in computational complexity
Thin wall to block LED light from hitting photodiode?
Checkmate in 1 on a Tangled Board
Was it really unprofessional of me to leave without asking for a raise first?
Present Perfect with "one of these days"
How can I deal with extreme temperatures in a hotel room?
How does the Divination wizard's Expert Divination feature work when you upcast a divination spell?
Can one use the present progressive or gerund like an adjective?
Converting Geographic Coordinates into Lambert2008 coordinates
Are gliders susceptible to bird strikes?
Is it possible to have a character with proficiency in all martial weapons without proficiency in Medium armor?
Is it okay to submit a paper from a master's thesis without informing the advisor?
Most elegant way to write a one-shot 'if'
Preferred word for "preferred", "target", "chosen" in end user support documentation
Does a Hand Crossbow with the Repeating Shot Infusion still require a Free Hand to use?
PhpStorm - Inspections about NULL value
Reference — What does this symbol mean in PHP?How to make phpstorm display line numbers by default?Word wrapping in phpstormReference - What does this error mean in PHP?Can IntelliJ IDEA encapsulate all of the functionality of WebStorm and PHPStorm through plugins?Nullable return types in PHP7Unable to Resolve Symbol on SQL code (PhpStorm issue)Why does PhpStorm report an “Argument type does not match” error?PhpStorm validation Error for custom static methodWhy does PhpStorm allow for null return type on function using yield?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Question about this example:
<?php declare(strict_types=1);
class SomeTestClass
/** @var string
Why PhpStorm 2018.3.5 is not informing me about wrong code in something()
related to using nullable value as a method argument which should not be nullable? I'm asking about this because when $name
property will be null
, then I would have an error in my app.
Version with
public function something(): void
/** @var string
also does not work.
php phpstorm
|
show 5 more comments
Question about this example:
<?php declare(strict_types=1);
class SomeTestClass
/** @var string
Why PhpStorm 2018.3.5 is not informing me about wrong code in something()
related to using nullable value as a method argument which should not be nullable? I'm asking about this because when $name
property will be null
, then I would have an error in my app.
Version with
public function something(): void
/** @var string
also does not work.
php phpstorm
Couldn't you put some comment above the something() method?
– lWA
Mar 25 at 14:00
1
I don't think PHPStorm does this, you could however use a tool like PHPStan, to find these issues for you.
– Gert de Pagter
Mar 25 at 14:03
1
It has to be youtrack.jetbrains.com/issue/WI-16072 or one of the related tickets.
– LazyOne
Mar 25 at 14:07
1
I can replicate this in 2018.3.5 with PHP 7.2 inspection. Code definitely results in a fatal and I'm unable to convince PHPStorm that there's anything wrong - even PHPDoc with justNULL
as the return forgetName
doesn't give a warning.
– frozenjakalope
Mar 25 at 14:10
2
also youtrack.jetbrains.com/issue/WI-15078. Not yet implemented in PhpStorm
– Ástþór
Mar 25 at 14:16
|
show 5 more comments
Question about this example:
<?php declare(strict_types=1);
class SomeTestClass
/** @var string
Why PhpStorm 2018.3.5 is not informing me about wrong code in something()
related to using nullable value as a method argument which should not be nullable? I'm asking about this because when $name
property will be null
, then I would have an error in my app.
Version with
public function something(): void
/** @var string
also does not work.
php phpstorm
Question about this example:
<?php declare(strict_types=1);
class SomeTestClass
/** @var string
Why PhpStorm 2018.3.5 is not informing me about wrong code in something()
related to using nullable value as a method argument which should not be nullable? I'm asking about this because when $name
property will be null
, then I would have an error in my app.
Version with
public function something(): void
/** @var string
also does not work.
php phpstorm
php phpstorm
edited Mar 25 at 14:04
Krzysztof Trzos
asked Mar 25 at 13:58
Krzysztof TrzosKrzysztof Trzos
3,88512 gold badges45 silver badges78 bronze badges
3,88512 gold badges45 silver badges78 bronze badges
Couldn't you put some comment above the something() method?
– lWA
Mar 25 at 14:00
1
I don't think PHPStorm does this, you could however use a tool like PHPStan, to find these issues for you.
– Gert de Pagter
Mar 25 at 14:03
1
It has to be youtrack.jetbrains.com/issue/WI-16072 or one of the related tickets.
– LazyOne
Mar 25 at 14:07
1
I can replicate this in 2018.3.5 with PHP 7.2 inspection. Code definitely results in a fatal and I'm unable to convince PHPStorm that there's anything wrong - even PHPDoc with justNULL
as the return forgetName
doesn't give a warning.
– frozenjakalope
Mar 25 at 14:10
2
also youtrack.jetbrains.com/issue/WI-15078. Not yet implemented in PhpStorm
– Ástþór
Mar 25 at 14:16
|
show 5 more comments
Couldn't you put some comment above the something() method?
– lWA
Mar 25 at 14:00
1
I don't think PHPStorm does this, you could however use a tool like PHPStan, to find these issues for you.
– Gert de Pagter
Mar 25 at 14:03
1
It has to be youtrack.jetbrains.com/issue/WI-16072 or one of the related tickets.
– LazyOne
Mar 25 at 14:07
1
I can replicate this in 2018.3.5 with PHP 7.2 inspection. Code definitely results in a fatal and I'm unable to convince PHPStorm that there's anything wrong - even PHPDoc with justNULL
as the return forgetName
doesn't give a warning.
– frozenjakalope
Mar 25 at 14:10
2
also youtrack.jetbrains.com/issue/WI-15078. Not yet implemented in PhpStorm
– Ástþór
Mar 25 at 14:16
Couldn't you put some comment above the something() method?
– lWA
Mar 25 at 14:00
Couldn't you put some comment above the something() method?
– lWA
Mar 25 at 14:00
1
1
I don't think PHPStorm does this, you could however use a tool like PHPStan, to find these issues for you.
– Gert de Pagter
Mar 25 at 14:03
I don't think PHPStorm does this, you could however use a tool like PHPStan, to find these issues for you.
– Gert de Pagter
Mar 25 at 14:03
1
1
It has to be youtrack.jetbrains.com/issue/WI-16072 or one of the related tickets.
– LazyOne
Mar 25 at 14:07
It has to be youtrack.jetbrains.com/issue/WI-16072 or one of the related tickets.
– LazyOne
Mar 25 at 14:07
1
1
I can replicate this in 2018.3.5 with PHP 7.2 inspection. Code definitely results in a fatal and I'm unable to convince PHPStorm that there's anything wrong - even PHPDoc with just
NULL
as the return for getName
doesn't give a warning.– frozenjakalope
Mar 25 at 14:10
I can replicate this in 2018.3.5 with PHP 7.2 inspection. Code definitely results in a fatal and I'm unable to convince PHPStorm that there's anything wrong - even PHPDoc with just
NULL
as the return for getName
doesn't give a warning.– frozenjakalope
Mar 25 at 14:10
2
2
also youtrack.jetbrains.com/issue/WI-15078. Not yet implemented in PhpStorm
– Ástþór
Mar 25 at 14:16
also youtrack.jetbrains.com/issue/WI-15078. Not yet implemented in PhpStorm
– Ástþór
Mar 25 at 14:16
|
show 5 more comments
2 Answers
2
active
oldest
votes
PhpStorm is not very strict when analysing code. For example, when injecting property values through constructor, it does not look at declared property type when autocompleting methods and properties, but rather at the type that was injected into constructor.
For very strict analysis, try out PHPStan. Unlike PhpStorm, you can easily add it to your CI build. See the resulting error for your example.
add a comment |
I think PhpStorm inspection is broken with instance variables type annotations.
If I use directly:
$this->setSomething(null);
I get the type error.
However, if I directly assign null to $this->sth
, I get no error at all:
$this->sth = null;
Basically, don't rely on variable type annotations to be correctly inspected with strict_types=1
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55339507%2fphpstorm-inspections-about-null-value%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
PhpStorm is not very strict when analysing code. For example, when injecting property values through constructor, it does not look at declared property type when autocompleting methods and properties, but rather at the type that was injected into constructor.
For very strict analysis, try out PHPStan. Unlike PhpStorm, you can easily add it to your CI build. See the resulting error for your example.
add a comment |
PhpStorm is not very strict when analysing code. For example, when injecting property values through constructor, it does not look at declared property type when autocompleting methods and properties, but rather at the type that was injected into constructor.
For very strict analysis, try out PHPStan. Unlike PhpStorm, you can easily add it to your CI build. See the resulting error for your example.
add a comment |
PhpStorm is not very strict when analysing code. For example, when injecting property values through constructor, it does not look at declared property type when autocompleting methods and properties, but rather at the type that was injected into constructor.
For very strict analysis, try out PHPStan. Unlike PhpStorm, you can easily add it to your CI build. See the resulting error for your example.
PhpStorm is not very strict when analysing code. For example, when injecting property values through constructor, it does not look at declared property type when autocompleting methods and properties, but rather at the type that was injected into constructor.
For very strict analysis, try out PHPStan. Unlike PhpStorm, you can easily add it to your CI build. See the resulting error for your example.
answered Mar 26 at 11:21
Ondřej MirtesOndřej Mirtes
3,22517 silver badges35 bronze badges
3,22517 silver badges35 bronze badges
add a comment |
add a comment |
I think PhpStorm inspection is broken with instance variables type annotations.
If I use directly:
$this->setSomething(null);
I get the type error.
However, if I directly assign null to $this->sth
, I get no error at all:
$this->sth = null;
Basically, don't rely on variable type annotations to be correctly inspected with strict_types=1
add a comment |
I think PhpStorm inspection is broken with instance variables type annotations.
If I use directly:
$this->setSomething(null);
I get the type error.
However, if I directly assign null to $this->sth
, I get no error at all:
$this->sth = null;
Basically, don't rely on variable type annotations to be correctly inspected with strict_types=1
add a comment |
I think PhpStorm inspection is broken with instance variables type annotations.
If I use directly:
$this->setSomething(null);
I get the type error.
However, if I directly assign null to $this->sth
, I get no error at all:
$this->sth = null;
Basically, don't rely on variable type annotations to be correctly inspected with strict_types=1
I think PhpStorm inspection is broken with instance variables type annotations.
If I use directly:
$this->setSomething(null);
I get the type error.
However, if I directly assign null to $this->sth
, I get no error at all:
$this->sth = null;
Basically, don't rely on variable type annotations to be correctly inspected with strict_types=1
answered Mar 25 at 14:19
gbalduzzigbalduzzi
2,6918 silver badges26 bronze badges
2,6918 silver badges26 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55339507%2fphpstorm-inspections-about-null-value%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Couldn't you put some comment above the something() method?
– lWA
Mar 25 at 14:00
1
I don't think PHPStorm does this, you could however use a tool like PHPStan, to find these issues for you.
– Gert de Pagter
Mar 25 at 14:03
1
It has to be youtrack.jetbrains.com/issue/WI-16072 or one of the related tickets.
– LazyOne
Mar 25 at 14:07
1
I can replicate this in 2018.3.5 with PHP 7.2 inspection. Code definitely results in a fatal and I'm unable to convince PHPStorm that there's anything wrong - even PHPDoc with just
NULL
as the return forgetName
doesn't give a warning.– frozenjakalope
Mar 25 at 14:10
2
also youtrack.jetbrains.com/issue/WI-15078. Not yet implemented in PhpStorm
– Ástþór
Mar 25 at 14:16