What you descibed is called [design by contract][1]. The requirement that the returned array needs to contain a key 'main_flags' is called a **postcondition**.

 [1]: https://en.wikipedia.org/wiki/Design_by_contract

The language element `interface` (in PHP, or other languages like Java or C#), however, does not provide such semantics constraints, interfaces can only be used to define the syntactical part of a contract, not the semantical part.

For many languages, even if they don't provide DBC "out of the box", there are frameworks which can help to implement preconditions, postconditions and invariants directly in code. The Wikipedia link above mentions some frameworks for PHP (disclaimer: I did not try them by myself, you have to evaluate by yourself). 

Without such a framework, the typical way of ensuring a postcondition is

- write precisely into the documentation of the interface of what the function needs to return 

- write unit tests which check the postcondition for each interface implementation

- add validation code to the calls of the output function which check for the presence of the key, and make the script break immediately when the postcondition is not fulfilled, or make the script handle it gracefully (but without masking the error).

If these measures are enough, or if you need a more strict way of checking postconditions and if using a DBC framework is worth it, is something you need to find out by yourself, for your environment and situation.