1
0
mirror of https://github.com/php/web-php.git synced 2026-03-23 23:02:13 +01:00
Commit Graph

17 Commits

Author SHA1 Message Date
Andreas Möller
59c070f557 Enhancement: Enable blank_line_after_opening_tag fixer (#875) 2023-12-07 16:57:19 +01:00
Andreas Möller
c093fb5382 Enhancement: Enable trailing_comma_in_multiline fixer (#647)
* Enhancement: Enable and configure trailing_comma_in_multiline fixer

* Fix: Run 'make coding-standards'
2023-12-06 23:16:28 +00:00
Andreas Möller
a528e6e91b Enhancement: Enable no_mixed_echo_print fixer (#864) 2023-12-06 15:19:57 +01:00
Andreas Möller
1ebc2c4996 Enhancement: Enable binary_operator_spaces fixer
Closes GH-667.
2022-08-22 19:17:38 +02:00
Andreas Möller
d9bcfed482 Enhancement: Enable array_syntax fixer
Co-authored-by: MathiasReker <mathias@reker.dk>

Closes GH-659.
2022-08-22 18:59:14 +02:00
Ayesh Karunaratne
1b83fd7ab7 Multiple micro-optimizations
* 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.
2022-07-03 12:24:14 +02:00
Sara Golemon
c0afd74bf7 Swap uses of _SERVER[DOCUMENT_ROOT] for __DIR__
2/4 - Update remaining except archives/ and release/.
2019-05-31 12:31:21 -04:00
Peter Kokot
b5edd2d17b Change dirname(__FILE__) to shorter __DIR__ 2018-10-23 17:30:55 +02:00
Peter Kokot
dd8d8bf863 Sync final and leading newlines
This patch adds some missing newlines, trims some multiple redundant
final newlines into a single one, and trims few redundant leading
newlines.

According to POSIX, a line is a sequence of zero or more non-'<newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-17 12:37:26 +02:00
Peter Kokot
e235f79473 Trim trailing whitespace
This patch cleans all redundant trailing whitespace across the
repository except for the icalendar files.
2018-10-17 10:51:08 +02:00
Hannes Magnusson
6abdfb5c2f Kill browser cache 2013-12-10 21:50:41 -08:00
Hannes Magnusson
206aab8bf2 Cache the images for a day 2013-12-06 17:00:35 -08:00
Hannes Magnusson
e0dd9f1bf9 Fix same origin policy errors
Maybe this fixes stuff for Opera?
It fixes some issues in Chrome fetching the elephpants for example
on http://php.net (as the elephants requests www.php.net).

The policy check will automatically support all php.net subdomains
2013-12-04 00:41:53 -08:00
Hannes Magnusson
bcc4cfa62c Fix counting logic.. as we skip an item if it doesn't exist
Also, don't allow more then 50 pics
2013-12-04 00:03:32 -08:00
Hannes Magnusson
1d2a2e9ef6 Have a fixed limit here, and remove endless count()s 2013-11-22 00:35:00 -08:00
Stewart Lord
dd5d429188 Replace __DIR__ with dirname(__FILE__). It's easy to forget that this
constant was only added in 5.3 (some mirrors run old versions).
2011-09-22 06:11:35 +00:00
Stewart Lord
86c75aca35 Made elephpant image banner dynamic.
Elephpant images are pulled from flickr via the php-master server hourly.
The web site now provides a simple PHP script to serve a random sampling
of these images in JSON format.

The web browser now loads the elephpant images via JavaScript, requesting
only the number of images that are required to fill the viewport. Images
are inserted into the page using the data URI scheme. This ensures that 
only one http request is needed to load all of the required images.

If the browser window resizes, the JavaScript will fetch additional images
as required to fill out the viewport again. There is a slight delay built
in (250ms) to avoid excessive requests while the window is being resized.

Some browsers (e.g. older versions of MSIE) do not support the data URI
scheme. For these browsers we may wish to provide a fallback mechanism of
aggregating the images (e.g. MHTML, aka MIME HTML).

If the images fail to load, the elephant banner is hidden automatically.
2011-09-21 04:33:01 +00:00