Skip to content
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

psalm-types for complex service/extension/factory type hints. #46

Merged
merged 3 commits into from May 14, 2024

Conversation

Chrico
Copy link
Member

@Chrico Chrico commented May 3, 2024

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes/features)
  • Docs have been added/updated (for bug fixes/features)

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

This PR does introduce 2 new psalm-types for:

  • Service --> callable(ContainerInterface $container):mixed
  • ExtendingService -> callable(mixed $service, ContainerInterface $container):mixed

and centrailizes the definition to reuse it in ReadOnlyContainer and ContainerConfigurator

@Chrico Chrico added the enhancement New feature or request label May 3, 2024
Copy link

codecov bot commented May 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.97%. Comparing base (feaa4d0) to head (2c50cb6).

Additional details and impacted files
@@            Coverage Diff            @@
##             master      #46   +/-   ##
=========================================
  Coverage     98.97%   98.97%           
  Complexity      217      217           
=========================================
  Files            10       10           
  Lines           588      588           
=========================================
  Hits            582      582           
  Misses            6        6           
Flag Coverage Δ
unittests 98.97% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Chrico Chrico requested a review from gmazzap May 3, 2024 14:31
…salm-types-for-services

# Conflicts:
#	src/Container/ContainerConfigurator.php
#	src/Container/ReadOnlyContainer.php
@Chrico Chrico marked this pull request as ready for review May 10, 2024 08:07
@Chrico Chrico requested a review from tfrommen May 10, 2024 08:07
@Chrico Chrico changed the title [draft] psalm-types for complex service/extension/factory type hints. psalm-types for complex service/extension/factory type hints. May 10, 2024
Copy link
Member

@tfrommen tfrommen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like adding an actual custom type for these. What I don't personally like that much is that we now have to add a lot of Psalm-specific annotations to the codebase. If possible, things like that were much better kept in or handled via the config, but this doesn't seem to be possible (nor planned).

Thanks for this.

src/Container/ServiceExtensions.php Show resolved Hide resolved
@Chrico Chrico merged commit c6855a6 into master May 14, 2024
66 checks passed
@Chrico Chrico deleted the feature/psalm-types-for-services branch May 14, 2024 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants