Skip to content

Conversation

@Girgias
Copy link
Member

@Girgias Girgias commented Nov 13, 2020

No description provided.

@cmb69
Copy link
Member

cmb69 commented Jul 24, 2021

Could you please rebase?

@Girgias Girgias force-pushed the link-new-type-decl-page branch from bb6997d to 6b08acb Compare July 24, 2021 22:31
@Girgias
Copy link
Member Author

Girgias commented Jul 24, 2021

Done the rebase and did some clean-up for the support for void at the same time (and add static although unlikely).

I also don't really understand the purpose of the format_type_if_object_or_pseudo_text() function.

$href = "language.types.$t";
break;
case "mixed":
case "void":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a format_void() methodas well, which apparently renders void return types.

Copy link
Member

@kocsismate kocsismate Jul 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I added 2 <span class="type">?</span> tags yesterday, which IMO should be updated as well

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum, I don't really know how to do this frankly, because from my understanding this works on the XML? So I would imagine it gets initially rendered with links like A|null before getting transformed again?

And I'll drop void then, didn't know it was already handled

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, phd converts XML to HTML, but in case of simple nullable types, I had to discard the render of the null subtype, and insert a <span class="type">?</span> before the other subtype of the union type gets rendered. So what I wanted to ask you is to add the href directly to these HTML tags as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you point me to where to the name of this function?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format_type() doesn't call format_type_text() so I didn't update it as I imagine this is already not displaying links.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format_type() is only called for rendering the tag itself, but format_type_text() is automatically called for the text inside the type tags. Now, that you changed format_methodsynopsis(), ? has the link at the return type positions, but since format_type_text() was left out, ? at parameter positions`are missing the links.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's still another problem with simple nullable parameters:

/* Methods */
public __construct(
    ? $locale,
    int $dateType,
    int $timeType,
    IntlTimeZone|DateTimeZone|string|null $timezone = null,
    IntlCalendar|int|null $calendar = null,
    string $pattern = ""
)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Frankly I do not understand how the fuck these method call happen, so I have no clue if what I'm doing makes any sense. When I opened this PR initially it was just after a commit which broke the generation of the links, so I looked at this and tried to fix it. But I have ZERO understanding of PhD, and just trying to figure out how shit works here is... painful.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit better now: ? characters both at the parameter as well as the return type position have the link. However, neither void, not false have them. As mentioned previously, you can add the link directly to the former one at phpdotnet/phd/Package/Generic/XHTML.php:1045, but I'm not sure what to do with false.

In order to fix the issue with the disappearing type in case of simple nullable types, you have to apply the following patch:

Index: phpdotnet/phd/Package/PHP/XHTML.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/phpdotnet/phd/Package/PHP/XHTML.php b/phpdotnet/phd/Package/PHP/XHTML.php
--- a/phpdotnet/phd/Package/PHP/XHTML.php	(revision e64f1141d524e7ad56e0a88c5cf161cfe5a6341d)
+++ b/phpdotnet/phd/Package/PHP/XHTML.php	(date 1627560074288)
@@ -546,12 +546,14 @@
         case "array":
         case "object":
         case "resource":
+        case "callable":
+        case "iterable":
+            $href = "language.types.$t";
+            break;
         case "null":
             if ($this->simple_nullable) {
                 return "";
             }
-        case "callable":
-        case "iterable":
             $href = "language.types.$t";
             break;
         case "mixed":

if ($this->cchunk["methodsynopsis"]["returntypes"]) {
$types = [];
foreach ($this->cchunk["methodsynopsis"]["returntypes"] as $return_type) {
$formatted_type = self::format_type_if_object_or_pseudo_text($return_type, "type");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe phpdotnet\phd\Package_PHP_XHTML::format_type_if_object_or_pseudo_text is not used anywhere else so itcan be removed

@Girgias Girgias force-pushed the link-new-type-decl-page branch from 6b08acb to 49b2b7d Compare July 26, 2021 23:38
foreach ($this->cchunk["methodsynopsis"]["returntypes"] as $return_type) {
$formatted_type = self::format_type_if_object_or_pseudo_text($return_type, "type");
$formatted_type = self::format_type_text($return_type, "type");
if ($formatted_type === false) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a false return is impossible now

$href = "language.types.$t";
break;
case "mixed":
case "void":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit better now: ? characters both at the parameter as well as the return type position have the link. However, neither void, not false have them. As mentioned previously, you can add the link directly to the former one at phpdotnet/phd/Package/Generic/XHTML.php:1045, but I'm not sure what to do with false.

In order to fix the issue with the disappearing type in case of simple nullable types, you have to apply the following patch:

Index: phpdotnet/phd/Package/PHP/XHTML.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/phpdotnet/phd/Package/PHP/XHTML.php b/phpdotnet/phd/Package/PHP/XHTML.php
--- a/phpdotnet/phd/Package/PHP/XHTML.php	(revision e64f1141d524e7ad56e0a88c5cf161cfe5a6341d)
+++ b/phpdotnet/phd/Package/PHP/XHTML.php	(date 1627560074288)
@@ -546,12 +546,14 @@
         case "array":
         case "object":
         case "resource":
+        case "callable":
+        case "iterable":
+            $href = "language.types.$t";
+            break;
         case "null":
             if ($this->simple_nullable) {
                 return "";
             }
-        case "callable":
-        case "iterable":
             $href = "language.types.$t";
             break;
         case "mixed":

@Girgias Girgias mentioned this pull request Feb 7, 2024
@haszi haszi mentioned this pull request Feb 11, 2024
@Girgias
Copy link
Member Author

Girgias commented Feb 13, 2024

Closed in favour of #94

@Girgias Girgias closed this Feb 13, 2024
@Girgias Girgias deleted the link-new-type-decl-page branch February 13, 2024 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants