Skip to content

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

Merged
Chrico merged 3 commits into
masterfrom
feature/psalm-types-for-services
May 14, 2024
Merged

psalm-types for complex service/extension/factory type hints.#46
Chrico merged 3 commits into
masterfrom
feature/psalm-types-for-services

Conversation

@Chrico

@Chrico Chrico commented May 3, 2024

Copy link
Copy Markdown
Member

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
@codecov

codecov Bot commented May 3, 2024

Copy link
Copy Markdown

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
Chrico added 2 commits May 10, 2024 09:16
…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

@tfrommen tfrommen left a comment

Copy link
Copy Markdown
Member

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.

Comment thread src/Container/ServiceExtensions.php
@Chrico
Chrico merged commit c6855a6 into master May 14, 2024
@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.

3 participants