* Replace `ob_get_contents();ob_clean()` with `ob_get_clean()`
`ob_get_clean()` is equivalent to `ob_get_contents()` followed by `ob_clean()`.
* Replace `intval()` calls with `(int)` type cast
This is a micro-optimization because `intval()` is a function call, and the type cast is about 6 times fast.
* Replace `preg_replace` call that could be done with an `rtrim()` call
In `./error.php`, there is a `preg_replace('!/+$!', '', $URI);` call that essentially is equivalent to `rtrim()`, that both calls removing trailing slash characters in `$URI`.
The `rtim()` call is more legible and faster.
* Combine consecutive `str_replace` calls to a single `str_replace` call
* Use short ternary operator where possible
Improves code readability.
* Cascade various `else` statements where possible
Cleans up the code by removing unnecessary `else` blocks and moving the code to the parent context if the previous `if` block exits the function by either terminating the script, or with a `return` statement.
* Combine multiple `isset()` calls to a single `isset()`
`isset()` accepts multiple parameters and returns `true` only if all of the parameters are `isset`. It makes sense to combine multiple individual `isset` calls to a single call for better readability.
* Replace `for` loop with a `foreach` loop
* Remove unnecessary character escapes in regular expressions
Regular expression special characters are context-sensitive. For example, special characters such as `.` are not considered special within square braces (`[]`).
This removes several of such instances that certain characters are escaped, but it is not strictly necessary within the context. This improves the readability of the expression.
See more information at [PHP.Watch: Writing better Regular Expressions in PHP](https://php.watch/articles/php-regex-readability#reduce-escape)
* Remove unnecessary break statement
* Remove unnecessary PHP close tags
* Remove redundant JSON_ERROR_NONE check
Remove unnecessary `json_last_error() == JSON_ERROR_NONE` where the decoded object is inspected already.
Closes GH-603.
- Rewrite version-specific part of releases API to loop over releases
only once
- Releases API: filter by minor or patch version, if provided
- Remove unused variable
- Rewrite version_array() to use array_pad(). Intended behavior:
- If count($versionArray) is less than $length, version_array()
should pad it with 0s to $length.
- If count($versionArray) is greater than $length, version_array()
should slice it to $length.
- If $length is not set, leave $versionArray as-is after exploding it.
- Remove unused variable
- Still print "Unknown version" if the major version is found but the
minor or patch version is not.
- Remove excess white space
- Bind array_replace_recursive() result to new variable instead of
mutating $RELEASES global
- Only set $machineReadable to its first element if $machineReadable is
not empty.
Changed the behaviour of get_active_branches() so that callers can
choose whether to get recently EOLed branches or not. (This is basically
for the supported versions page; the other callers -- namely the front
page download links and bug tracker backend -- likely still want the
previous behaviour.)
After all, it's a little weird listing 5.5 as a supported version in the
table when we just made a big deal of EOLing it!
For "modern" PHP branches (5.3 onwards), we'll base whether they're considered
active purely off the support dates for the branch. To ensure that we don't
immediately remove the download links for EOL branches from the front page,
we'll still consider them "active" for those purposes for 28 days after the
final release.
Basically, rather than having two sources of truth for whether a branch is EOL
or not (the flag and the support dates in branches.inc), we now have one (the
support dates). This should be an improvement.