jenkins-bot has submitted this change and it was merged.
Change subject: Pass phpcs-strict on includes/libs/
......................................................................
Pass phpcs-strict on includes/libs/
No changes to "real" libs. They are excluded from CodeSniffer tests.
Change-Id: Ifd14c0be24014fd9629a31e9bd155b27e2c0e93d
---
M includes/libs/CSSMin.php
M includes/libs/GenericArrayObject.php
M includes/libs/IEContentAnalyzer.php
M includes/libs/MWMessagePack.php
4 files changed, 68 insertions(+), 43 deletions(-)
Approvals:
Chad: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/libs/CSSMin.php b/includes/libs/CSSMin.php
index e3a3e2c..10277e6 100644
--- a/includes/libs/CSSMin.php
+++ b/includes/libs/CSSMin.php
@@ -112,7 +112,9 @@
* instead. If $sizeLimit is false, no limit is enforced.
* @return string|bool: Image contents encoded as a data URI or false.
*/
- public static function encodeImageAsDataURI( $file, $type = null,
$sizeLimit = self::EMBED_SIZE_LIMIT ) {
+ public static function encodeImageAsDataURI( $file, $type = null,
+ $sizeLimit = self::EMBED_SIZE_LIMIT
+ ) {
if ( $sizeLimit !== false && filesize( $file ) >= $sizeLimit ) {
return false;
}
@@ -175,13 +177,14 @@
}
/**
- * Remaps CSS URL paths and automatically embeds data URIs for CSS
rules or url() values
- * preceded by an / * @embed * / comment.
+ * Remaps CSS URL paths and automatically embeds data URIs for CSS rules
+ * or url() values preceded by an / * @embed * / comment.
*
* @param string $source CSS data to remap
* @param string $local File path where the source was read from
* @param string $remote URL path to the file
- * @param bool $embedData If false, never do any data URI embedding,
even if / * @embed * / is found
+ * @param bool $embedData If false, never do any data URI embedding,
+ * even if / * @embed * / is found.
* @return string Remapped CSS data
*/
public static function remap( $source, $local, $remote, $embedData =
true ) {
@@ -200,44 +203,65 @@
$remote = substr( $remote, 0, -1 );
}
- // Note: This will not correctly handle cases where ';', '{' or
'}' appears in the rule itself,
- // e.g. in a quoted string. You are advised not to use such
characters in file names.
- // We also match start/end of the string to be consistent in
edge-cases ('@import url(…)').
+ // Note: This will not correctly handle cases where ';', '{' or
'}'
+ // appears in the rule itself, e.g. in a quoted string. You are
advised
+ // not to use such characters in file names. We also match
start/end of
+ // the string to be consistent in edge-cases ('@import url(…)').
$pattern = '/(?:^|[;{])\K[^;{}]*' . CSSMin::URL_REGEX .
'[^;}]*(?=[;}]|$)/';
- return preg_replace_callback( $pattern, function ( $matchOuter
) use ( $local, $remote, $embedData ) {
- $rule = $matchOuter[0];
- // Check for global @embed comment and remove it
- $embedAll = false;
- $rule = preg_replace( '/^(\s*)' . CSSMin::EMBED_REGEX .
'\s*/', '$1', $rule, 1, $embedAll );
+ return preg_replace_callback(
+ $pattern,
+ function ( $matchOuter ) use ( $local, $remote,
$embedData ) {
+ $rule = $matchOuter[0];
- // Build two versions of current rule: with remapped
URLs and with embedded data: URIs (where possible)
- $pattern = '/(?P<embed>' . CSSMin::EMBED_REGEX .
'\s*|)' . CSSMin::URL_REGEX . '/';
+ // Check for global @embed comment and remove it
+ $embedAll = false;
+ $rule = preg_replace( '/^(\s*)' .
CSSMin::EMBED_REGEX . '\s*/', '$1', $rule, 1, $embedAll );
- $ruleWithRemapped = preg_replace_callback( $pattern,
function ( $match ) use ( $local, $remote ) {
- $remapped = CSSMin::remapOne( $match['file'],
$match['query'], $local, $remote, false );
- return CSSMin::buildUrlValue( $remapped );
- }, $rule );
+ // Build two versions of current rule: with
remapped URLs
+ // and with embedded data: URIs (where
possible).
+ $pattern = '/(?P<embed>' . CSSMin::EMBED_REGEX
. '\s*|)' . CSSMin::URL_REGEX . '/';
- if ( $embedData ) {
- $ruleWithEmbedded = preg_replace_callback(
$pattern, function ( $match ) use ( $embedAll, $local, $remote ) {
- $embed = $embedAll || $match['embed'];
- $embedded = CSSMin::remapOne(
$match['file'], $match['query'], $local, $remote, $embed );
- return CSSMin::buildUrlValue( $embedded
);
- }, $rule );
- }
+ $ruleWithRemapped = preg_replace_callback(
+ $pattern,
+ function ( $match ) use ( $local,
$remote ) {
+ $remapped = CSSMin::remapOne(
$match['file'], $match['query'], $local, $remote, false );
- if ( $embedData && $ruleWithEmbedded !==
$ruleWithRemapped ) {
- // Build 2 CSS properties; one which uses a
base64 encoded data URI in place
- // of the @embed comment to try and retain
line-number integrity, and the
- // other with a remapped an versioned URL and
an Internet Explorer hack
- // making it ignored in all browsers that
support data URIs
- return "$ruleWithEmbedded;$ruleWithRemapped!ie";
- } else {
- // No reason to repeat twice
- return $ruleWithRemapped;
- }
- }, $source );
+ return CSSMin::buildUrlValue(
$remapped );
+ },
+ $rule
+ );
+
+ if ( $embedData ) {
+ $ruleWithEmbedded =
preg_replace_callback(
+ $pattern,
+ function ( $match ) use (
$embedAll, $local, $remote ) {
+ $embed = $embedAll ||
$match['embed'];
+ $embedded =
CSSMin::remapOne(
+ $match['file'],
+ $match['query'],
+ $local,
+ $remote,
+ $embed
+ );
+
+ return
CSSMin::buildUrlValue( $embedded );
+ },
+ $rule
+ );
+ }
+
+ if ( $embedData && $ruleWithEmbedded !==
$ruleWithRemapped ) {
+ // Build 2 CSS properties; one which
uses a base64 encoded data URI in place
+ // of the @embed comment to try and
retain line-number integrity, and the
+ // other with a remapped an versioned
URL and an Internet Explorer hack
+ // making it ignored in all browsers
that support data URIs
+ return
"$ruleWithEmbedded;$ruleWithRemapped!ie";
+ } else {
+ // No reason to repeat twice
+ return $ruleWithRemapped;
+ }
+ }, $source );
}
/**
diff --git a/includes/libs/GenericArrayObject.php
b/includes/libs/GenericArrayObject.php
index d77d8ad..db8a7ec 100644
--- a/includes/libs/GenericArrayObject.php
+++ b/includes/libs/GenericArrayObject.php
@@ -33,7 +33,6 @@
* @author Jeroen De Dauw < [email protected] >
*/
abstract class GenericArrayObject extends ArrayObject {
-
/**
* Returns the name of an interface/class that the element should
implement/extend.
*
@@ -144,7 +143,8 @@
protected function setElement( $index, $value ) {
if ( !$this->hasValidType( $value ) ) {
throw new InvalidArgumentException(
- 'Can only add ' . $this->getObjectType() . '
implementing objects to ' . get_called_class() . '.'
+ 'Can only add ' . $this->getObjectType() . '
implementing objects to '
+ . get_called_class() . '.'
);
}
@@ -237,5 +237,4 @@
public function isEmpty() {
return $this->count() === 0;
}
-
}
diff --git a/includes/libs/IEContentAnalyzer.php
b/includes/libs/IEContentAnalyzer.php
index 7f461a0..a80f6d9 100644
--- a/includes/libs/IEContentAnalyzer.php
+++ b/includes/libs/IEContentAnalyzer.php
@@ -712,8 +712,9 @@
$xbmMagic2 = '_width';
$xbmMagic3 = '_bits';
$binhexMagic = 'converted with BinHex';
+ $chunkLength = strlen( $chunk );
- for ( $offset = 0; $offset < strlen( $chunk ); $offset++ ) {
+ for ( $offset = 0; $offset < $chunkLength; $offset++ ) {
$curChar = $chunk[$offset];
if ( $curChar == "\x0a" ) {
$counters['lf']++;
diff --git a/includes/libs/MWMessagePack.php b/includes/libs/MWMessagePack.php
index c61e8f8..cd9aad8 100644
--- a/includes/libs/MWMessagePack.php
+++ b/includes/libs/MWMessagePack.php
@@ -33,7 +33,6 @@
* @file
*/
class MWMessagePack {
-
/** @var boolean|null Whether current system is bigendian. **/
public static $bigendian = null;
@@ -75,7 +74,8 @@
} elseif ( $length <= 0xFFFFFFFF ) {
return pack( 'CNa*', 0xDB, $length, $value );
}
- throw new InvalidArgumentException( __METHOD__ . ":
string too long (length: $length; max: 4294967295)" );
+ throw new InvalidArgumentException( __METHOD__
+ . ": string too long (length: $length; max:
4294967295)" );
case 'integer':
if ( $value >= 0 ) {
@@ -142,7 +142,8 @@
$buffer = '';
$length = count( $value );
if ( $length > 0xFFFFFFFF ) {
- throw new InvalidArgumentException( __METHOD__
. ": array too long (length: $length, max: 4294967295)" );
+ throw new InvalidArgumentException( __METHOD__
+ . ": array too long (length: $length,
max: 4294967295)" );
}
$index = 0;
--
To view, visit https://gerrit.wikimedia.org/r/129545
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ifd14c0be24014fd9629a31e9bd155b27e2c0e93d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Siebrand <[email protected]>
Gerrit-Reviewer: Chad <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits