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;








3















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.










share|improve this question
























  • 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 for getName 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

















3















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.










share|improve this question
























  • 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 for getName 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













3












3








3








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.










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 just NULL as the return for getName 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






  • 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 for getName 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












2 Answers
2






active

oldest

votes


















1














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.






share|improve this answer






























    0














    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






    share|improve this answer

























      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
      );



      );













      draft saved

      draft discarded


















      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









      1














      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.






      share|improve this answer



























        1














        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.






        share|improve this answer

























          1












          1








          1







          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.






          share|improve this answer













          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.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 26 at 11:21









          Ondřej MirtesOndřej Mirtes

          3,22517 silver badges35 bronze badges




          3,22517 silver badges35 bronze badges























              0














              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






              share|improve this answer



























                0














                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






                share|improve this answer

























                  0












                  0








                  0







                  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






                  share|improve this answer













                  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







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 25 at 14:19









                  gbalduzzigbalduzzi

                  2,6918 silver badges26 bronze badges




                  2,6918 silver badges26 bronze badges



























                      draft saved

                      draft discarded
















































                      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.




                      draft saved


                      draft discarded














                      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





















































                      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







                      Popular posts from this blog

                      Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                      SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                      은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현