Page MenuHomePhabricator

PHP Coding conventions: 3 Backslashes?
Closed, DeclinedPublic

Description

It seems to me that in the context of regexp replacements 4 backslashes are preferred over 3 backslashes.

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Math/+/826932

However, there are some instances of 3 backslashes in core.

https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+blame/94d71c83c16d47c4c2a3b4aa0a579d77689a231d/includes/api/ApiErrorFormatter.php#242

$class = preg_replace( '#^Wikimedia\\\Rdbms\\\#', '', get_class( $exception ) );

https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+blame/94d71c83c16d47c4c2a3b4aa0a579d77689a231d/includes/api/ApiMain.php#1309

$class = preg_replace( '#^Wikimedia\\\Rdbms\\\#', '', get_class( $e ) );

Now my question is:

  1. Are there good reasons for 3 backslashes?
  2. Should we replace the existing instances of 3 backslashes with 4 backslashes?

Event Timeline

Aklapper renamed this task from PHP Coding conventions: 3 Backlsashes? to PHP Coding conventions: 3 Backslashes?.Aug 27 2022, 7:17 PM

Currently, not a priority.