1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-20 21:02:30 +02:00

Apply php-cs-fixer new rules

This commit is contained in:
Elan Ruusamäe
2019-12-11 17:00:16 +02:00
parent f9d3d54e62
commit eff278193b
88 changed files with 1225 additions and 1213 deletions

View File

@@ -1,7 +1,6 @@
<?php
/**
* Class Minify_Cache_APC
* @package Minify
*/
/**
@@ -11,17 +10,13 @@
* Minify::setCache(new Minify_Cache_APC());
* </code>
*
* @package Minify
* @author Chris Edwards
**/
class Minify_Cache_APC implements Minify_CacheInterface
{
/**
* Create a Minify_Cache_APC object, to be passed to
* Minify::setCache().
*
*
* @param int $expire seconds until expiration (default = 0
* meaning the item will not get an expiration date)
*
@@ -36,7 +31,6 @@ class Minify_Cache_APC implements Minify_CacheInterface
* Write data to cache.
*
* @param string $id cache id
*
* @param string $data
*
* @return bool success
@@ -55,29 +49,28 @@ class Minify_Cache_APC implements Minify_CacheInterface
*/
public function getSize($id)
{
if (! $this->_fetch($id)) {
if (!$this->_fetch($id)) {
return false;
}
if (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2)) {
if (function_exists('mb_strlen') && ((int) ini_get('mbstring.func_overload') & 2)) {
return mb_strlen($this->_data, '8bit');
} else {
return strlen($this->_data);
}
return strlen($this->_data);
}
/**
* Does a valid cache entry exist?
*
* @param string $id cache id
*
* @param int $srcMtime mtime of the original source file(s)
*
* @return bool exists
*/
public function isValid($id, $srcMtime)
{
return ($this->_fetch($id) && ($this->_lm >= $srcMtime));
return $this->_fetch($id) && ($this->_lm >= $srcMtime);
}
/**
@@ -102,12 +95,14 @@ class Minify_Cache_APC implements Minify_CacheInterface
return $this->_fetch($id) ? $this->_data : '';
}
private $_exp = null;
private $_exp;
// cache of most recently fetched id
private $_lm = null;
private $_data = null;
private $_id = null;
private $_lm;
private $_data;
private $_id;
/**
* Fetch data and timestamp from apc, store in instance
@@ -122,7 +117,7 @@ class Minify_Cache_APC implements Minify_CacheInterface
return true;
}
$ret = apc_fetch($id);
if (false === $ret) {
if ($ret === false) {
$this->_id = null;
return false;

View File

@@ -1,14 +1,11 @@
<?php
/**
* Class Minify_Cache_File
* @package Minify
*/
use Psr\Log\LoggerInterface;
class Minify_Cache_File implements Minify_CacheInterface
{
/**
* @var string
*/
@@ -31,7 +28,7 @@ class Minify_Cache_File implements Minify_CacheInterface
*/
public function __construct($path = '', $fileLocking = false, LoggerInterface $logger = null)
{
if (! $path) {
if (!$path) {
$path = sys_get_temp_dir();
}
$this->locking = $fileLocking;
@@ -47,7 +44,6 @@ class Minify_Cache_File implements Minify_CacheInterface
* Write data to cache.
*
* @param string $id cache id (e.g. a filename)
*
* @param string $data
*
* @return bool success
@@ -57,14 +53,14 @@ class Minify_Cache_File implements Minify_CacheInterface
$flag = $this->locking ? LOCK_EX : null;
$file = $this->path . '/' . $id;
if (! @file_put_contents($file, $data, $flag)) {
$this->logger->warning("Minify_Cache_File: Write failed to '$file'");
if (!@file_put_contents($file, $data, $flag)) {
$this->logger->warning("Minify_Cache_File: Write failed to '${file}'");
}
// write control
if ($data !== $this->fetch($id)) {
@unlink($file);
$this->logger->warning("Minify_Cache_File: Post-write read failed for '$file'");
$this->logger->warning("Minify_Cache_File: Post-write read failed for '${file}'");
return false;
}
@@ -88,7 +84,6 @@ class Minify_Cache_File implements Minify_CacheInterface
* Does a valid cache entry exist?
*
* @param string $id cache id (e.g. a filename)
*
* @param int $srcMtime mtime of the original source file(s)
*
* @return bool exists
@@ -97,7 +92,7 @@ class Minify_Cache_File implements Minify_CacheInterface
{
$file = $this->path . '/' . $id;
return (is_file($file) && (filemtime($file) >= $srcMtime));
return is_file($file) && (filemtime($file) >= $srcMtime);
}
/**
@@ -160,6 +155,7 @@ class Minify_Cache_File implements Minify_CacheInterface
* Get a usable temp directory
*
* @return string
*
* @deprecated
*/
public static function tmp()
@@ -171,8 +167,11 @@ class Minify_Cache_File implements Minify_CacheInterface
/**
* Send message to the Minify logger
*
* @param string $msg
*
* @return null
*
* @deprecated Use $this->logger
*/
protected function _log($msg)

View File

@@ -1,7 +1,6 @@
<?php
/**
* Class Minify_Cache_Memcache
* @package Minify
*/
/**
@@ -19,13 +18,11 @@
**/
class Minify_Cache_Memcache implements Minify_CacheInterface
{
/**
* Create a Minify_Cache_Memcache object, to be passed to
* Minify::setCache().
*
* @param Memcache $memcache already-connected instance
*
* @param int $expire seconds until expiration (default = 0
* meaning the item will not get an expiration date)
*/
@@ -39,7 +36,6 @@ class Minify_Cache_Memcache implements Minify_CacheInterface
* Write data to cache.
*
* @param string $id cache id
*
* @param string $data
*
* @return bool success
@@ -58,29 +54,28 @@ class Minify_Cache_Memcache implements Minify_CacheInterface
*/
public function getSize($id)
{
if (! $this->_fetch($id)) {
if (!$this->_fetch($id)) {
return false;
}
if (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2)) {
if (function_exists('mb_strlen') && ((int) ini_get('mbstring.func_overload') & 2)) {
return mb_strlen($this->_data, '8bit');
} else {
return strlen($this->_data);
}
return strlen($this->_data);
}
/**
* Does a valid cache entry exist?
*
* @param string $id cache id
*
* @param int $srcMtime mtime of the original source file(s)
*
* @return bool exists
*/
public function isValid($id, $srcMtime)
{
return ($this->_fetch($id) && ($this->_lm >= $srcMtime));
return $this->_fetch($id) && ($this->_lm >= $srcMtime);
}
/**
@@ -105,13 +100,16 @@ class Minify_Cache_Memcache implements Minify_CacheInterface
return $this->_fetch($id) ? $this->_data : '';
}
private $_mc = null;
private $_exp = null;
private $_mc;
private $_exp;
// cache of most recently fetched id
private $_lm = null;
private $_data = null;
private $_id = null;
private $_lm;
private $_data;
private $_id;
/**
* Fetch data and timestamp from memcache, store in instance
@@ -127,7 +125,7 @@ class Minify_Cache_Memcache implements Minify_CacheInterface
}
$ret = $this->_mc->get($id);
if (false === $ret) {
if ($ret === false) {
$this->_id = null;
return false;

View File

@@ -5,8 +5,6 @@
*
* If this is used, Minify will not use a cache and, for each 200 response, will
* need to recombine files, minify and encode the output.
*
* @package Minify
*/
class Minify_Cache_Null implements Minify_CacheInterface
{
@@ -64,4 +62,4 @@ class Minify_Cache_Null implements Minify_CacheInterface
public function fetch($id)
{
}
}
}

View File

@@ -1,7 +1,6 @@
<?php
/**
* Class Minify_Cache_Wincache
* @package Minify
*/
/**
@@ -11,8 +10,6 @@
* Minify::setCache(new Minify_Cache_WinCache());
* </code>
*
* @package Minify
* @author Matthias Fax
**/
class Minify_Cache_WinCache implements Minify_CacheInterface
{
@@ -28,7 +25,7 @@ class Minify_Cache_WinCache implements Minify_CacheInterface
public function __construct($expire = 0)
{
if (!function_exists('wincache_ucache_info')) {
throw new Exception("WinCache for PHP is not installed to be able to use Minify_Cache_WinCache!");
throw new Exception('WinCache for PHP is not installed to be able to use Minify_Cache_WinCache!');
}
$this->_exp = $expire;
}
@@ -37,7 +34,6 @@ class Minify_Cache_WinCache implements Minify_CacheInterface
* Write data to cache.
*
* @param string $id cache id
*
* @param string $data
*
* @return bool success
@@ -62,23 +58,22 @@ class Minify_Cache_WinCache implements Minify_CacheInterface
if (function_exists('mb_strlen') && ((int) ini_get('mbstring.func_overload') & 2)) {
return mb_strlen($this->_data, '8bit');
} else {
return strlen($this->_data);
}
return strlen($this->_data);
}
/**
* Does a valid cache entry exist?
*
* @param string $id cache id
*
* @param int $srcMtime mtime of the original source file(s)
*
* @return bool exists
*/
public function isValid($id, $srcMtime)
{
return ($this->_fetch($id) && ($this->_lm >= $srcMtime));
return $this->_fetch($id) && ($this->_lm >= $srcMtime);
}
/**
@@ -103,12 +98,14 @@ class Minify_Cache_WinCache implements Minify_CacheInterface
return $this->_fetch($id) ? $this->_data : '';
}
private $_exp = null;
private $_exp;
// cache of most recently fetched id
private $_lm = null;
private $_data = null;
private $_id = null;
private $_lm;
private $_data;
private $_id;
/**
* Fetch data and timestamp from WinCache, store in instance
@@ -136,4 +133,4 @@ class Minify_Cache_WinCache implements Minify_CacheInterface
return true;
}
}
}

View File

@@ -2,8 +2,7 @@
/**
* Class Minify_Cache_XCache
*
* @link http://xcache.lighttpd.net/
* @package Minify
* @see http://xcache.lighttpd.net/
*/
/**
@@ -14,12 +13,9 @@
* Minify::setCache(new Minify_Cache_XCache());
* </code>
*
* @package Minify
* @author Elan Ruusamäe <glen@delfi.ee>
**/
class Minify_Cache_XCache implements Minify_CacheInterface
{
/**
* Create a Minify_Cache_XCache object, to be passed to
* Minify::setCache().
@@ -37,6 +33,7 @@ class Minify_Cache_XCache implements Minify_CacheInterface
*
* @param string $id cache id
* @param string $data
*
* @return bool success
*/
public function store($id, $data)
@@ -48,19 +45,20 @@ class Minify_Cache_XCache implements Minify_CacheInterface
* Get the size of a cache entry
*
* @param string $id cache id
*
* @return int size in bytes
*/
public function getSize($id)
{
if (! $this->_fetch($id)) {
if (!$this->_fetch($id)) {
return false;
}
if (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2)) {
if (function_exists('mb_strlen') && ((int) ini_get('mbstring.func_overload') & 2)) {
return mb_strlen($this->_data, '8bit');
} else {
return strlen($this->_data);
}
return strlen($this->_data);
}
/**
@@ -68,11 +66,12 @@ class Minify_Cache_XCache implements Minify_CacheInterface
*
* @param string $id cache id
* @param int $srcMtime mtime of the original source file(s)
*
* @return bool exists
*/
public function isValid($id, $srcMtime)
{
return ($this->_fetch($id) && ($this->_lm >= $srcMtime));
return $this->_fetch($id) && ($this->_lm >= $srcMtime);
}
/**
@@ -89,6 +88,7 @@ class Minify_Cache_XCache implements Minify_CacheInterface
* Fetch the cached content
*
* @param string $id cache id
*
* @return string
*/
public function fetch($id)
@@ -96,17 +96,20 @@ class Minify_Cache_XCache implements Minify_CacheInterface
return $this->_fetch($id) ? $this->_data : '';
}
private $_exp = null;
private $_exp;
// cache of most recently fetched id
private $_lm = null;
private $_data = null;
private $_id = null;
private $_lm;
private $_data;
private $_id;
/**
* Fetch data and timestamp from xcache, store in instance
*
* @param string $id
*
* @return bool success
*/
private function _fetch($id)
@@ -116,7 +119,7 @@ class Minify_Cache_XCache implements Minify_CacheInterface
}
$ret = xcache_get($id);
if (false === $ret) {
if ($ret === false) {
$this->_id = null;
return false;

View File

@@ -1,7 +1,6 @@
<?php
/**
* Class Minify_Cache_ZendPlatform
* @package Minify
*/
/**
@@ -12,20 +11,15 @@
* <code>
* Minify::setCache(new Minify_Cache_ZendPlatform());
* </code>
*
* @package Minify
* @author Patrick van Dissel
*/
class Minify_Cache_ZendPlatform implements Minify_CacheInterface
{
/**
* Create a Minify_Cache_ZendPlatform object, to be passed to
* Minify::setCache().
*
* @param int $expire seconds until expiration (default = 0
* meaning the item will not get an expiration date)
*
*/
public function __construct($expire = 0)
{
@@ -36,7 +30,6 @@ class Minify_Cache_ZendPlatform implements Minify_CacheInterface
* Write data to cache.
*
* @param string $id cache id
*
* @param string $data
*
* @return bool success
@@ -62,14 +55,13 @@ class Minify_Cache_ZendPlatform implements Minify_CacheInterface
* Does a valid cache entry exist?
*
* @param string $id cache id
*
* @param int $srcMtime mtime of the original source file(s)
*
* @return bool exists
*/
public function isValid($id, $srcMtime)
{
return ($this->_fetch($id) && ($this->_lm >= $srcMtime));
return $this->_fetch($id) && ($this->_lm >= $srcMtime);
}
/**
@@ -94,12 +86,14 @@ class Minify_Cache_ZendPlatform implements Minify_CacheInterface
return $this->_fetch($id) ? $this->_data : '';
}
private $_exp = null;
private $_exp;
// cache of most recently fetched id
private $_lm = null;
private $_data = null;
private $_id = null;
private $_lm;
private $_data;
private $_id;
/**
* Fetch data and timestamp from ZendPlatform, store in instance
@@ -115,7 +109,7 @@ class Minify_Cache_ZendPlatform implements Minify_CacheInterface
}
$ret = output_cache_get($id, $this->_exp);
if (false === $ret) {
if ($ret === false) {
$this->_id = null;
return false;