In general, the :php:enum: and :php:case: directives work just like :php:class: and :php:const:, respectively. However, to support backed enums, I got a little creative and introduced a minor new syntax to the signature line.
The use of () ->, however, is intended to convey method parameters and a return type, which isn't appropriate semantics for a backed enum type and case values, so I decided to introduce this new syntax.
When it renders, Sphinx displays it with the arrow symbol (→) as if it is a return type, but we don't have much choice, since we must use one of the methods from sphinx.addnodes, and I chose to use desc_returns().
I think this is very reasonable syntax. docutils is big on : as separators so using it for enum name/values seems inline with other extensions I've seen.
This PR adds support for PHP enumerations.
In general, the
:php:enum:
and:php:case:
directives work just like:php:class:
and:php:const:
, respectively. However, to support backed enums, I got a little creative and introduced a minor new syntax to the signature line.Here's a very simple, basic enum example:
Here's the same example as a backed enum:
This new syntax is effectively the same as this:
The use of
() ->
, however, is intended to convey method parameters and a return type, which isn't appropriate semantics for a backed enum type and case values, so I decided to introduce this new syntax.When it renders, Sphinx displays it with the arrow symbol (→) as if it is a return type, but we don't have much choice, since we must use one of the methods from
sphinx.addnodes
, and I chose to usedesc_returns()
.