Skip to content

refactor: Improve types for phpstan #9685

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

neznaika0
Copy link
Contributor

Description
Improved typing.
What is done:

  • Added a "dot" at the end of the descriptions
  • Since CIUnitTestCase, the dependent code has been updated
  • Updated types in related functions in Common.php
  • Properties have been added for traits. If it is redundant, some can be deleted, phpstan does not consider this a mistake.

OFFTOP: I'll ask again: Do we really need repeated code descriptions? (You answered Yes.)
Because of this, it needs to be fixed in several places. See, example $namespace property. Modern IDEs fully support type highlighting and you can switch to declarations. If not, then is it worth adding missing comments everywhere? I would leave it as it is now, but this contradicts the desire to duplicate the code: Everywhere without repeating, or always duplicate typing.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@paulbalandan paulbalandan added the refactor Pull requests that refactor code label Aug 15, 2025
@paulbalandan
Copy link
Member

I'm not a fan either of duplicating code comments and PHPDocs. If those are already defined by the base class or interface, then child classes can remove them since, as you said, IDEs will show you the inherited code comments (unless you are not using an IDE?). It is also a maintenance burden to keep similar comments in sync.

@neznaika0
Copy link
Contributor Author

If I'm not mistaken, @samsonasik is against deletion.

@samsonasik
Copy link
Member

can @inheritDoc be used?

@neznaika0
Copy link
Contributor Author

Why? Inheritance works fine without it. Maybe the tag is needed when generating documentation? I don't see the need for it during development.

Look at $namespace, $seed - the properties have different values, but the type is specified again.

@paulbalandan
Copy link
Member

If I remember correctly, @inheritDoc is needed by phpDocumentor for its generated API docs. But IDEs work perfectly without it and there are other documentation generators that can generate API docs without @inheritDoc.

@neznaika0
Copy link
Contributor Author

Tags should be updated if the type changes or becomes more precise (int|string > object). Am I wrong?

@paulbalandan
Copy link
Member

Yes, they should be updated.

@michalsn
Copy link
Member

If phpDocumentor requires @inheritDoc, then we should include it.

@neznaika0
Copy link
Contributor Author

Okay. Can we fix the style in the Markdown guidelines or user guide?

I would like to have an exact strategy for further refactoring (example Commands, Request, Model,..). It may be necessary to remove all "bad" files from the comments. Alternatively, you can add @inheritDoc.

This may reduce the size of the installation ZIP archive.

@github-actions github-actions bot added the stale Pull requests with conflicts label Aug 17, 2025
Copy link

👋 Hi, @neznaika0!

We detected conflicts in your PR against the base branch 🙊
You may want to sync 🔄 your branch with upstream!

Ref: Syncing Your Branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Pull requests that refactor code stale Pull requests with conflicts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants