netgen / media-site

Netgen Media Site (Powered by Netgen Layouts & eZ Platform)
https://netgen.io
Other
30 stars 10 forks source link

Add PHPStan baseline to exclude most frequent errors related to Ibexa #141

Closed emodric closed 1 year ago

emodric commented 1 year ago

This adds some useful PHPStan ignore rules which are related to how Ibexa handles content fields and their values, e.g.

$content->getFieldValue('title')->text

would result in an error:

Access to an undefined property Ibexa\Contracts\Core\FieldType\Value::$text

I will add more later as I run into them

pspanja commented 1 year ago

Looks good 👍 BTW, do inline type annotations also silence the errors here?

emodric commented 1 year ago

@pspanja They do, but when you work with content extensively (for example in netgen/site-bundle), so much of them looks very very ugly, and you have to complicate code to actually use them:

/** @var \Ibexa\Core\FieldType\TextLine\Value $fieldValue **/
$fieldValue = $content->getFieldValue('title');
$text = $fieldValue->text;

That's why I always fallback to just excluding these errors from PHPStan.

emodric commented 1 year ago

Thanks all!