What you are afterdescibed is called design by contract. You want something likeThe requirement that the returned array needs to contain a key 'main_flags' is called a postcondition.
// postcondition: returned array needs to contain a key 'main_flags' interface OutputExportData { public function output(); } 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 "design by contract" frameworks for PHP which seem to be capable of what you scetched above (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 a clear statementprecisely 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.