As far as I can see, there are two ways of storing temporary data when working with complex forms in Drupal 8.
$form_state->set('key', 'value'). The value ends up in $form_state['storage']['value'], and I can use it other places because it is passed around from function to function.
Make a non-static property inside
class MyForm extends FormBase. The value is also accessible everywhere I need it, since all of the form functions are in one class.
After browsing through a lot of core
EntityForm code today, it seems that both are used! Is any of the above necessarily "better" or more in line with "The Drupal Way"?
Related question: It seems that there is a
1:1 mapping between an instance of
MyForm and the
$form_state variable. Why then, is
$form_state not implemented as a non-static class property? Then it wouldn't be necessary to pass it from function to function. The same can be asked of the