Fatal error: Declaration of ... must be compatible with /**
   * {@inheritdoc}
   */
  public function blockForm($form, FormStateInterface $form_state) {
    return [];
  }


in BlockBase.php

vs 

/**
     * @inheritdoc
     */
    public function blockForm(array $form, FormStateInterface $form_state ) {
       $form = parent::blockForm($form, $form_state);

       $form['city'] = [
        '#type' =&gt; 'textfield',
        '#title' =&gt; $this-&gt;t('City'),
        '#default_value' =&gt; $this-&gt;configuration['city'],
       ];

       return $form; 
    }


in CustomWeatherBlock.php

Adding array in first argument as typehint of $form gives above error.
I just need to understand why is it giving an error.Is it because BlockBase is an abstract class and CustomWeatherBlock class extends BlockBase hence it needs to copy exactly the methods name and its arguments (including typehint) ?

Error 


  ( ! ) Fatal error: Declaration of
  Drupal\custom_changes\Plugin\Block\CustomWeatherBlock::blockForm(array
  $form, Drupal\custom_changes\Plugin\Block\FormStateInterface
  $form_state) must be compatible with
  Drupal\Core\Block\BlockBase::blockForm($form,
  Drupal\Core\Form\FormStateInterface $form_state) in
  /Applications/MAMP/htdocs/d8jsonapi/web/modules/custom/custom_changes/src/Plugin/Block/CustomWeatherBlock.php
  on line 16
BlockBase implements BlockPluginInterface, which defines blockForm() as follows:

public function blockForm($form, FormStateInterface $form_state);


Interfaces are like contracts. Any class that implements an interface (or one of it's descendants) must define all the functions in the interface, and they must be defined exactly as in the interface. This is so that developers can replace classes, but ensure the code will still work, since the function definition will always expect the same values, as defined by the interface.

When you add a typehint to force $form to be an array, you break the contract of the interface. The interface says that any value should be allowed for the $form argument, but you are saying it must be an array. If you used your code, and a function passed a non-array value, it would cause an error. The interface is there to prevent such errors from happening. This is why you cannot change the function definition.