The parser converts XHP syntax to standard PHP code. This file documents some parts of that conversion.
See :xhp::element2class
and :xhp::class2element
.
This method returns the child validation rules; it is used by XHP-Lib to enforce the child declarations at runtimes.
It returns:
1
: the element accepts any children0
: the element accepts no children- expr: A more complicated restraint; see below
array(
0 => expr_type [0-3],
1 => constraint_type,
2 => constraint_data,
)
|
array(
0 => expr_type [4-5],
1 => expr,
2 => expr,
)
- 0: single thing (
:thing
) - 1: any number of things (
:thing*
) - 2: zero or one things (
:thing?
) - 3: one or more things (
:thing+
) - 4: two things in sequence (
:athing, :anotherthing
) - 5: either of two things (
:athing || :anotherthing
)
- 1: any - no constraint.
constraint_data
is ignored. - 2: pcdata.
constraint_data
is ignored. - 3: specific element.
constraint_data
is astring
class name - 4: category.
constraint_data
is astring
category name - 5: expression.
constraint_data
is an expression.
This returns a map from attribute names to declarations. Declarations match the following:
array(
0 => TYPE_STRING|TYPE_BOOL|TYPE_INTEGER|TYPE_ARRAY|TYPE_VAR|TYPE_FLOAT,
1 => ignored,
2 => default: ?mixed,
3 => required: 1|0,
)
|
array(
0 => TYPE_OBJECT,
1 => class name: string,
2 => default: ?mixed,
3 => required: 1|0,
)
|
array(
0 => TYPE_ENUM,
1 => enum values: array<string>,
2 => default: ?string,
3 => required: 1|0,
)
These constants are currently declared in :x:node
.