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

Use template type for StateFactory methods to assist IDEs better. #7546

Merged
merged 4 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/rpp-add-template-type-create_state
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Use template type for StateFactory methods to assist IDEs better.


7 changes: 5 additions & 2 deletions src/Internal/Payment/State/AbstractPaymentState.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,11 @@ public function complete_processing() {
* This method should only be called whenever the process is ready to transition
* to the next state, as each new state will be considered the payment's latest one.
*
* @param string $state_class The class of the state to crate.
* @return AbstractPaymentState
* @template ConcreteState
* @param class-string<ConcreteState> | string $state_class The class of the state to crate.
*
* @return AbstractPaymentState | ConcreteState
*
* @throws StateTransitionException In case the new state could not be created.
* @throws ContainerException When the dependency container cannot instantiate the state.
*/
Expand Down
8 changes: 5 additions & 3 deletions src/Internal/Payment/State/StateFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ public function __construct( Container $container ) {
/**
* Creates a new state based on class name.
*
* @param string $state_class Name of the state class.
* @param PaymentContext $context Context for the new state.
* @return AbstractPaymentState The generated payment state instance.
* @template ConcreteState
* @param class-string<ConcreteState> | string $state_class Name of the state class.
* @param PaymentContext $context Context for the new state.
*
* @return AbstractPaymentState | ConcreteState The generated payment state instance.
* @throws ContainerException When the dependency container cannot instantiate the state.
* @throws StateTransitionException When the class name is not a state.
*/
Expand Down
Loading