WordPress.org

Make WordPress Core

Opened 22 months ago

Last modified 9 months ago

#42918 new enhancement

Replace intval(), strval(), ... function calls with type hints

Reported by: ayeshrajans Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch needs-testing
Focuses: performance Cc:
PR Number:

Description

PHP's intval(), strval(), floatval() and boolval() are from PHP 4 ages. PHP 5 and later has the type hinting pattern (e.g (int) $var) that is ~6x faster than their function-call counterpart.

There are over 250 such calls, and I'll upload a patch to replace them with type hints. The patch itself is large, but because intval() and (int) are identical in usage, I hope you can review it. The test suit passed (https://travis-ci.org/Ayesh/wordpress-develop/builds/317469175).

I have not changed anything in third party libraries (such as random_compat).

Thank you.

Attachments (2)

42918-php-typehints.patch (95.5 KB) - added by ayeshrajans 22 months ago.
ONe big patch with all changes
42918-2.patch (91.6 KB) - added by ayeshrajans 22 months ago.
Please disregard the previous patch. Uploading a new one with proper WP code styling. Thanks to https://github.com/Mahjouba91 for the review and additional fixes.

Download all attachments as: .zip

Change History (5)

@ayeshrajans
22 months ago

ONe big patch with all changes

#1 @desrosj
22 months ago

  • Focuses performance added
  • Keywords has-patch needs-testing added

@ayeshrajans
22 months ago

Please disregard the previous patch. Uploading a new one with proper WP code styling. Thanks to https://github.com/Mahjouba91 for the review and additional fixes.

#3 @pento
9 months ago

  • Version trunk deleted
Note: See TracTickets for help on using tickets.