$row ) { foreach ( array( 'hook', 'callback', 'priority', 'args', 'reason', 'phase' ) as $field ) { if ( ! array_key_exists( $field, $row ) ) { throw new \InvalidArgumentException( esc_html( 'Hook manifest row ' . $index . ' is missing ' . $field . '.' ) ); } } if ( ! \in_array( $row['phase'], array( 'pre-latch', 'sync-latched', 'post-latch' ), true ) ) { throw new \InvalidArgumentException( esc_html( 'Hook manifest row ' . $index . ' requires a valid phase.' ) ); } foreach ( array( 'priority', 'args' ) as $field ) { if ( ! \is_int( $row[ $field ] ) ) { throw new \InvalidArgumentException( esc_html( 'Hook manifest row ' . $index . ' requires an integer ' . $field . '.' ) ); } } if ( ! \is_callable( $row['callback'] ) ) { throw new \InvalidArgumentException( esc_html( 'Hook manifest row ' . $index . ' requires a callable callback.' ) ); } if ( ! \is_string( $row['reason'] ) || '' === trim( $row['reason'] ) ) { throw new \InvalidArgumentException( esc_html( 'Hook manifest row ' . $index . ' requires a non-empty reason.' ) ); } } } }