Skip to content

Replace @deprecated by #[\Deprecated] for internal functions / class constants - #14750

Merged
TimWolla merged 1 commit into
php:masterfrom
TimWolla:DeprecatedAttribute-apply
Jul 10, 2024
Merged

Replace @deprecated by #[\Deprecated] for internal functions / class constants#14750
TimWolla merged 1 commit into
php:masterfrom
TimWolla:DeprecatedAttribute-apply

Conversation

@TimWolla

Copy link
Copy Markdown
Member

This is spun out of and depends on #11293.

@TimWolla

Copy link
Copy Markdown
MemberAuthor

In the previous PR there were some unresolved threads from @Girgias remaining (regarding version information / messages). And there was a discussion regarding the formatting of the version within the $since. You can find it here: #11293 (comment)

Comment threadext/libxml/libxml.stub.php Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

reason: because entity loading is disabled by default since PHP 8.0.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

@nielsdos Would libxml_disable_entity_loader(false) reenable it or not?

@ndosschendosscheJul 4, 2024

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes but only when also passing LIBXML_NOENT to the parsing options of the XML extensions.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I understand that external entities are dangerous, but the deprecation without any alternative sounds wrong.

Anyway: Do you have a specific wording suggestion here? Best to suggest it using GitHub's suggestion feature.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

but the deprecation without any alternative sounds wrong.

You can still use them though, this was necessary to combat shit defaults in libxml2 < v2.9. Since PHP 8.0 we require at least libxml2 v2.9 and so the problem went away.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
#[\Deprecated(since: '8.0')]
#[\Deprecated(message: 'External entity loading is disabled by default', since: '8.0')]

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

You can still use them though.

I understand this is not the correct place for this discussion, but does it require the use of this deprecated function to enable them or will this happen automatically when calling libxml_set_external_entity_loader() or so? If the former, then this doesn't really feel like still being able to use them.

Regarding the change: Thanks, applied (with s/External/as external/ to better fit the grammar).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I understand this is not the correct place for this discussion, but does it require the use of this deprecated function to enable them

No you don't have to use this. You have to pass the LIBXML_NOENT option to an XML parser. libxml_set_external_entity_loader() is orthogonal to this

Comment threadext/mysqli/mysqli.stub.php Outdated

@GirgiasGirgias left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think I've covered all the reasonable alternatives now.

Comment threadext/intl/php_intl.stub.php Outdated
Comment threadext/intl/php_intl.stub.php Outdated
Comment threadext/openssl/openssl.stub.php Outdated
Comment threadext/openssl/openssl.stub.php Outdated
Comment threadext/openssl/openssl.stub.php Outdated
Comment threadext/enchant/enchant.stub.php Outdated
Comment threadext/date/php_date.stub.php Outdated
Comment threadext/date/php_date.stub.php Outdated
Comment threadext/date/php_date.stub.php Outdated
Comment threadext/date/php_date.stub.php Outdated
@TimWolla
TimWollaforce-pushed the DeprecatedAttribute-apply branch from 5fe18aa to 3110205CompareJuly 8, 2024 07:12
@TimWolla

Copy link
Copy Markdown
MemberAuthor

I think I've covered all the reasonable alternatives now.

Thanks, all applied and then slightly adjusted for formatting:

  • Moved the since parameter first in the stubs, because it is shorter.
  • Lowercase use in the message.
  • Use consistent phrasing for “use the IntlDateFormatter::format() method instead” 👉 “use IntlDateFormatter::format() instead”

@GirgiasGirgias left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM from my PoV

@TimWolla
TimWollaforce-pushed the DeprecatedAttribute-apply branch from 7620042 to 1c1c6ceCompareJuly 9, 2024 08:13
@TimWolla

Copy link
Copy Markdown
MemberAuthor

@Girgias I just did a rebase of the stuff you already reviewed and pushed some more commits to add the missing data / to correct some data. All deprecations have a since value filled in (based on the version where the @deprecated was added first or based on the docs depending on what I could find more easily). I've also added a message where the docs already explained what to do succinctly.

@TimWolla
TimWolla requested a review from GirgiasJuly 9, 2024 08:40
Comment threadext/date/tests/gmstrftime_variation20.phpt Outdated
Comment threadext/hash/hash.stub.php Outdated
Comment threadext/zip/tests/zip_entry_open.phpt Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Okay this is a complete aside, but I just realized that in the documentation, our manual style guide requires use to say "deprecated as of PHP 8.0" instead of "since", not sure if this is something we should match or not, but that's orthogonal to this PR.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I think keeping consistency with the property name is valuable here.

…ass constants
Co-authored-by: Gina Peter Banyard <girgias@php.net>
Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@TimWolla@kocsismate@ndossche@Girgias