PhpStorm Warnings On Incorrect Objects (Laravel)
I have been cleaning up some PhpStorm warnings using PHPDoc and in some cases there are objects referenced incorrectly. Here's an example:
$Title = $currentSlide->createRichTextShape();
CreateRichTextShape() returns as RichText as seen here:
/**
* Create rich text shape
*
* @return \PhpOffice\PhpPresentation\Shape\RichText
*/
public function createRichTextShape()
{
$shape = new RichText();
$this->addShape($shape);
return $shape;
}
This all works fine.
Then I try to call a function within RichText such as:
$textRun = $Title->createTextRun( 'Title' );
However, when hovering over the code I receive this warning:
PhpStorm thinks CreateRichTextShape()
is returning an AbstractShape
when it is actually returning a RichText
, so it can't find the function within AbstractShape
even though it exists and is documented correctly.
Note that there are no actual errors in this code - it runs fine. Just want to get rid of the warnings.
Answer
At least regarding Laravel Projects, you can clear this up in PhpStorm by adding
/** @var RichText $Title */
before the variable/method.
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS - Conditionally Load a Different Page
- → Make a Laravel collection into angular array (octobercms)
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
- → Validating fileupload(image Dimensions) in Backend Octobercms
- → OctoberCMS Fileupload completely destroys my backend
- → How do I call the value from another backed page form and use it on a component in OctoberCms