From f2ba93877bf62012ff9b8fa67c3bc658c34678c1 Mon Sep 17 00:00:00 2001 From: haszi Date: Tue, 20 Feb 2024 23:12:31 +0100 Subject: [PATCH] Fix doc-en GH-3197 - Incorrect void return type appended (#100) * Fix doc-en GH_3197 Fix void return type appended on void parameter list and add test for this fix. Fix tests with incorrect expected output. * Replace hardcoded html file extension for void type with the appropriate method call --------- Co-authored-by: haszi --- phpdotnet/phd/Package/Generic/XHTML.php | 2 +- phpdotnet/phd/Package/PHP/XHTML.php | 2 - tests/php/bug49102-1.phpt | 10 ++--- tests/php/bug_doc-en_GH-3179.phpt | 43 +++++++++++++++++++ tests/php/data/bug_doc-en_GH-3197.xml | 8 ++++ ...torsynopsis_parameters-and-return-type.xml | 26 ++++------- ..._rendering_methodsynopsis_return_types.xml | 20 +++------ tests/php/type_rendering_001.phpt | 24 ++++------- tests/php/type_rendering_003.phpt | 28 +++++------- 9 files changed, 92 insertions(+), 71 deletions(-) create mode 100644 tests/php/bug_doc-en_GH-3179.phpt create mode 100644 tests/php/data/bug_doc-en_GH-3197.xml diff --git a/phpdotnet/phd/Package/Generic/XHTML.php b/phpdotnet/phd/Package/Generic/XHTML.php index 20581b43..3c5ee6a1 100644 --- a/phpdotnet/phd/Package/Generic/XHTML.php +++ b/phpdotnet/phd/Package/Generic/XHTML.php @@ -1287,7 +1287,7 @@ public function format_void($open, $name, $attrs, $props) { 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 599df82d..4b2928f0 100644 --- a/phpdotnet/phd/Package/PHP/XHTML.php +++ b/phpdotnet/phd/Package/PHP/XHTML.php @@ -722,8 +722,6 @@ public function format_type_text($type, $tagname) { 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 parent::format_void($open, $name, $attrs, $props); diff --git a/tests/php/bug49102-1.phpt b/tests/php/bug49102-1.phpt index e489ded7..dd3f7902 100644 --- a/tests/php/bug49102-1.phpt +++ b/tests/php/bug49102-1.phpt @@ -63,19 +63,19 @@ Content:
/* Methods */
- __construct(): void
+ __construct()
setIteratorMode(int $mode): void
/* Inherited methods */
-
SplDoublyLinkedList::bottom(): mixedvoid
+
SplDoublyLinkedList::bottom(): mixed
-
SplDoublyLinkedList::count(): intvoid
+
SplDoublyLinkedList::count(): int
-
SplDoublyLinkedList::current(): mixedvoid
+
SplDoublyLinkedList::current(): mixed
-
SplDoublyLinkedList::getIteratorMode(): intvoid
+
SplDoublyLinkedList::getIteratorMode(): int
SplDoublyLinkedList::offsetExists(mixed $index): bool
diff --git a/tests/php/bug_doc-en_GH-3179.phpt b/tests/php/bug_doc-en_GH-3179.phpt new file mode 100644 index 00000000..fdab0849 --- /dev/null +++ b/tests/php/bug_doc-en_GH-3179.phpt @@ -0,0 +1,43 @@ +--TEST-- +Bug doc-en GH-3197 +--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: bug_doc-en_GH-3179.html +Content: +
+
+
method_name(): void
+ +
+ +
diff --git a/tests/php/data/bug_doc-en_GH-3197.xml b/tests/php/data/bug_doc-en_GH-3197.xml new file mode 100644 index 00000000..d1bc97b1 --- /dev/null +++ b/tests/php/data/bug_doc-en_GH-3197.xml @@ -0,0 +1,8 @@ + + + + voidmethod_name + + + + 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 index 2d531928..f2e8a0b1 100644 --- a/tests/php/data/type_rendering_constructorsynopsis_parameters-and-return-type.xml +++ b/tests/php/data/type_rendering_constructorsynopsis_parameters-and-return-type.xml @@ -9,15 +9,7 @@
- 2. Constructor with no parameters, void (element) return type - - final public ClassName::__construct - - -
- -
- 3. Constructor with one parameter + 2. Constructor with one parameter final private ClassName::__construct mixedanything @@ -25,7 +17,7 @@
- 4. Constructor with optional parameter + 3. Constructor with optional parameter final protected ClassName::__construct intcount0 @@ -33,7 +25,7 @@
- 5. Constructor with nullable parameter + 4. Constructor with nullable parameter final public ClassName::__construct floatnullvalue @@ -41,7 +33,7 @@
- 6. Constructor with nullable optional parameter + 5. Constructor with nullable optional parameter final private ClassName::__construct stringnulloptions"" @@ -49,7 +41,7 @@
- 7. Constructor with reference parameter + 6. Constructor with reference parameter final protected ClassName::__construct arrayreference @@ -57,7 +49,7 @@
- 8. Constructor with union type parameter + 7. Constructor with union type parameter final public ClassName::__construct iterableresourcecallablenulloption @@ -65,7 +57,7 @@
- 9. Constructor with intersection type parameter + 8. Constructor with intersection type parameter final public ClassName::__construct CountableTraversableoption @@ -73,7 +65,7 @@
- 10. Constructor with DNF (Disjunctive Normal Form) type parameter + 9. Constructor with DNF (Disjunctive Normal Form) type parameter final public ClassName::__construct CountableTraversableDOMAttroption @@ -81,7 +73,7 @@
- 11. Constructor with more than three parameters + 10. Constructor with more than three parameters final private ClassName::__construct intcount diff --git a/tests/php/data/type_rendering_methodsynopsis_return_types.xml b/tests/php/data/type_rendering_methodsynopsis_return_types.xml index cc973a88..8bc25be4 100644 --- a/tests/php/data/type_rendering_methodsynopsis_return_types.xml +++ b/tests/php/data/type_rendering_methodsynopsis_return_types.xml @@ -23,50 +23,42 @@
- 4. Function/method with one return type - void element - - function_name - - -
- -
- 5. Function/method with one return type - mixed + 4. Function/method with one return type - mixed mixedfunction_name
- 6. Function/method with union return type + 5. Function/method with union return type intfloatfalsefunction_name
- 7. Function/method with nullable return type + 6. Function/method with nullable return type objectnullfunction_name
- 8. Function/method with nullable union return type + 7. Function/method with nullable union return type stringarrayresourcecallableiterabletruenullfunction_name
- 9. Function/method with unknown return type + 8. Function/method with unknown return type UnknownTypefunction_name