Skip to content

Allow types (when used in method and function) to be more than 1 type. #91

@rquadling

Description

@rquadling

Hi.

Coming from PHP, specifically PHP 7.1 where the concept of union types are supported.

Currently, where a method may return more than 1 type - commonly a boolean false and some other type, this is documented as mixed.

For example:

mixed strpos ( string $haystack , mixed $needle [, int $offset = 0 ] )

This is rendered from this docbook snippet:

  <methodsynopsis>
   <type>mixed</type><methodname>strpos</methodname>
   <methodparam><type>string</type><parameter>haystack</parameter></methodparam>
   <methodparam><type>mixed</type><parameter>needle</parameter></methodparam>
   <methodparam choice="opt"><type>int</type><parameter>offset</parameter><initializer>0</initializer></methodparam>
  </methodsynopsis>

The result for this function will either be a boolean false or a positive integer, but as a single <type> is allowed, <type>mixed</type> is what we are currently using.

It would be useful to enhance docbook to allow for multiple types for <methodsynopsis> and <methodparam>.

So, my proposal is a new tag of <types> that allows for 2 or more <type>.

methodsynopsis ::=
	Sequence of:
		Zero or more of:
			modifier
		Optionally one of:
			type
			types
				Two or more of:
					type
			void
		methodname
		One of:
			One or more of:
				group (db.group.methodparam)
				methodparam
			void
		Zero or more of:
			exceptionname
		Zero or more of:
			modifier

and

methodparam ::=
	Sequence of:
		Zero or more of:
			modifier
		Optionally one of
			type
			types
				Two or more of:
					type
		One of:
			Sequence of:
				Zero or more of:
					modifier
				parameter
				initializer?
			funcparams
		Zero or more of:
			modifier

If there are other places where a <type> is defined, these may also need to be expanded to allow for multiple types.

If there is no way to require 2 or more of a child tag, then 1 or more would be fine, and would make <type>int</type> the same as <types><type>int</type></types>.

I'm happy to make a proper pull request if pointed in the right direction.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions