Skip to content

Commit

Permalink
phpcs: enable psr2
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Oct 16, 2016
1 parent 0cc631c commit 5fb7ea1
Show file tree
Hide file tree
Showing 44 changed files with 175 additions and 109 deletions.
3 changes: 2 additions & 1 deletion .php_cs
Expand Up @@ -5,7 +5,7 @@ $finder = Symfony\CS\Finder\DefaultFinder::create()
; ;


return Symfony\CS\Config\Config::create() return Symfony\CS\Config\Config::create()
->level(Symfony\CS\FixerInterface::NONE_LEVEL) ->level(Symfony\CS\FixerInterface::PSR2_LEVEL)
->setUsingCache(true) ->setUsingCache(true)
->fixers(array( ->fixers(array(
'linefeed', 'linefeed',
Expand All @@ -21,6 +21,7 @@ return Symfony\CS\Config\Config::create()
'controls_spaces', 'controls_spaces',
'elseif', 'elseif',
'-eof_ending', '-eof_ending',
'-method_argument_space',
)) ))
->finder($finder) ->finder($finder)
; ;
6 changes: 4 additions & 2 deletions lib/HTTP/ConditionalGet.php
Expand Up @@ -60,7 +60,8 @@
* @subpackage HTTP * @subpackage HTTP
* @author Stephen Clay <steve@mrclay.org> * @author Stephen Clay <steve@mrclay.org>
*/ */
class HTTP_ConditionalGet { class HTTP_ConditionalGet
{


/** /**
* Does the client have a valid copy of the requested resource? * Does the client have a valid copy of the requested resource?
Expand Down Expand Up @@ -340,7 +341,8 @@ protected function resourceMatchedEtag()
* *
* @return string * @return string
*/ */
protected function normalizeEtag($etag) { protected function normalizeEtag($etag)
{
$etag = trim($etag); $etag = trim($etag);


return $this->_stripEtag return $this->_stripEtag
Expand Down
12 changes: 5 additions & 7 deletions lib/HTTP/Encoder.php
Expand Up @@ -43,7 +43,8 @@
* @subpackage HTTP * @subpackage HTTP
* @author Stephen Clay <steve@mrclay.org> * @author Stephen Clay <steve@mrclay.org>
*/ */
class HTTP_Encoder { class HTTP_Encoder
{


/** /**
* Should the encoder allow HTTP encoding to IE6? * Should the encoder allow HTTP encoding to IE6?
Expand Down Expand Up @@ -97,8 +98,7 @@ public function __construct($spec)
$this->_headers['Content-Type'] = $spec['type']; $this->_headers['Content-Type'] = $spec['type'];
} }
if (isset($spec['method']) if (isset($spec['method'])
&& in_array($spec['method'], array('gzip', 'deflate', 'compress', ''))) && in_array($spec['method'], array('gzip', 'deflate', 'compress', ''))) {
{
$this->_encodeMethod = array($spec['method'], $spec['method']); $this->_encodeMethod = array($spec['method'], $spec['method']);
} else { } else {
$this->_encodeMethod = self::getAcceptedEncoding(); $this->_encodeMethod = self::getAcceptedEncoding();
Expand Down Expand Up @@ -192,8 +192,7 @@ public static function getAcceptedEncoding($allowCompress = true, $allowDeflate
// @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html // @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html


if (! isset($_SERVER['HTTP_ACCEPT_ENCODING']) if (! isset($_SERVER['HTTP_ACCEPT_ENCODING'])
|| self::isBuggyIe()) || self::isBuggyIe()) {
{
return array('', ''); return array('', '');
} }
$ae = $_SERVER['HTTP_ACCEPT_ENCODING']; $ae = $_SERVER['HTTP_ACCEPT_ENCODING'];
Expand Down Expand Up @@ -259,8 +258,7 @@ public function encode($compressionLevel = null)
} }
if ('' === $this->_encodeMethod[0] if ('' === $this->_encodeMethod[0]
|| ($compressionLevel == 0) || ($compressionLevel == 0)
|| !extension_loaded('zlib')) || !extension_loaded('zlib')) {
{
return false; return false;
} }
if ($this->_encodeMethod[0] === 'deflate') { if ($this->_encodeMethod[0] === 'deflate') {
Expand Down
16 changes: 8 additions & 8 deletions lib/Minify.php
Expand Up @@ -24,7 +24,8 @@
* @license http://opensource.org/licenses/bsd-license.php New BSD License * @license http://opensource.org/licenses/bsd-license.php New BSD License
* @link https://github.com/mrclay/minify * @link https://github.com/mrclay/minify
*/ */
class Minify { class Minify
{


/** /**
* API version * API version
Expand Down Expand Up @@ -87,7 +88,8 @@ class Minify {
* @param Minify_CacheInterface $cache * @param Minify_CacheInterface $cache
* @param LoggerInterface $logger * @param LoggerInterface $logger
*/ */
public function __construct(Minify_CacheInterface $cache, LoggerInterface $logger = null) { public function __construct(Minify_CacheInterface $cache, LoggerInterface $logger = null)
{
$this->cache = $cache; $this->cache = $cache;
$this->logger = $logger; $this->logger = $logger;
} }
Expand Down Expand Up @@ -492,7 +494,8 @@ public function errorExit($header, $url = '', $msgHtml = '')
* @param string $content * @param string $content
* @return string * @return string
*/ */
public static function nullMinifier($content) { public static function nullMinifier($content)
{
if (isset($content[0]) && $content[0] === "\xef") { if (isset($content[0]) && $content[0] === "\xef") {
$content = substr($content, 3); $content = substr($content, 3);
} }
Expand All @@ -506,7 +509,7 @@ public static function nullMinifier($content) {
*/ */
protected function setupUriRewrites() protected function setupUriRewrites()
{ {
foreach($this->sources as $key => $source) { foreach ($this->sources as $key => $source) {
$file = $this->env->normalizePath($source->getFilePath()); $file = $this->env->normalizePath($source->getFilePath());
$minifyOptions = $source->getMinifierOptions(); $minifyOptions = $source->getMinifierOptions();


Expand Down Expand Up @@ -594,8 +597,7 @@ protected function combineMinify()
|| $type === self::TYPE_CSS // yes, to process CSS individually (avoiding PCRE bugs/limits) || $type === self::TYPE_CSS // yes, to process CSS individually (avoiding PCRE bugs/limits)
|| $minifier !== $lastMinifier // yes, minifier changed || $minifier !== $lastMinifier // yes, minifier changed
|| $options !== $lastOptions) // yes, options changed || $options !== $lastOptions) // yes, options changed
) ) {
{
// minify previous sources with last settings // minify previous sources with last settings
$imploded = implode($implodeSeparator, $groupToProcessTogether); $imploded = implode($implodeSeparator, $groupToProcessTogether);
$groupToProcessTogether = array(); $groupToProcessTogether = array();
Expand Down Expand Up @@ -718,7 +720,6 @@ protected function analyzeSources($options = array())
if (!empty($options['contentType'])) { if (!empty($options['contentType'])) {
// just verify sources have null content type or match the options // just verify sources have null content type or match the options
if ($sourceType !== null && $sourceType !== $options['contentType']) { if ($sourceType !== null && $sourceType !== $options['contentType']) {

$this->logger && $this->logger->warning('ContentType mismatch'); $this->logger && $this->logger->warning('ContentType mismatch');


$this->sources = array(); $this->sources = array();
Expand All @@ -732,7 +733,6 @@ protected function analyzeSources($options = array())
if ($type === null) { if ($type === null) {
$type = $sourceType; $type = $sourceType;
} elseif ($sourceType !== $type) { } elseif ($sourceType !== $type) {

$this->logger && $this->logger->warning('ContentType mismatch'); $this->logger && $this->logger->warning('ContentType mismatch');


$this->sources = array(); $this->sources = array();
Expand Down
9 changes: 6 additions & 3 deletions lib/Minify/App.php
Expand Up @@ -21,7 +21,8 @@
* @property \Minify_Source_Factory $sourceFactory * @property \Minify_Source_Factory $sourceFactory
* @property array $sourceFactoryOptions * @property array $sourceFactoryOptions
*/ */
class App extends Container { class App extends Container
{


/** /**
* Constructor * Constructor
Expand Down Expand Up @@ -249,7 +250,8 @@ public function __construct($dir)
}; };
} }


public function runServer() { public function runServer()
{
if (!$this->env->get('f') && $this->env->get('g') === null) { if (!$this->env->get('f') && $this->env->get('g') === null) {
// no spec given // no spec given
$msg = '<p>No "f" or "g" parameters were detected.</p>'; $msg = '<p>No "f" or "g" parameters were detected.</p>';
Expand All @@ -265,7 +267,8 @@ public function runServer() {
* @param mixed $var * @param mixed $var
* @return string * @return string
*/ */
private function typeOf($var) { private function typeOf($var)
{
$type = gettype($var); $type = gettype($var);


return $type === 'object' ? get_class($var) : $type; return $type === 'object' ? get_class($var) : $type;
Expand Down
8 changes: 5 additions & 3 deletions lib/Minify/Build.php
Expand Up @@ -34,7 +34,8 @@
* @package Minify * @package Minify
* @author Stephen Clay <steve@mrclay.org> * @author Stephen Clay <steve@mrclay.org>
*/ */
class Minify_Build { class Minify_Build
{


/** /**
* Last modification time of all files in the build * Last modification time of all files in the build
Expand Down Expand Up @@ -67,15 +68,16 @@ class Minify_Build {
* append the timestamp to the URI. * append the timestamp to the URI.
* @return string * @return string
*/ */
public function uri($uri, $forceAmpersand = false) { public function uri($uri, $forceAmpersand = false)
{
$sep = ($forceAmpersand || strpos($uri, '?') !== false) $sep = ($forceAmpersand || strpos($uri, '?') !== false)
? self::$ampersand ? self::$ampersand
: '?'; : '?';


return "{$uri}{$sep}{$this->lastModified}"; return "{$uri}{$sep}{$this->lastModified}";
} }


/** /**
* Create a build object * Create a build object
* *
* @param array $sources array of Minify_Source objects and/or file paths * @param array $sources array of Minify_Source objects and/or file paths
Expand Down
3 changes: 2 additions & 1 deletion lib/Minify/CSS.php
Expand Up @@ -16,7 +16,8 @@
* *
* @deprecated Use Minify_CSSmin * @deprecated Use Minify_CSSmin
*/ */
class Minify_CSS { class Minify_CSS
{


/** /**
* Minify a CSS string * Minify a CSS string
Expand Down
6 changes: 4 additions & 2 deletions lib/Minify/CSS/Compressor.php
Expand Up @@ -26,7 +26,8 @@
* *
* @deprecated Use CSSmin (tubalmartin/cssmin) * @deprecated Use CSSmin (tubalmartin/cssmin)
*/ */
class Minify_CSS_Compressor { class Minify_CSS_Compressor
{


/** /**
* Minify a CSS string * Minify a CSS string
Expand Down Expand Up @@ -61,7 +62,8 @@ public static function process($css, $options = array())
* *
* @param array $options (currently ignored) * @param array $options (currently ignored)
*/ */
private function __construct($options) { private function __construct($options)
{
$this->_options = $options; $this->_options = $options;
} }


Expand Down
9 changes: 6 additions & 3 deletions lib/Minify/CSS/UriRewriter.php
Expand Up @@ -10,7 +10,8 @@
* @package Minify * @package Minify
* @author Stephen Clay <steve@mrclay.org> * @author Stephen Clay <steve@mrclay.org>
*/ */
class Minify_CSS_UriRewriter { class Minify_CSS_UriRewriter
{


/** /**
* rewrite() and rewriteRelative() append debugging information here * rewrite() and rewriteRelative() append debugging information here
Expand Down Expand Up @@ -326,7 +327,8 @@ private static function _processUriCB($m)
* @param string $css * @param string $css
* @return string * @return string
*/ */
private static function _owlifySvgPaths($css) { private static function _owlifySvgPaths($css)
{
return preg_replace('~\b((?:clip-path|mask|-webkit-mask)\s*\:\s*)url(\(\s*#\w+\s*\))~', '$1owl$2', $css); return preg_replace('~\b((?:clip-path|mask|-webkit-mask)\s*\:\s*)url(\(\s*#\w+\s*\))~', '$1owl$2', $css);
} }


Expand All @@ -338,7 +340,8 @@ private static function _owlifySvgPaths($css) {
* @param string $css * @param string $css
* @return string * @return string
*/ */
private static function _unOwlify($css) { private static function _unOwlify($css)
{
return preg_replace('~\b((?:clip-path|mask|-webkit-mask)\s*\:\s*)owl~', '$1url', $css); return preg_replace('~\b((?:clip-path|mask|-webkit-mask)\s*\:\s*)owl~', '$1url', $css);
} }
} }
3 changes: 2 additions & 1 deletion lib/Minify/CSSmin.php
Expand Up @@ -12,7 +12,8 @@
* @package Minify * @package Minify
* @author Stephen Clay <steve@mrclay.org> * @author Stephen Clay <steve@mrclay.org>
*/ */
class Minify_CSSmin { class Minify_CSSmin
{


/** /**
* Minify a CSS string * Minify a CSS string
Expand Down
3 changes: 2 additions & 1 deletion lib/Minify/Cache/APC.php
Expand Up @@ -14,7 +14,8 @@
* @package Minify * @package Minify
* @author Chris Edwards * @author Chris Edwards
**/ **/
class Minify_Cache_APC implements Minify_CacheInterface { class Minify_Cache_APC implements Minify_CacheInterface
{


/** /**
* Create a Minify_Cache_APC object, to be passed to * Create a Minify_Cache_APC object, to be passed to
Expand Down
5 changes: 3 additions & 2 deletions lib/Minify/Cache/File.php
Expand Up @@ -6,7 +6,8 @@


use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;


class Minify_Cache_File implements Minify_CacheInterface { class Minify_Cache_File implements Minify_CacheInterface
{


/** /**
* @var string * @var string
Expand Down Expand Up @@ -117,7 +118,7 @@ public function display($id)
} }
} }


/** /**
* Fetch the cached content * Fetch the cached content
* *
* @param string $id cache id (e.g. a filename) * @param string $id cache id (e.g. a filename)
Expand Down
7 changes: 4 additions & 3 deletions lib/Minify/Cache/Memcache.php
Expand Up @@ -17,7 +17,8 @@
* } * }
* </code> * </code>
**/ **/
class Minify_Cache_Memcache implements Minify_CacheInterface { class Minify_Cache_Memcache implements Minify_CacheInterface
{


/** /**
* Create a Minify_Cache_Memcache object, to be passed to * Create a Minify_Cache_Memcache object, to be passed to
Expand Down Expand Up @@ -92,7 +93,7 @@ public function display($id)
: ''; : '';
} }


/** /**
* Fetch the cached content * Fetch the cached content
* *
* @param string $id cache id * @param string $id cache id
Expand All @@ -114,7 +115,7 @@ public function fetch($id)
private $_data = null; private $_data = null;
private $_id = null; private $_id = null;


/** /**
* Fetch data and timestamp from memcache, store in instance * Fetch data and timestamp from memcache, store in instance
* *
* @param string $id * @param string $id
Expand Down
3 changes: 2 additions & 1 deletion lib/Minify/Cache/Null.php
Expand Up @@ -8,7 +8,8 @@
* *
* @package Minify * @package Minify
*/ */
class Minify_Cache_Null implements Minify_CacheInterface { class Minify_Cache_Null implements Minify_CacheInterface
{
/** /**
* Write data to cache. * Write data to cache.
* *
Expand Down
10 changes: 5 additions & 5 deletions lib/Minify/Cache/WinCache.php
Expand Up @@ -99,12 +99,12 @@ public function fetch($id)
return $this->_fetch($id) ? $this->_data : ''; return $this->_fetch($id) ? $this->_data : '';
} }


private $_exp = NULL; private $_exp = null;


// cache of most recently fetched id // cache of most recently fetched id
private $_lm = NULL; private $_lm = null;
private $_data = NULL; private $_data = null;
private $_id = NULL; private $_id = null;


/** /**
* Fetch data and timestamp from WinCache, store in instance * Fetch data and timestamp from WinCache, store in instance
Expand All @@ -121,7 +121,7 @@ private function _fetch($id)
$suc = false; $suc = false;
$ret = wincache_ucache_get($id, $suc); $ret = wincache_ucache_get($id, $suc);
if (!$suc) { if (!$suc) {
$this->_id = NULL; $this->_id = null;


return false; return false;
} }
Expand Down
3 changes: 2 additions & 1 deletion lib/Minify/Cache/XCache.php
Expand Up @@ -17,7 +17,8 @@
* @package Minify * @package Minify
* @author Elan Ruusamäe <glen@delfi.ee> * @author Elan Ruusamäe <glen@delfi.ee>
**/ **/
class Minify_Cache_XCache implements Minify_CacheInterface { class Minify_Cache_XCache implements Minify_CacheInterface
{


/** /**
* Create a Minify_Cache_XCache object, to be passed to * Create a Minify_Cache_XCache object, to be passed to
Expand Down
3 changes: 2 additions & 1 deletion lib/Minify/Cache/ZendPlatform.php
Expand Up @@ -16,7 +16,8 @@
* @package Minify * @package Minify
* @author Patrick van Dissel * @author Patrick van Dissel
*/ */
class Minify_Cache_ZendPlatform implements Minify_CacheInterface { class Minify_Cache_ZendPlatform implements Minify_CacheInterface
{


/** /**
* Create a Minify_Cache_ZendPlatform object, to be passed to * Create a Minify_Cache_ZendPlatform object, to be passed to
Expand Down
3 changes: 2 additions & 1 deletion lib/Minify/CacheInterface.php
Expand Up @@ -9,7 +9,8 @@
* *
* @package Minify * @package Minify
*/ */
interface Minify_CacheInterface { interface Minify_CacheInterface
{
/** /**
* Write data to cache. * Write data to cache.
* *
Expand Down

0 comments on commit 5fb7ea1

Please sign in to comment.