-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate deprecation warning box for the manual #14938
base: master
Are you sure you want to change the base?
Conversation
$refsynopsisDiv = $doc->createElement('refsynopsisdiv'); | ||
$deprecationEntity = $doc->createEntityReference( | ||
'warn.deprecated.' . (isset($aliasMap[$this->name->__toString()]) ? 'alias' : 'function-') . | ||
str_replace(".", "-", $this->deprecatedSince) . "-0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TimWolla The since
property currently doesn't contain the patch version. However, theoretically it's possible to deprecate symbols in patch versions as well... So I'm wondering whether the .0
suffix could be added to the property value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, currently, 3rd party extensions shouldn't really use Deprecated
attributes... because currently I have to assume that the value of the since
property relates to PHP versions, and not the version of the extension itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, theoretically it's possible to deprecate symbols in patch versions as well... So I'm wondering whether the .0 suffix could be added to the property value?
I don't see a value-add in that. Deprecations in patch version should be very rare. As an example, if folks convert deprecations to Exceptions this would cause a break. Yes, folks should not do that, but they do.
Pretending that the deprecation was there in the .0
version is a good enough approximation, because only the latest patch version of a branch is supported anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, currently, 3rd party extensions shouldn't really use
Deprecated
attributes... because currently I have to assume that the value of thesince
property relates to PHP versions, and not the version of the extension itself.
if ($funcInfo->deprecatedSince) { | ||
foreach ($doc->getElementsByTagName("refentry") as $refentryElement) { | ||
foreach ($refentryElement->getElementsByTagName("refnamediv") as $refnameDivElement) { | ||
if (count($refnameDivElement->getElementsByTagName("refname")) !== 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The warning saying This function has been DEPRECATED as of ...
doesn't make sense on pages where multiple functions/methods are documented, so I skip the automatic addition of the box in such cases.
'warn.deprecated.' . (isset($aliasMap[$this->name->__toString()]) ? 'alias' : 'function-') . | ||
str_replace(".", "-", $this->deprecatedSince) . "-0" | ||
); | ||
$refsynopsisDiv->appendChild(new DOMText("\n ")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can actually simplify DOMText insertions as follows:
$refsynopsisDiv->appendChild(new DOMText("\n ")); | |
$refsynopsisDiv->append("\n "); |
or even combine the 3 appendChilds into one, but I guess you didn't do it because it would be a long line or would have to be multilined anyway.
Although for this to work, we would need gen_stub to properly generate the |
Yes, and there's another problem with the alternative suggestion: this information isn't available for phd. And as I found out, not even gen_stub.php can always generate this properly. :( On one hand, it's because the XML markup is missing when a symbol is referenced (e.g.: That's why I went with what I wrote in the description: the replacement only happens if there is no similar box added yet (then the "skeleton" text can be fine-tuned afterwards).
Yes, it would be awesome if it did! But then we should add the version numbers for all functions... Uh, it sounds like huge pain. |
If it's a huge pain, maybe leave it as is for now. :) |
The |
By using the information available by the newly added
Deprecated
property, the deprecation warning boxes in the manual can now be generated when not exists. (if it already exists, the box may contain different alternative suggestion than what's written in the stub, so this case is not handled).