Skip to content

Commit

Permalink
Use template type for StateFactory methods to assist IDEs better. (#7546
Browse files Browse the repository at this point in the history
)
  • Loading branch information
htdat authored Oct 26, 2023
1 parent 8e23b57 commit 84bfd68
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
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

0 comments on commit 84bfd68

Please sign in to comment.