Problem/Motivation

With the bump to PHPstan 3 Extension now throws many errors anytime something is changed.

Longer term we want to do: #2024043: Add Module, Theme, Profile, and Extension value objects and #3292759: Create getters and setters for dynamic Extension properties, but for a stopgap, let's add @property annotations to Extension.

Steps to reproduce

https://git.drupalcode.org/project/drupal/-/jobs/13336499

Proposed resolution

Add @property annotations for all of the properties
Update baseline

Remaining tasks

Review

User interface changes

N/A

Introduced terminology

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

Issue fork drupal-3635205

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

nicxvan created an issue. See original summary.

nicxvan’s picture

Issue summary: View changes
Status: Active » Needs review

nicxvan’s picture

Rebuilt this after the recent issues. This is ready for review again.

dcam’s picture

I did my best to validate all of the types of the new annotations. I had trouble figuring out where the $required property is set or used. But since it's typed as an array like $required_by and $requires, I'm guessing it's OK.

There is one remaining baselined property.notFound error for \Drupal\Core\Extension\Extension. ExtensionSerializationTest::testPublicProperties() sets the property $test. It's done solely for the purpose of testing serialization of extension properties. So this one seems like one we don't want to add an annotation for. Might we want to add a @phpstan-ignore in order to get it out of the baseline?

nicxvan’s picture

Thank you @dcam for your in-depth review!

I could have sworn I saw required, I pulled it from the issue linked in the IS let's remove it and see if phpstan complains.

Also for the test property, instead of ignoring it I just changed the property to a known property.

dcam’s picture

Status: Needs review » Reviewed & tested by the community

Sounds good to me. Thank you for checking my feedback.

catch’s picture

I can understand doing a stopgap here, but I feel like I need to ask - could we not make these public, readonly properties and leave it like that?

nicxvan’s picture

Status: Reviewed & tested by the community » Needs review

Moved the theme specific ones to the Theme value object.

This should be ready for review again, I'll keep an eye on tests.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new12.7 KB

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

mstrelan made their first commit to this issue’s fork.

quietone’s picture

Does anyone know if @property is handled correctly by the API project? Or by Doctum, which is there is an issue to switch to?

mstrelan’s picture

@quietone there is an example in FieldItemListInterface, it just shows up as plain text.

It has better support in doctum, see MessageSent in laravel, where $message comes from a @property annotation.

quietone’s picture

@mstrelan, thanks. I did some more searching and yes, it is displayed as just a string but without a line break. So, no a.d.o doesn't handle @property.

nicxvan’s picture

We should probably create an issue in the api project to track this. I don't think it should block this issue though.

nicxvan’s picture

Status: Needs work » Needs review
phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

I reviewed this and I think it's good to go. Tagging for a follow-up per #16.

That said: this is only changing comments, which are easy to adjust later if needed...and the changes here lop 700 lines out of the PHPStan baseline. I think that's a win.