mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-06 08:47:45 +02:00
[task/code-sniffer] Replace spaces with tabs.
PHPBB3-11980
This commit is contained in:
@@ -47,7 +47,7 @@ class class_loader
|
||||
* @param \phpbb\cache\driver\driver_interface $cache An implementation of the phpBB cache interface.
|
||||
*/
|
||||
public function __construct($namespace, $path, $php_ext = 'php', \phpbb\cache\driver\driver_interface $cache = null)
|
||||
{
|
||||
{
|
||||
if ($namespace[0] !== '\\')
|
||||
{
|
||||
$namespace = '\\' . $namespace;
|
||||
|
@@ -74,8 +74,8 @@ class datetime extends \DateTime
|
||||
* finally check that relative dates are supported by the language pack
|
||||
*/
|
||||
if ($delta <= 3600 && $delta > -60 &&
|
||||
($delta >= -5 || (($now_ts / 60) % 60) == (($timestamp / 60) % 60))
|
||||
&& isset($this->user->lang['datetime']['AGO']))
|
||||
($delta >= -5 || (($now_ts / 60) % 60) == (($timestamp / 60) % 60))
|
||||
&& isset($this->user->lang['datetime']['AGO']))
|
||||
{
|
||||
return $this->user->lang(array('datetime', 'AGO'), max(0, (int) floor($delta / 60)));
|
||||
}
|
||||
|
@@ -13,50 +13,50 @@ use Symfony\Component\EventDispatcher\Event;
|
||||
|
||||
class data extends Event implements \ArrayAccess
|
||||
{
|
||||
private $data;
|
||||
private $data;
|
||||
|
||||
public function __construct(array $data = array())
|
||||
{
|
||||
$this->set_data($data);
|
||||
}
|
||||
public function __construct(array $data = array())
|
||||
{
|
||||
$this->set_data($data);
|
||||
}
|
||||
|
||||
public function set_data(array $data = array())
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
public function set_data(array $data = array())
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function get_data()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
public function get_data()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns data filtered to only include specified keys.
|
||||
*
|
||||
* This effectively discards any keys added to data by hooks.
|
||||
*/
|
||||
public function get_data_filtered($keys)
|
||||
{
|
||||
return array_intersect_key($this->data, array_flip($keys));
|
||||
}
|
||||
/**
|
||||
* Returns data filtered to only include specified keys.
|
||||
*
|
||||
* This effectively discards any keys added to data by hooks.
|
||||
*/
|
||||
public function get_data_filtered($keys)
|
||||
{
|
||||
return array_intersect_key($this->data, array_flip($keys));
|
||||
}
|
||||
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return isset($this->data[$offset]);
|
||||
}
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return isset($this->data[$offset]);
|
||||
}
|
||||
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return isset($this->data[$offset]) ? $this->data[$offset] : null;
|
||||
}
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return isset($this->data[$offset]) ? $this->data[$offset] : null;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
$this->data[$offset] = $value;
|
||||
}
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
$this->data[$offset] = $value;
|
||||
}
|
||||
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
unset($this->data[$offset]);
|
||||
}
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
unset($this->data[$offset]);
|
||||
}
|
||||
}
|
||||
|
@@ -139,7 +139,7 @@ class metadata_manager
|
||||
|
||||
if (!file_exists($this->metadata_file))
|
||||
{
|
||||
throw new \phpbb\extension\exception('The required file does not exist: ' . $this->metadata_file);
|
||||
throw new \phpbb\extension\exception('The required file does not exist: ' . $this->metadata_file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,12 +158,12 @@ class metadata_manager
|
||||
{
|
||||
if (!($file_contents = file_get_contents($this->metadata_file)))
|
||||
{
|
||||
throw new \phpbb\extension\exception('file_get_contents failed on ' . $this->metadata_file);
|
||||
throw new \phpbb\extension\exception('file_get_contents failed on ' . $this->metadata_file);
|
||||
}
|
||||
|
||||
if (($metadata = json_decode($file_contents, true)) === null)
|
||||
{
|
||||
throw new \phpbb\extension\exception('json_decode failed on ' . $this->metadata_file);
|
||||
throw new \phpbb\extension\exception('json_decode failed on ' . $this->metadata_file);
|
||||
}
|
||||
|
||||
$this->metadata = $metadata;
|
||||
@@ -191,50 +191,50 @@ class metadata_manager
|
||||
* @return Bool True if valid, throws an exception if invalid
|
||||
*/
|
||||
public function validate($name = 'display')
|
||||
{
|
||||
// Basic fields
|
||||
$fields = array(
|
||||
'name' => '#^[a-zA-Z0-9_\x7f-\xff]{2,}/[a-zA-Z0-9_\x7f-\xff]{2,}$#',
|
||||
'type' => '#^phpbb-extension$#',
|
||||
'licence' => '#.+#',
|
||||
'version' => '#.+#',
|
||||
);
|
||||
{
|
||||
// Basic fields
|
||||
$fields = array(
|
||||
'name' => '#^[a-zA-Z0-9_\x7f-\xff]{2,}/[a-zA-Z0-9_\x7f-\xff]{2,}$#',
|
||||
'type' => '#^phpbb-extension$#',
|
||||
'licence' => '#.+#',
|
||||
'version' => '#.+#',
|
||||
);
|
||||
|
||||
switch ($name)
|
||||
{
|
||||
case 'all':
|
||||
$this->validate('display');
|
||||
switch ($name)
|
||||
{
|
||||
case 'all':
|
||||
$this->validate('display');
|
||||
|
||||
$this->validate_enable();
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'display':
|
||||
foreach ($fields as $field => $data)
|
||||
case 'display':
|
||||
foreach ($fields as $field => $data)
|
||||
{
|
||||
$this->validate($field);
|
||||
}
|
||||
|
||||
$this->validate_authors();
|
||||
break;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (isset($fields[$name]))
|
||||
{
|
||||
if (!isset($this->metadata[$name]))
|
||||
{
|
||||
throw new \phpbb\extension\exception("Required meta field '$name' has not been set.");
|
||||
default:
|
||||
if (isset($fields[$name]))
|
||||
{
|
||||
if (!isset($this->metadata[$name]))
|
||||
{
|
||||
throw new \phpbb\extension\exception("Required meta field '$name' has not been set.");
|
||||
}
|
||||
|
||||
if (!preg_match($fields[$name], $this->metadata[$name]))
|
||||
{
|
||||
throw new \phpbb\extension\exception("Meta field '$name' is invalid.");
|
||||
throw new \phpbb\extension\exception("Meta field '$name' is invalid.");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the contents of the authors field
|
||||
@@ -245,14 +245,14 @@ class metadata_manager
|
||||
{
|
||||
if (empty($this->metadata['authors']))
|
||||
{
|
||||
throw new \phpbb\extension\exception("Required meta field 'authors' has not been set.");
|
||||
throw new \phpbb\extension\exception("Required meta field 'authors' has not been set.");
|
||||
}
|
||||
|
||||
foreach ($this->metadata['authors'] as $author)
|
||||
{
|
||||
if (!isset($author['name']))
|
||||
{
|
||||
throw new \phpbb\extension\exception("Required meta field 'author name' has not been set.");
|
||||
throw new \phpbb\extension\exception("Required meta field 'author name' has not been set.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -254,8 +254,7 @@ class manager
|
||||
SET notification_read = 1
|
||||
WHERE notification_time <= " . (int) $time .
|
||||
(($notification_type_name !== false) ? ' AND ' .
|
||||
(is_array($notification_type_name) ? $this->db->sql_in_set('notification_type_id', $this->get_notification_type_ids($notification_type_name)) : 'notification_type_id = ' . $this->get_notification_type_id($notification_type_name))
|
||||
: '') .
|
||||
(is_array($notification_type_name) ? $this->db->sql_in_set('notification_type_id', $this->get_notification_type_ids($notification_type_name)) : 'notification_type_id = ' . $this->get_notification_type_id($notification_type_name)) : '') .
|
||||
(($user_id !== false) ? ' AND ' . (is_array($user_id) ? $this->db->sql_in_set('user_id', $user_id) : 'user_id = ' . (int) $user_id) : '') .
|
||||
(($item_id !== false) ? ' AND ' . (is_array($item_id) ? $this->db->sql_in_set('item_id', $item_id) : 'item_id = ' . (int) $item_id) : '');
|
||||
$this->db->sql_query($sql);
|
||||
@@ -277,8 +276,7 @@ class manager
|
||||
SET notification_read = 1
|
||||
WHERE notification_time <= " . (int) $time .
|
||||
(($notification_type_name !== false) ? ' AND ' .
|
||||
(is_array($notification_type_name) ? $this->db->sql_in_set('notification_type_id', $this->get_notification_type_ids($notification_type_name)) : 'notification_type_id = ' . $this->get_notification_type_id($notification_type_name))
|
||||
: '') .
|
||||
(is_array($notification_type_name) ? $this->db->sql_in_set('notification_type_id', $this->get_notification_type_ids($notification_type_name)) : 'notification_type_id = ' . $this->get_notification_type_id($notification_type_name)) : '') .
|
||||
(($item_parent_id !== false) ? ' AND ' . (is_array($item_parent_id) ? $this->db->sql_in_set('item_parent_id', $item_parent_id) : 'item_parent_id = ' . (int) $item_parent_id) : '') .
|
||||
(($user_id !== false) ? ' AND ' . (is_array($user_id) ? $this->db->sql_in_set('user_id', $user_id) : 'user_id = ' . (int) $user_id) : '');
|
||||
$this->db->sql_query($sql);
|
||||
|
@@ -1180,8 +1180,8 @@ class fulltext_native extends \phpbb\search\base
|
||||
* we know that it will also be lower than CJK ranges
|
||||
*/
|
||||
if ((strncmp($word, UTF8_HANGUL_FIRST, 3) < 0 || strncmp($word, UTF8_HANGUL_LAST, 3) > 0)
|
||||
&& (strncmp($word, UTF8_CJK_FIRST, 3) < 0 || strncmp($word, UTF8_CJK_LAST, 3) > 0)
|
||||
&& (strncmp($word, UTF8_CJK_B_FIRST, 4) < 0 || strncmp($word, UTF8_CJK_B_LAST, 4) > 0))
|
||||
&& (strncmp($word, UTF8_CJK_FIRST, 3) < 0 || strncmp($word, UTF8_CJK_LAST, 3) > 0)
|
||||
&& (strncmp($word, UTF8_CJK_B_FIRST, 4) < 0 || strncmp($word, UTF8_CJK_B_LAST, 4) > 0))
|
||||
{
|
||||
$word = strtok(' ');
|
||||
continue;
|
||||
@@ -1675,8 +1675,8 @@ class fulltext_native extends \phpbb\search\base
|
||||
$pos += $utf_len;
|
||||
|
||||
if (($utf_char >= UTF8_HANGUL_FIRST && $utf_char <= UTF8_HANGUL_LAST)
|
||||
|| ($utf_char >= UTF8_CJK_FIRST && $utf_char <= UTF8_CJK_LAST)
|
||||
|| ($utf_char >= UTF8_CJK_B_FIRST && $utf_char <= UTF8_CJK_B_LAST))
|
||||
|| ($utf_char >= UTF8_CJK_FIRST && $utf_char <= UTF8_CJK_LAST)
|
||||
|| ($utf_char >= UTF8_CJK_B_FIRST && $utf_char <= UTF8_CJK_B_LAST))
|
||||
{
|
||||
/**
|
||||
* All characters within these ranges are valid
|
||||
|
@@ -40,11 +40,11 @@ class extension extends \Twig_Extension
|
||||
return 'phpbb';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the token parser instance to add to the existing list.
|
||||
*
|
||||
* @return array An array of Twig_TokenParser instances
|
||||
*/
|
||||
/**
|
||||
* Returns the token parser instance to add to the existing list.
|
||||
*
|
||||
* @return array An array of Twig_TokenParser instances
|
||||
*/
|
||||
public function getTokenParsers()
|
||||
{
|
||||
return array(
|
||||
@@ -58,36 +58,36 @@ class extension extends \Twig_Extension
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of filters to add to the existing list.
|
||||
*
|
||||
* @return array An array of filters
|
||||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
/**
|
||||
* Returns a list of filters to add to the existing list.
|
||||
*
|
||||
* @return array An array of filters
|
||||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
return array(
|
||||
new \Twig_SimpleFilter('subset', array($this, 'loop_subset'), array('needs_environment' => true)),
|
||||
new \Twig_SimpleFilter('addslashes', 'addslashes'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of global functions to add to the existing list.
|
||||
*
|
||||
* @return array An array of global functions
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
/**
|
||||
* Returns a list of global functions to add to the existing list.
|
||||
*
|
||||
* @return array An array of global functions
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
return array(
|
||||
new \Twig_SimpleFunction('lang', array($this, 'lang')),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of operators to add to the existing list.
|
||||
*
|
||||
* @return array An array of operators
|
||||
*/
|
||||
/**
|
||||
* Returns a list of operators to add to the existing list.
|
||||
*
|
||||
* @return array An array of operators
|
||||
*/
|
||||
public function getOperators()
|
||||
{
|
||||
return array(
|
||||
@@ -118,19 +118,19 @@ class extension extends \Twig_Extension
|
||||
'mod' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_Mod', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Grabs a subset of a loop
|
||||
*
|
||||
* @param Twig_Environment $env A Twig_Environment instance
|
||||
* @param mixed $item A variable
|
||||
* @param integer $start Start of the subset
|
||||
* @param integer $end End of the subset
|
||||
* @param Boolean $preserveKeys Whether to preserve key or not (when the input is an array)
|
||||
*
|
||||
* @return mixed The sliced variable
|
||||
*/
|
||||
* Grabs a subset of a loop
|
||||
*
|
||||
* @param Twig_Environment $env A Twig_Environment instance
|
||||
* @param mixed $item A variable
|
||||
* @param integer $start Start of the subset
|
||||
* @param integer $end End of the subset
|
||||
* @param Boolean $preserveKeys Whether to preserve key or not (when the input is an array)
|
||||
*
|
||||
* @return mixed The sliced variable
|
||||
*/
|
||||
function loop_subset(\Twig_Environment $env, $item, $start, $end = null, $preserveKeys = false)
|
||||
{
|
||||
// We do almost the same thing as Twig's slice (array_slice), except when $end is positive
|
||||
|
@@ -49,10 +49,10 @@ class event extends \Twig_Node
|
||||
// templates on page load rather than at compile. This is
|
||||
// slower, but makes developing extensions easier (no need to
|
||||
// purge the cache when a new event template file is added)
|
||||
$compiler
|
||||
->write("if (\$this->env->getLoader()->exists('@{$ext_namespace}/{$location}.html')) {\n")
|
||||
->indent()
|
||||
;
|
||||
$compiler
|
||||
->write("if (\$this->env->getLoader()->exists('@{$ext_namespace}/{$location}.html')) {\n")
|
||||
->indent()
|
||||
;
|
||||
}
|
||||
|
||||
if (defined('DEBUG') || $this->environment->getLoader()->exists('@' . $ext_namespace . '/' . $location . '.html'))
|
||||
@@ -71,7 +71,7 @@ class event extends \Twig_Node
|
||||
{
|
||||
$compiler
|
||||
->outdent()
|
||||
->write("}\n\n")
|
||||
->write("}\n\n")
|
||||
;
|
||||
}
|
||||
}
|
||||
|
@@ -45,5 +45,5 @@ class php extends \Twig_TokenParser
|
||||
public function getTag()
|
||||
{
|
||||
return 'PHP';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user