Getting the node object in hook_form_FORM_ID_alter
PhpStorm doesn't know as the type of form object is dynamic but it's fine.

If you want to make it happy, wrap it in a condition like:

if ($form_state-&gt;getFormObject() instanceof EntityForm) {
  ...
}


Either way, it should definitely work if you implement the correct form alter. If you don't, you should end up with a fatal error not just without a node object.

You need to share your exact code if you want a more specific answer, that's all I can tell you.