hyn/state-machine

Wrong Condition: State NOT in suggested states

Closed this issue · 5 comments

LMCom commented

If a next state is specified, it should actually be in the suggested states of a transition, which is checked to be a possible next transition. It seems wrong, that the code negates in_array().

if (!$nextState || ($nextState && !in_array($nextState, $transition->suggests()))) {

LMCom commented

On a second thought, does it even play a role, if the next state is in the suggested states of the possible transitions?

I think you're right that negation is incorrect. What it tries to do is, if you provide a wished for next state to identify which of the transitions suits the needs to transition to that state. The negation blocks that functionality.

Are you willing to provide a PR for this?

LMCom commented

Sorry, I am currently exclusively programming for work and very busy and I am actually not using your state-machine. I just looked through the code for inspiration, because I have to do something similar. However, it will be quite configurable, so it will make use of a database, where possible. Your state-machine is really nice, but not suited in this case.

Thanks for your quick reply!

No problem, glad this package has at least some use. I'm not using it anymore, but keeping it available to the public does obviously help.

Good luck with writing one of your own, it's a bit of a challenge but extremely fun to do!

closed in 5ba826e