diff --git a/phpdotnet/phd/Package/Generic/XHTML.php b/phpdotnet/phd/Package/Generic/XHTML.php index 256aa71a7..9e6d64bb6 100644 --- a/phpdotnet/phd/Package/Generic/XHTML.php +++ b/phpdotnet/phd/Package/Generic/XHTML.php @@ -478,8 +478,9 @@ abstract class Package_Generic_XHTML extends Format_Abstract_XHTML { "modifier" => "public", ), "methodsynopsis" => array( - "returntypes" => [], - "type_separator" => null, + "returntypes" => array(), + "type_separator" => array(), + "type_separator_stack" => array(), ), "co" => 0, "callouts" => 0, @@ -1277,10 +1278,10 @@ public function format_parameter($open, $name, $attrs, $props) } public function format_void($open, $name, $attrs, $props) { - if ($props['sibling'] == 'methodname') { + if (isset($props['sibling']) && $props['sibling'] == 'methodname') { return '('; } else { - return 'void'; + return 'void'; } } diff --git a/phpdotnet/phd/Package/PHP/XHTML.php b/phpdotnet/phd/Package/PHP/XHTML.php index 7c59b05b4..f1cc5e3b1 100644 --- a/phpdotnet/phd/Package/PHP/XHTML.php +++ b/phpdotnet/phd/Package/PHP/XHTML.php @@ -11,8 +11,13 @@ abstract class Package_PHP_XHTML extends Package_Generic_XHTML { 'colophon' => 'format_chunk', 'function' => 'format_function', 'methodname' => 'format_function', + 'methodparam' => 'format_methodparam', 'methodsynopsis' => 'format_methodsynopsis', 'legalnotice' => 'format_chunk', + 'parameter' => array( + /* DEFAULT */ 'format_parameter', + 'methodparam' => 'format_methodparam_parameter', + ), 'part' => 'format_container_chunk', 'partintro' => 'format_partintro', 'preface' => 'format_chunk', @@ -70,9 +75,16 @@ abstract class Package_PHP_XHTML extends Package_Generic_XHTML { 'type' => array( /* DEFAULT */ 'format_type', 'methodsynopsis' => 'format_methodsynopsis_type', + 'methodparam' => 'format_type_methodparam', 'type' => array( /* DEFAULT */ 'format_type', - 'methodsynopsis' => 'format_suppressed_tags', + 'methodsynopsis' => 'format_methodsynopsis_type', + 'methodparam' => 'format_type_methodparam', + 'type' => array( + /* DEFAULT */ 'format_type', + 'methodsynopsis' => 'format_methodsynopsis_type', + 'methodparam' => 'format_type_methodparam', + ), ), ), 'varname' => array( @@ -120,14 +132,20 @@ abstract class Package_PHP_XHTML extends Package_Generic_XHTML { ), 'refname' => 'format_refname_text', 'type' => array( - /* DEFAULT */ 'format_type_if_object_or_pseudo_text', + /* DEFAULT */ 'format_type_text', 'classsynopsisinfo' => false, - 'fieldsynopsis' => 'format_type_if_object_or_pseudo_text', - 'methodparam' => 'format_type_if_object_or_pseudo_text', + 'fieldsynopsis' => 'format_type_text', + 'methodparam' => 'format_type_methodparam_text', 'methodsynopsis' => 'format_type_methodsynopsis_text', 'type' => array( - /* DEFAULT */ 'format_type_if_object_or_pseudo_text', + /* DEFAULT */ 'format_type_text', 'methodsynopsis' => 'format_type_methodsynopsis_text', + 'methodparam' => 'format_type_methodparam_text', + 'type' => array( + /* DEFAULT */ 'format_type_text', + 'methodsynopsis' => 'format_type_methodsynopsis_text', + 'methodparam' => 'format_type_methodparam_text', + ), ), ), 'titleabbrev' => array( @@ -167,13 +185,18 @@ abstract class Package_PHP_XHTML extends Package_Generic_XHTML { "refname" => array(), "alternatives" => array(), "refsynopsisdiv" => null, + "methodparam" => array( + "type_separator" => array(), + "type_separator_stack" => array(), + "paramtypes" => array(), + ), ); /** @var int|null Number of already formatted types in the current compound type */ private $num_types = null; - /** @var string|null The character to separate the current compound type, i.e. "|" or "&" */ - private $type_separator = null; + /** @var array The characters to separate the current compound types, i.e. "|" or "&" */ + private $type_separator = []; /** @var bool|null Decides whether the union type can be displayed by using "?" */ private $simple_nullable = null; @@ -344,14 +367,19 @@ public function format_type($open, $tag, $attrs, $props) { strpos($props["innerXml"], 'null') !== false ) { $this->simple_nullable = true; - $this->type_separator = ""; + $this->type_separator[] = ""; $retval .= '?'; } else { - $this->type_separator = $isUnionType ? "|" : "&"; + $typeSeparator = match ($attrs[Reader::XMLNS_DOCBOOK]["class"]) { + "union" => "|", + "intersection" => "&", + default => "", + }; + $this->type_separator[] = $typeSeparator; } } elseif (isset($this->num_types)) { if ($this->num_types > 0) { - $retval .= $this->type_separator; + $retval .= end($this->type_separator); } $this->num_types++; @@ -361,7 +389,7 @@ public function format_type($open, $tag, $attrs, $props) { } else { if (isset($attrs[Reader::XMLNS_DOCBOOK]["class"])) { $this->num_types = null; - $this->type_separator = null; + array_pop($this->type_separator); $this->simple_nullable = null; } $retval .= ''; @@ -370,10 +398,23 @@ public function format_type($open, $tag, $attrs, $props) { return $retval; } - public function format_methodsynopsis_type($open, $tag, $attrs) - { - if ($open && isset($attrs[Reader::XMLNS_DOCBOOK]["class"])) { - $this->cchunk["methodsynopsis"]["type_separator"] = $attrs[Reader::XMLNS_DOCBOOK]["class"] === "union" ? "|" : "&"; + public function format_methodsynopsis_type($open, $tag, $attrs) { + if ($open) { + if (isset($attrs[Reader::XMLNS_DOCBOOK]["class"])) { + $this->cchunk["methodsynopsis"]["type_separator_stack"][] = match ($attrs[Reader::XMLNS_DOCBOOK]["class"]) { + "union" => "|", + "intersection" => "&", + }; + } + } else { + if ( + isset($attrs[Reader::XMLNS_DOCBOOK]["class"]) + && ($attrs[Reader::XMLNS_DOCBOOK]["class"] === "union" + || $attrs[Reader::XMLNS_DOCBOOK]["class"] === "intersection") + ) { + $lastSeparator = array_pop($this->cchunk["methodsynopsis"]["type_separator_stack"]); + $this->cchunk["methodsynopsis"]["type_separator"][count($this->cchunk["methodsynopsis"]["type_separator"]) - 1] = end($this->cchunk["methodsynopsis"]["type_separator_stack"]) ?: $lastSeparator; + } } return ""; @@ -481,64 +522,136 @@ public function format_methodsynopsis($open, $name, $attrs, $props) { $content = ""; if ($this->params["paramCount"] > 3) { $content .= "
"; + } else if ($this->params["paramCount"] === 0) { + $content .= "("; } $content .= ")"; if ($this->cchunk["methodsynopsis"]["returntypes"]) { - $types = []; - $this->type_separator = $this->cchunk["methodsynopsis"]["type_separator"]; + $type = $this->format_types( + $this->cchunk["methodsynopsis"]["type_separator"], + $this->cchunk["methodsynopsis"]["returntypes"] + ); - if ( - $this->type_separator === "|" && - count($this->cchunk["methodsynopsis"]["returntypes"]) === 2 && - in_array("null", $this->cchunk["methodsynopsis"]["returntypes"], true) - ) { - $this->simple_nullable = true; - $this->type_separator = ""; - $types[] = '?'; - } + $content .= ': ' . $type; + } - foreach ($this->cchunk["methodsynopsis"]["returntypes"] as $return_type) { - $formatted_type = self::format_type_if_object_or_pseudo_text($return_type, "type"); - if ($formatted_type === false) { - $formatted_type = $return_type; - } - if ($formatted_type !== "") { + $content .= "\n"; + $this->cchunk["methodsynopsis"] = $this->dchunk["methodsynopsis"]; + + return $content; + } + + private function format_types($type_separators, $paramOrReturnType) { + $types = []; + + if ( + $type_separators[0] === "|" && + count($paramOrReturnType) === 2 && + in_array("null", $paramOrReturnType, true) + ) { + $this->simple_nullable = true; + $type_separators[0] = ""; + $formatted_type = self::format_type_text("?", "type"); + $types[] = '' . $formatted_type .''; + } + + foreach ($paramOrReturnType as $individualType) { + $formatted_type = self::format_type_text($individualType, "type"); + if ($formatted_type === false) { + $formatted_type = $individualType; + } + if ($formatted_type !== "") { + if ($individualType === "void") { + $types[] = $formatted_type; + } else { $types[] = '' . $formatted_type . ''; } } + } - $type = implode($this->type_separator ?? '', $types); - if (count($types) > 1) { - $type = '' . $type . ''; - } - $content .= ': ' . $type; - $this->simple_nullable = null; + $type = ""; + $isDnfType = (in_array("&", $type_separators, true) && in_array("|", $type_separators, true)); + for ($i = 0; $i < count($types); $i++) { + $previousSeparator = ($i > 0 ) ? $type_separators[$i - 1] : ""; + $openingParenthesis = ($isDnfType && $type_separators[$i] === "&" && $previousSeparator !== "&") ? "(" : ""; + $closingParenthesis = ($isDnfType && $type_separators[$i] !== "&" && $previousSeparator === "&") ? ")" : ""; + + $type .= $openingParenthesis . $types[$i] . $closingParenthesis . $type_separators[$i]; } + $type = rtrim($type, end($type_separators)); - $content .= "\n"; - $this->cchunk["methodsynopsis"] = $this->dchunk["methodsynopsis"]; + if (count($types) > 1) { + $type = '' . $type . ''; + } + $this->simple_nullable = null; - return $content; + return $type; } public function format_type_methodsynopsis_text($type, $tagname) { $this->cchunk["methodsynopsis"]["returntypes"][] = $type; + $this->cchunk["methodsynopsis"]["type_separator"][] = end($this->cchunk["methodsynopsis"]["type_separator_stack"]); return ""; } - public function format_type_if_object_or_pseudo_text($type, $tagname) { - if (strtolower($type) === "null" && $this->simple_nullable) { - return ""; + public function format_methodparam_parameter($open, $name, $attrs, $props) { + $type = ""; + if ($open) { + if ($this->cchunk["methodparam"]["paramtypes"]) { + $type = $this->format_types( + $this->cchunk["methodparam"]["type_separator"], + $this->cchunk["methodparam"]["paramtypes"] + ); + } + $this->cchunk["methodparam"] = $this->dchunk["methodparam"]; } + return $type . parent::format_methodparam_parameter($open, $name, $attrs, $props); + } - if (in_array(strtolower($type), array("bool", "int", "double", "boolean", "integer", "float", "string", "array", "object", "resource", "null"))) { - return false; + public function format_methodparam($open, $name, $attrs) { + if ($open) { + $this->cchunk["methodparam"] = $this->dchunk["methodparam"]; + return parent::format_methodparam($open, $name, $attrs); } - return self::format_type_text($type, $tagname); + if ($this->params["opt"] && !$this->params["init"]) { + return ' = ?'; + } + $this->params["init"] = false; + $this->cchunk["methodparam"] = $this->dchunk["methodparam"]; + return ""; + } + + public function format_type_methodparam($open, $tag, $attrs) { + if ($open) { + if (isset($attrs[Reader::XMLNS_DOCBOOK]["class"])) { + $this->cchunk["methodparam"]["type_separator_stack"][] = match ($attrs[Reader::XMLNS_DOCBOOK]["class"]) { + "union" => "|", + "intersection" => "&", + }; + } + } else { + if ( + isset($attrs[Reader::XMLNS_DOCBOOK]["class"]) + && ($attrs[Reader::XMLNS_DOCBOOK]["class"] === "union" + || $attrs[Reader::XMLNS_DOCBOOK]["class"] === "intersection") + ) { + $lastSeparator = array_pop($this->cchunk["methodparam"]["type_separator_stack"]); + $this->cchunk["methodparam"]["type_separator"][count($this->cchunk["methodparam"]["type_separator"]) - 1] = end($this->cchunk["methodparam"]["type_separator_stack"]) ?: $lastSeparator; + } + } + + return ""; + } + + public function format_type_methodparam_text($type, $tagname) { + $this->cchunk["methodparam"]["paramtypes"][] = $type; + $this->cchunk["methodparam"]["type_separator"][] = end($this->cchunk["methodparam"]["type_separator_stack"]); + + return ""; } public function format_type_text($type, $tagname) { @@ -546,6 +659,8 @@ public function format_type_text($type, $tagname) { $href = $fragment = ""; switch($t) { + case "void": + return $this->format_void(false, '', [], []); case "bool": $href = "language.types.boolean"; break; @@ -555,6 +670,17 @@ public function format_type_text($type, $tagname) { case "double": $href = "language.types.float"; break; + case "?": + $href = "language.types.null"; + break; + case "false": + case "true": + $href = "language.types.value"; + break; + case "null": + if ($this->simple_nullable) { + return ""; + } case "boolean": case "integer": case "float": @@ -562,30 +688,38 @@ public function format_type_text($type, $tagname) { case "array": case "object": case "resource": - case "null": - if ($this->simple_nullable) { - return ""; - } case "callable": case "iterable": - $href = "language.types.$t"; - break; case "mixed": - $href = "language.types.declarations"; - $fragment = "language.types.declarations.$t"; + case "never": + $href = "language.types.$t"; break; default: /* Check if its a classname. */ $href = Format::getFilename("class.$t"); } + if ($href === false) { + return false; + } + + $classNames = ($type === "?") ? ($tagname . ' null') : ($tagname . ' ' . $type); if ($href && $this->chunked) { - return '' .$type. ''; + return '' .$type. ''; } if ($href) { - return '' .$type. ''; + return '' .$type. ''; + } + return '' .$type. ''; + } + + public function format_void($open, $name, $attrs, $props) { + if (isset($props['sibling']) && $props['sibling'] == 'methodname') { + $this->cchunk["methodsynopsis"]["returntypes"][] = "void"; + $this->cchunk["methodsynopsis"]["type_separator"][] = ""; + return ''; } - return '' .$type. ''; + return parent::format_void($open, $name, $attrs, $props); } public function format_example_title($open, $name, $attrs, $props) { diff --git a/tests/php/bug49102-1.phpt b/tests/php/bug49102-1.phpt index d3f0f0ffe..e489ded72 100644 --- a/tests/php/bug49102-1.phpt +++ b/tests/php/bug49102-1.phpt @@ -63,26 +63,28 @@ Content:
/* Methods */
- __construct()
+ __construct(): void -
setIteratorMode(int $mode): void
+
setIteratorMode(int $mode): void
/* Inherited methods */
-
SplDoublyLinkedList::bottom(): mixed
+
SplDoublyLinkedList::bottom(): mixedvoid
-
SplDoublyLinkedList::count(): int
+
SplDoublyLinkedList::count(): intvoid
-
SplDoublyLinkedList::current(): mixed
+
SplDoublyLinkedList::current(): mixedvoid
-
SplDoublyLinkedList::getIteratorMode(): int
+
SplDoublyLinkedList::getIteratorMode(): intvoid
-
SplDoublyLinkedList::offsetExists(mixed $index): bool
+
SplDoublyLinkedList::offsetExists(mixed $index): bool
-
SplDoublyLinkedList::offsetGet(mixed $index): mixed
+
SplDoublyLinkedList::offsetGet(mixed $index): mixed
} + + diff --git a/tests/php/data/type_rendering_constructorsynopsis_parameters-and-return-type.xml b/tests/php/data/type_rendering_constructorsynopsis_parameters-and-return-type.xml new file mode 100644 index 000000000..2d531928b --- /dev/null +++ b/tests/php/data/type_rendering_constructorsynopsis_parameters-and-return-type.xml @@ -0,0 +1,94 @@ + + + +
+ 1. Constructor with no parameters, no return type + + final public ClassName::__construct + +
+ +
+ 2. Constructor with no parameters, void (element) return type + + final public ClassName::__construct + + +
+ +
+ 3. Constructor with one parameter + + final private ClassName::__construct + mixedanything + +
+ +
+ 4. Constructor with optional parameter + + final protected ClassName::__construct + intcount0 + +
+ +
+ 5. Constructor with nullable parameter + + final public ClassName::__construct + floatnullvalue + +
+ +
+ 6. Constructor with nullable optional parameter + + final private ClassName::__construct + stringnulloptions"" + +
+ +
+ 7. Constructor with reference parameter + + final protected ClassName::__construct + arrayreference + +
+ +
+ 8. Constructor with union type parameter + + final public ClassName::__construct + iterableresourcecallablenulloption + +
+ +
+ 9. Constructor with intersection type parameter + + final public ClassName::__construct + CountableTraversableoption + +
+ +
+ 10. Constructor with DNF (Disjunctive Normal Form) type parameter + + final public ClassName::__construct + CountableTraversableDOMAttroption + +
+ +
+ 11. Constructor with more than three parameters + + final private ClassName::__construct + intcount + stringname + boolisSomething + arraylist + +
+ +
diff --git a/tests/php/data/type_rendering_methodsynopsis_parameters.xml b/tests/php/data/type_rendering_methodsynopsis_parameters.xml new file mode 100644 index 000000000..f2912f1f3 --- /dev/null +++ b/tests/php/data/type_rendering_methodsynopsis_parameters.xml @@ -0,0 +1,86 @@ + + + +
+ 1. Function/method with no parameters + + function_name + +
+ +
+ 2. Function/method with one parameter + + function_name + mixedanything + +
+ +
+ 3. Function/method with optional parameter + + function_name + intcount0 + +
+ +
+ 4. Function/method with nullable parameter + + function_name + floatnullvalue + +
+ +
+ 5. Function/method with nullable optional parameter + + function_name + stringnulloptions"" + +
+ +
+ 6. Function/method with reference parameter + + function_name + arrayreference + +
+ +
+ 7. Function/method with union type parameter + + function_name + iterableresourcecallablenulloption + +
+ +
+ 8. Function/method with intersection type parameter + + function_name + CountableTraversableoption + +
+ +
+ 9. Function/method with DNF (Disjunctive Normal Form) type parameter + + function_name + CountableTraversableDOMAttroption + +
+ +
+ 10. Function/method with more than three parameters + + function_name + intcount + stringname + boolisSomething + arraylist + +
+ +
diff --git a/tests/php/data/type_rendering_methodsynopsis_return_types.xml b/tests/php/data/type_rendering_methodsynopsis_return_types.xml new file mode 100644 index 000000000..cc973a88f --- /dev/null +++ b/tests/php/data/type_rendering_methodsynopsis_return_types.xml @@ -0,0 +1,75 @@ + + + +
+ 1. Function/method with no return type + + function_name + +
+ +
+ 2. Function/method with one return type - never + + neverfunction_name + +
+ +
+ 3. Function/method with one return type - void + + voidfunction_name + +
+ +
+ 4. Function/method with one return type - void element + + function_name + + +
+ +
+ 5. Function/method with one return type - mixed + + mixedfunction_name + +
+ +
+ 6. Function/method with union return type + + intfloatfalsefunction_name + +
+ +
+ 7. Function/method with nullable return type + + objectnullfunction_name + +
+ +
+ 8. Function/method with nullable union return type + + stringarrayresourcecallableiterabletruenullfunction_name + +
+ +
+ 9. Function/method with unknown return type + + UnknownTypefunction_name + +
+ +
diff --git a/tests/php/type_rendering_001.phpt b/tests/php/type_rendering_001.phpt new file mode 100644 index 000000000..3e0d2545e --- /dev/null +++ b/tests/php/type_rendering_001.phpt @@ -0,0 +1,94 @@ +--TEST-- +Type rendering 001 - Methodsynopsis return types +--FILE-- + true, + "xml_root" => dirname($xml_file), + "xml_file" => $xml_file, + "output_dir" => __DIR__ . "/output/", +); + +$extra = array( + "lang_dir" => __PHDDIR__ . "phpdotnet/phd/data/langs/", + "phpweb_version_filename" => dirname($xml_file) . '/version.xml', + "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', +); + +$render = new TestRender($formatclass, $opts, $extra); + +if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { + mkdir($opts["output_dir"], 0755); +} + +$render->run(); +?> +--EXPECT-- +Filename: type-rendering-methodsynopsis-return-types.html +Content: +
+ +
+

1. Function/method with no return type

+
+ function_name()
+ +
+ +
+

2. Function/method with one return type - never

+
function_name(): never
+ +
+ +
+

3. Function/method with one return type - void

+
function_name(): void
+ +
+ +
+

4. Function/method with one return type - void element

+
function_name(): void
+ +
+ +
+

5. Function/method with one return type - mixed

+
function_name(): mixed
+ +
+ +
+

6. Function/method with union return type

+
function_name(): int|float|false
+ +
+ +
+

7. Function/method with nullable return type

+
function_name(): ?object
+ +
+ +
+

8. Function/method with nullable union return type

+ + +
+ +
+

9. Function/method with unknown return type

+
function_name(): UnknownType
+ +
+ +
diff --git a/tests/php/type_rendering_002.phpt b/tests/php/type_rendering_002.phpt new file mode 100644 index 000000000..e44a1c80a --- /dev/null +++ b/tests/php/type_rendering_002.phpt @@ -0,0 +1,100 @@ +--TEST-- +Type rendering 002 - Methodsynopsis parameters and parameter types +--FILE-- + true, + "xml_root" => dirname($xml_file), + "xml_file" => $xml_file, + "output_dir" => __DIR__ . "/output/", +); + +$extra = array( + "lang_dir" => __PHDDIR__ . "phpdotnet/phd/data/langs/", + "phpweb_version_filename" => dirname($xml_file) . '/version.xml', + "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', +); + +$render = new TestRender($formatclass, $opts, $extra); + +if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { + mkdir($opts["output_dir"], 0755); +} + +$render->run(); +?> +--EXPECT-- +Filename: type-rendering-methodsynopsis-parameters.html +Content: +
+ +
+

1. Function/method with no parameters

+
+ function_name()
+ +
+ +
+

2. Function/method with one parameter

+
function_name(mixed $anything)
+ +
+ +
+

3. Function/method with optional parameter

+
function_name(int $count = 0)
+ +
+ +
+

4. Function/method with nullable parameter

+
function_name(?float $value)
+ +
+ +
+

5. Function/method with nullable optional parameter

+
function_name(?string $options = "")
+ +
+ +
+

6. Function/method with reference parameter

+
function_name(array &$reference)
+ +
+ +
+

7. Function/method with union type parameter

+
function_name(iterable|resource|callable|null $option)
+ +
+ +
+

8. Function/method with intersection type parameter

+
function_name(Countable&Traversable $option)
+ +
+ +
+

9. Function/method with DNF (Disjunctive Normal Form) type parameter

+
function_name((Countable&Traversable)|DOMAttr $option)
+ +
+ +
+

10. Function/method with more than three parameters

+
function_name(
    int $count,
    string $name,
    bool $isSomething,
    array $list
)
+ +
+ +
diff --git a/tests/php/type_rendering_003.phpt b/tests/php/type_rendering_003.phpt new file mode 100644 index 000000000..03a30c7d4 --- /dev/null +++ b/tests/php/type_rendering_003.phpt @@ -0,0 +1,106 @@ +--TEST-- +Type rendering 003 - Constructorsynopsis parameters and parameter types +--FILE-- + true, + "xml_root" => dirname($xml_file), + "xml_file" => $xml_file, + "output_dir" => __DIR__ . "/output/", +); + +$extra = array( + "lang_dir" => __PHDDIR__ . "phpdotnet/phd/data/langs/", + "phpweb_version_filename" => dirname($xml_file) . '/version.xml', + "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', +); + +$render = new TestRender($formatclass, $opts, $extra); + +if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { + mkdir($opts["output_dir"], 0755); +} + +$render->run(); +?> +--EXPECT-- +Filename: type-rendering-constructorsynopsis-parameters-and-return-type.html +Content: +
+ +
+

1. Constructor with no parameters, no return type

+
+ final public ClassName::__construct()
+ +
+ +
+

2. Constructor with no parameters, void (element) return type

+
final public ClassName::__construct(): void
+ +
+ +
+

3. Constructor with one parameter

+
final private ClassName::__construct(mixed $anything)
+ +
+ +
+

4. Constructor with optional parameter

+
final protected ClassName::__construct(int $count = 0)
+ +
+ +
+

5. Constructor with nullable parameter

+
final public ClassName::__construct(?float $value)
+ +
+ +
+

6. Constructor with nullable optional parameter

+
final private ClassName::__construct(?string $options = "")
+ +
+ +
+

7. Constructor with reference parameter

+
final protected ClassName::__construct(array &$reference)
+ +
+ +
+

8. Constructor with union type parameter

+
final public ClassName::__construct(iterable|resource|callable|null $option)
+ +
+ +
+

9. Constructor with intersection type parameter

+
final public ClassName::__construct(Countable&Traversable $option)
+ +
+ +
+

10. Constructor with DNF (Disjunctive Normal Form) type parameter

+
final public ClassName::__construct((Countable&Traversable)|DOMAttr $option)
+ +
+ +
+

11. Constructor with more than three parameters

+
final private ClassName::__construct(
    int $count,
    string $name,
    bool $isSomething,
    array $list
)
+ +
+ +