Merge pull request #1839 from bantu/task/code-sniffer

More PHP Code Sniffer rules
This commit is contained in:
Nils Adermann 2013-11-01 07:58:18 -07:00
commit e118b4f4c0
206 changed files with 192 additions and 1851 deletions

View file

@ -81,7 +81,7 @@
--standard=build/code_sniffer/ruleset-php-strict.xml
--ignore=phpBB/phpbb/db/migration/data/v30x/*
phpBB/phpbb"
dir="." checkreturn="true" passthru="true" />
dir="." returnProperty="retval-php-strict" passthru="true" />
<exec command="phpBB/vendor/bin/phpcs
-s
--extensions=php
@ -92,10 +92,20 @@
--ignore=phpBB/includes/sphinxapi.php
--ignore=phpBB/includes/utf/data/*
--ignore=phpBB/install/data/*
--ignore=phpBB/install/database_update.php
--ignore=phpBB/phpbb/*
--ignore=phpBB/vendor/*
phpBB"
dir="." checkreturn="true" passthru="true" />
dir="." returnProperty="retval-php-legacy" passthru="true" />
<if>
<or>
<not><equals arg1="${retval-php-strict}" arg2="0" /></not>
<not><equals arg1="${retval-php-legacy}" arg2="0" /></not>
</or>
<then>
<fail message="PHP Code Sniffer failed." />
</then>
</if>
</target>
<target name="docs">

View file

@ -9,4 +9,7 @@
<!-- All code files MUST use the Unix LF (linefeed) line ending. -->
<rule ref="Generic.Files.LineEndings" />
<!-- Tabs MUST be used for indentation -->
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent" />
</ruleset>

View file

@ -5,9 +5,21 @@
<rule ref="./ruleset-minimum.xml" />
<!-- "for (; bar; )" should be "while (bar)" instead -->
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop" />
<!-- A method MUST not only call its parent -->
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod" />
<!-- The body of each structure MUST be enclosed by braces. -->
<rule ref="Generic.ControlStructures.InlineControlStructure" />
<!-- There MUST not be more than one statement per line. -->
<rule ref="Generic.Formatting.DisallowMultipleStatements" />
<!-- Call-time pass-by-reference MUST not be used. -->
<rule ref="Generic.Functions.CallTimePassByReference.NotAllowed" />
<!-- Class constants MUST be declared in all upper case with underscore separators. -->
<rule ref="Generic.NamingConventions.UpperCaseConstantName" />
@ -17,6 +29,15 @@
<!-- Method arguments with default values MUST go at the end of the argument list. -->
<rule ref="PEAR.Functions.ValidDefaultValue" />
<!-- In the argument list, there MUST NOT be a space before each comma,
and there MUST be one space after each comma. -->
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
<properties>
<property name="equalsSpacing" value="1"/>
</properties>
</rule>
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterHint" />
<!-- The ?> closing tag MUST be omitted from files containing only PHP. -->
<rule ref="Zend.Files.ClosingTag" />

View file

@ -34,6 +34,15 @@
<!-- Functions MUST NOT contain multiple empty lines in a row -->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines" />
<!-- Classes etc. MUST be namespaced -->
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace" />
<!-- A file MUST not contain more than one class/interface -->
<rule ref="PSR1.Classes.ClassDeclaration.MultipleClasses" />
<!-- Files containing classes MUST not have any side-effects -->
<rule ref="PSR1.Files.SideEffects.FoundWithSymbols" />
<!-- When present, all use declarations MUST go after the namespace declaration.
There MUST be one use keyword per declaration.
There MUST be one blank line after the use block. -->

View file

@ -763,8 +763,8 @@ class acp_board
global $user, $config;
$act_ary = array(
'ACC_DISABLE' => USER_ACTIVATION_DISABLE,
'ACC_NONE' => USER_ACTIVATION_NONE,
'ACC_DISABLE' => USER_ACTIVATION_DISABLE,
'ACC_NONE' => USER_ACTIVATION_NONE,
);
if ($config['email_enable'])
{

View file

@ -479,7 +479,7 @@ class acp_icons
$icons_updated++;
}
}
}
}
$cache->destroy('_icons');

View file

@ -647,8 +647,8 @@ class acp_users
while ($row = $db->sql_fetchrow($result))
{
if ($topic_id_ary[$row['topic_id']][ITEM_APPROVED] == $row['topic_posts_approved']
&& $topic_id_ary[$row['topic_id']][ITEM_UNAPPROVED] == $row['topic_posts_unapproved']
&& $topic_id_ary[$row['topic_id']][ITEM_DELETED] == $row['topic_posts_softdeleted'])
&& $topic_id_ary[$row['topic_id']][ITEM_UNAPPROVED] == $row['topic_posts_unapproved']
&& $topic_id_ary[$row['topic_id']][ITEM_DELETED] == $row['topic_posts_softdeleted'])
{
$move_topic_ary[] = $row['topic_id'];
}

View file

@ -26,7 +26,6 @@ class captcha
var $width = 360;
var $height = 96;
/**
* Create the image containing $code with a seed of $seed
*/
@ -69,7 +68,6 @@ class captcha
$bounding_boxes[$i] = $box;
}
// Redistribute leftover x-space
$offset = array();
for ($i = 0; $i < $code_len; ++$i)
@ -99,12 +97,12 @@ class captcha
imagedashedline($img, mt_rand($x -3, $x + 3), mt_rand(0, 4), mt_rand($x -3, $x + 3), mt_rand($this->height - 5, $this->height), $current_colour);
}
}
if ($config['captcha_gd_wave'] && ($config['captcha_gd_y_grid'] || $config['captcha_gd_y_grid']))
{
$this->wave($img);
}
if ($config['captcha_gd_3d_noise'])
{
$xoffset = mt_rand(0,9);
@ -122,11 +120,12 @@ class captcha
$dimm = $bounding_boxes[$i];
$xoffset += ($offset[$i] - $dimm[0]);
$yoffset = mt_rand(-$dimm[1], $this->height - $dimm[3]);
$noise[$i]->drawchar($sizes[$i], $xoffset, $yoffset, $img, $colour->get_resource('background'), $scheme);
$xoffset += $dimm[2];
}
}
$xoffset = 5;
for ($i = 0; $i < $code_len; ++$i)
{
@ -137,14 +136,17 @@ class captcha
$characters[$i]->drawchar($sizes[$i], $xoffset, $yoffset, $img, $colour->get_resource('background'), $scheme);
$xoffset += $dimm[2];
}
if ($config['captcha_gd_wave'])
{
$this->wave($img);
}
if ($config['captcha_gd_foreground_noise'])
{
$this->noise_line($img, 0, 0, $this->width, $this->height, $colour->get_resource('background'), $scheme, $bg_colours);
}
// Send image
header('Content-Type: image/png');
header('Cache-control: no-cache, no-store');
@ -233,7 +235,6 @@ class captcha
imagesetthickness($img, 1);
}
function captcha_noise_bg_bitmaps()
{
return array(
@ -292,7 +293,7 @@ class captcha
),
));
}
/**
* Return bitmaps
*/

View file

@ -86,7 +86,7 @@ class captcha
$fontcolors[0] = imagecolorallocate($img, mt_rand(0, 120), mt_rand(0, 120), mt_rand(0, 120));
$colors = array();
$colors = array();
$minr = mt_rand(20, 30);
$ming = mt_rand(20, 30);

View file

@ -823,7 +823,7 @@ function get_avatar_dim($src, $axis, $func = false, $arg1 = false, $arg2 = false
break;
case AVATAR_REMOTE:
// see notes on this functions usage and (hopefully) model $func to avoid this accordingly
// see notes on this functions usage and (hopefully) model $func to avoid this accordingly
return get_remote_avatar_dim($src, $axis);
break;
@ -1117,7 +1117,7 @@ function words_unique(&$words)
* Adds a user to the specified group and optionally makes them a group leader
* This function does not create the group if it does not exist and so should only be called after the groups have been created
*/
function add_user_group($group_id, $user_id, $group_leader=false)
function add_user_group($group_id, $user_id, $group_leader = false)
{
global $convert, $phpbb_root_path, $config, $user, $db;
@ -1297,7 +1297,7 @@ function restore_config($schema)
$src_ary = $schema['array_name'];
$config_value = (isset($convert_config[$src_ary][$src])) ? $convert_config[$src_ary][$src] : '';
}
}
}
if ($config_value !== '')
{

View file

@ -269,7 +269,7 @@ function view_folder($id, $mode, $folder_id, $folder)
// There is the chance that all recipients of the message got deleted. To avoid creating
// exports without recipients, we add a bogus "undisclosed recipient".
if (!(isset($address[$message_id]['g']) && sizeof($address[$message_id]['g'])) &&
!(isset($address[$message_id]['u']) && sizeof($address[$message_id]['u'])))
!(isset($address[$message_id]['u']) && sizeof($address[$message_id]['u'])))
{
$address[$message_id]['u'] = array();
$address[$message_id]['u']['to'] = array();

View file

@ -691,7 +691,7 @@ class module
/**
* Generate the relevant HTML for an input field and the associated label and explanatory text
*/
function input_field($name, $type, $value='', $options='')
function input_field($name, $type, $value = '', $options = '')
{
global $lang;
$tpl_type = explode(':', $type);

View file

@ -9,14 +9,6 @@
namespace phpbb\auth;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Permission/Auth class
* @package phpBB3

View file

@ -9,14 +9,6 @@
namespace phpbb\auth\provider;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Apache authentication provider for phpBB3
*

View file

@ -9,14 +9,6 @@
namespace phpbb\auth\provider;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Base authentication provider class that all other providers should implement
*

View file

@ -9,14 +9,6 @@
namespace phpbb\auth\provider;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Database authentication provider for phpBB3
*

View file

@ -9,14 +9,6 @@
namespace phpbb\auth\provider;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Database authentication provider for phpBB3
*

View file

@ -9,14 +9,6 @@
namespace phpbb\auth\provider\oauth;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
use OAuth\Common\Consumer\Credentials;
use OAuth\Common\Http\Uri\Uri;

View file

@ -9,14 +9,6 @@
namespace phpbb\auth\provider\oauth\service;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Base OAuth abstract class that all OAuth services should implement
*

View file

@ -9,14 +9,6 @@
namespace phpbb\auth\provider\oauth\service;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Bitly OAuth service
*

View file

@ -9,14 +9,6 @@
namespace phpbb\auth\provider\oauth\service;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* OAuth service exception class
*

View file

@ -9,14 +9,6 @@
namespace phpbb\auth\provider\oauth\service;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Facebook OAuth service
*

View file

@ -9,14 +9,6 @@
namespace phpbb\auth\provider\oauth\service;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Google OAuth service
*

View file

@ -9,14 +9,6 @@
namespace phpbb\auth\provider\oauth\service;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* OAuth service interface
*

View file

@ -9,14 +9,6 @@
namespace phpbb\auth\provider\oauth;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
use OAuth\OAuth1\Token\StdOAuth1Token;
use OAuth\Common\Token\TokenInterface;

View file

@ -9,14 +9,6 @@
namespace phpbb\auth\provider;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* The interface authentication provider classes have to implement.
*

View file

@ -9,14 +9,6 @@
namespace phpbb\avatar\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Base class for avatar drivers
* @package phpBB3

View file

@ -9,14 +9,6 @@
namespace phpbb\avatar\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Interface for avatar drivers
* @package phpBB3

View file

@ -9,14 +9,6 @@
namespace phpbb\avatar\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Handles avatars hosted at gravatar.com
* @package phpBB3

View file

@ -9,14 +9,6 @@
namespace phpbb\avatar\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Handles avatars selected from the board gallery
* @package phpBB3

View file

@ -9,14 +9,6 @@
namespace phpbb\avatar\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Handles avatars hosted remotely
* @package phpBB3

View file

@ -9,14 +9,6 @@
namespace phpbb\avatar\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Handles avatars uploaded to the board
* @package phpBB3

View file

@ -9,14 +9,6 @@
namespace phpbb\avatar;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package avatar
*/

View file

@ -9,14 +9,6 @@
namespace phpbb\cache\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* ACM for APC
* @package acm

View file

@ -9,14 +9,6 @@
namespace phpbb\cache\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package acm
*/

View file

@ -9,14 +9,6 @@
namespace phpbb\cache\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* An interface that all cache drivers must implement
*

View file

@ -9,14 +9,6 @@
namespace phpbb\cache\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* ACM for eAccelerator
* @package acm

View file

@ -9,14 +9,6 @@
namespace phpbb\cache\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* ACM File Based Caching
* @package acm

View file

@ -9,14 +9,6 @@
namespace phpbb\cache\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
if (!defined('PHPBB_ACM_MEMCACHE_PORT'))
{
define('PHPBB_ACM_MEMCACHE_PORT', 11211);

View file

@ -9,14 +9,6 @@
namespace phpbb\cache\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* ACM Abstract Memory Class
* @package acm

View file

@ -9,14 +9,6 @@
namespace phpbb\cache\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* ACM Null Caching
* @package acm

View file

@ -9,14 +9,6 @@
namespace phpbb\cache\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
if (!defined('PHPBB_ACM_REDIS_PORT'))
{
define('PHPBB_ACM_REDIS_PORT', 6379);

View file

@ -9,14 +9,6 @@
namespace phpbb\cache\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* ACM for WinCache
* @package acm

View file

@ -9,14 +9,6 @@
namespace phpbb\cache\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* ACM for XCache
* @package acm

View file

@ -9,14 +9,6 @@
namespace phpbb\cache;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Class for grabbing/handling cached entries
* @package acm

View file

@ -9,14 +9,6 @@
namespace phpbb;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* The class loader resolves class names to file system paths and loads them if
* necessary.
@ -55,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;

View file

@ -9,14 +9,6 @@
namespace phpbb\config;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Configuration container class
* @package phpBB3

View file

@ -9,14 +9,6 @@
namespace phpbb\config;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Configuration container class
* @package phpBB3

View file

@ -9,14 +9,6 @@
namespace phpbb\config;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Manages configuration options with an arbitrary length value stored in a TEXT
* column. In constrast to class \phpbb\config\db, values are never cached and

View file

@ -9,14 +9,6 @@
namespace phpbb;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* phpbb_visibility
* Handle fetching and setting the visibility for topics and posts

View file

@ -9,14 +9,6 @@
namespace phpbb\controller;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Controller exception class
* @package phpBB3

View file

@ -9,14 +9,6 @@
namespace phpbb\controller;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
use Symfony\Component\HttpFoundation\Response;
/**

View file

@ -9,14 +9,6 @@
namespace phpbb\controller;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Loader\YamlFileLoader;
use Symfony\Component\Config\FileLocator;

View file

@ -9,14 +9,6 @@
namespace phpbb\controller;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;

View file

@ -9,14 +9,6 @@
namespace phpbb\cron;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Cron manager class.
*

View file

@ -9,14 +9,6 @@
namespace phpbb\cron\task;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Cron task base class. Provides sensible defaults for cron tasks
* and partially implements cron task interface, making writing cron tasks easier.

View file

@ -9,14 +9,6 @@
namespace phpbb\cron\task\core;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Prune all forums cron task.
*

View file

@ -9,14 +9,6 @@
namespace phpbb\cron\task\core;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Prune one forum cron task.
*

View file

@ -9,14 +9,6 @@
namespace phpbb\cron\task\core;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Prune notifications cron task.
*

View file

@ -9,14 +9,6 @@
namespace phpbb\cron\task\core;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Queue cron task. Sends email and jabber messages queued by other scripts.
*

View file

@ -9,14 +9,6 @@
namespace phpbb\cron\task\core;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Tidy cache cron task.
*

View file

@ -9,14 +9,6 @@
namespace phpbb\cron\task\core;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Tidy database cron task.
*

View file

@ -9,14 +9,6 @@
namespace phpbb\cron\task\core;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Cron task for cleaning plupload's temporary upload directory.
*

View file

@ -9,14 +9,6 @@
namespace phpbb\cron\task\core;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Tidy search cron task.
*

View file

@ -9,14 +9,6 @@
namespace phpbb\cron\task\core;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Tidy sessions cron task.
*

View file

@ -9,14 +9,6 @@
namespace phpbb\cron\task\core;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Tidy warnings cron task.
*

View file

@ -9,14 +9,6 @@
namespace phpbb\cron\task;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Parametrized cron task interface.
*

View file

@ -9,14 +9,6 @@
namespace phpbb\cron\task;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Cron task interface
* @package phpBB3

View file

@ -9,14 +9,6 @@
namespace phpbb\cron\task;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Cron task wrapper class.
* Enhances cron tasks with convenience methods that work identically for all tasks.

View file

@ -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)));
}

View file

@ -9,14 +9,6 @@
namespace phpbb\db\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Database Abstraction Layer
* @package dbal

View file

@ -9,14 +9,6 @@
namespace phpbb\db\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Firebird/Interbase Database Abstraction Layer
* Minimum Requirement is Firebird 2.1

View file

@ -9,14 +9,6 @@
namespace phpbb\db\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* MSSQL Database Abstraction Layer
* Minimum Requirement is MSSQL 2000+

View file

@ -9,14 +9,6 @@
namespace phpbb\db\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* MSSQL Database Base Abstraction Layer
* @package dbal

View file

@ -9,14 +9,6 @@
namespace phpbb\db\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Unified ODBC functions
* Unified ODBC functions support any database having ODBC driver, for example Adabas D, IBM DB2, iODBC, Solid, Sybase SQL Anywhere...

View file

@ -13,183 +13,6 @@
namespace phpbb\db\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Prior to version 1.1 the SQL Server Native PHP driver didn't support sqlsrv_num_rows, or cursor based seeking so we recall all rows into an array
* and maintain our own cursor index into that array.
*/
class result_mssqlnative
{
public function result_mssqlnative($queryresult = false)
{
$this->m_cursor = 0;
$this->m_rows = array();
$this->m_num_fields = sqlsrv_num_fields($queryresult);
$this->m_field_meta = sqlsrv_field_metadata($queryresult);
while ($row = sqlsrv_fetch_array($queryresult, SQLSRV_FETCH_ASSOC))
{
if ($row !== null)
{
foreach($row as $k => $v)
{
if (is_object($v) && method_exists($v, 'format'))
{
$row[$k] = $v->format("Y-m-d\TH:i:s\Z");
}
}
$this->m_rows[] = $row;//read results into memory, cursors are not supported
}
}
$this->m_row_count = sizeof($this->m_rows);
}
private function array_to_obj($array, &$obj)
{
foreach ($array as $key => $value)
{
if (is_array($value))
{
$obj->$key = new \stdClass();
array_to_obj($value, $obj->$key);
}
else
{
$obj->$key = $value;
}
}
return $obj;
}
public function fetch($mode = SQLSRV_FETCH_BOTH, $object_class = 'stdClass')
{
if ($this->m_cursor >= $this->m_row_count || $this->m_row_count == 0)
{
return false;
}
$ret = false;
$arr_num = array();
if ($mode == SQLSRV_FETCH_NUMERIC || $mode == SQLSRV_FETCH_BOTH)
{
foreach($this->m_rows[$this->m_cursor] as $key => $value)
{
$arr_num[] = $value;
}
}
switch ($mode)
{
case SQLSRV_FETCH_ASSOC:
$ret = $this->m_rows[$this->m_cursor];
break;
case SQLSRV_FETCH_NUMERIC:
$ret = $arr_num;
break;
case 'OBJECT':
$ret = $this->array_to_obj($this->m_rows[$this->m_cursor], $o = new $object_class);
break;
case SQLSRV_FETCH_BOTH:
default:
$ret = $this->m_rows[$this->m_cursor] + $arr_num;
break;
}
$this->m_cursor++;
return $ret;
}
public function get($pos, $fld)
{
return $this->m_rows[$pos][$fld];
}
public function num_rows()
{
return $this->m_row_count;
}
public function seek($iRow)
{
$this->m_cursor = min($iRow, $this->m_row_count);
}
public function num_fields()
{
return $this->m_num_fields;
}
public function field_name($nr)
{
$arr_keys = array_keys($this->m_rows[0]);
return $arr_keys[$nr];
}
public function field_type($nr)
{
$i = 0;
$int_type = -1;
$str_type = '';
foreach ($this->m_field_meta as $meta)
{
if ($nr == $i)
{
$int_type = $meta['Type'];
break;
}
$i++;
}
//http://msdn.microsoft.com/en-us/library/cc296183.aspx contains type table
switch ($int_type)
{
case SQLSRV_SQLTYPE_BIGINT: $str_type = 'bigint'; break;
case SQLSRV_SQLTYPE_BINARY: $str_type = 'binary'; break;
case SQLSRV_SQLTYPE_BIT: $str_type = 'bit'; break;
case SQLSRV_SQLTYPE_CHAR: $str_type = 'char'; break;
case SQLSRV_SQLTYPE_DATETIME: $str_type = 'datetime'; break;
case SQLSRV_SQLTYPE_DECIMAL/*($precision, $scale)*/: $str_type = 'decimal'; break;
case SQLSRV_SQLTYPE_FLOAT: $str_type = 'float'; break;
case SQLSRV_SQLTYPE_IMAGE: $str_type = 'image'; break;
case SQLSRV_SQLTYPE_INT: $str_type = 'int'; break;
case SQLSRV_SQLTYPE_MONEY: $str_type = 'money'; break;
case SQLSRV_SQLTYPE_NCHAR/*($charCount)*/: $str_type = 'nchar'; break;
case SQLSRV_SQLTYPE_NUMERIC/*($precision, $scale)*/: $str_type = 'numeric'; break;
case SQLSRV_SQLTYPE_NVARCHAR/*($charCount)*/: $str_type = 'nvarchar'; break;
case SQLSRV_SQLTYPE_NTEXT: $str_type = 'ntext'; break;
case SQLSRV_SQLTYPE_REAL: $str_type = 'real'; break;
case SQLSRV_SQLTYPE_SMALLDATETIME: $str_type = 'smalldatetime'; break;
case SQLSRV_SQLTYPE_SMALLINT: $str_type = 'smallint'; break;
case SQLSRV_SQLTYPE_SMALLMONEY: $str_type = 'smallmoney'; break;
case SQLSRV_SQLTYPE_TEXT: $str_type = 'text'; break;
case SQLSRV_SQLTYPE_TIMESTAMP: $str_type = 'timestamp'; break;
case SQLSRV_SQLTYPE_TINYINT: $str_type = 'tinyint'; break;
case SQLSRV_SQLTYPE_UNIQUEIDENTIFIER: $str_type = 'uniqueidentifier'; break;
case SQLSRV_SQLTYPE_UDT: $str_type = 'UDT'; break;
case SQLSRV_SQLTYPE_VARBINARY/*($byteCount)*/: $str_type = 'varbinary'; break;
case SQLSRV_SQLTYPE_VARCHAR/*($charCount)*/: $str_type = 'varchar'; break;
case SQLSRV_SQLTYPE_XML: $str_type = 'xml'; break;
default: $str_type = $int_type;
}
return $str_type;
}
public function free()
{
unset($this->m_rows);
return;
}
}
/**
* @package dbal
*/

View file

@ -9,14 +9,6 @@
namespace phpbb\db\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* MySQL4 Database Abstraction Layer
* Compatible with:

View file

@ -9,14 +9,6 @@
namespace phpbb\db\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Abstract MySQL Database Base Abstraction Layer
* @package dbal

View file

@ -9,14 +9,6 @@
namespace phpbb\db\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* MySQLi Database Abstraction Layer
* mysqli-extension has to be compiled with:
@ -31,7 +23,7 @@ class mysqli extends \phpbb\db\driver\mysql_base
/**
* Connect to server
*/
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false , $new_link = false)
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
{
if (!function_exists('mysqli_connect'))
{

View file

@ -9,14 +9,6 @@
namespace phpbb\db\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Oracle Database Abstraction Layer
* @package dbal

View file

@ -9,14 +9,6 @@
namespace phpbb\db\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* PostgreSQL Database Abstraction Layer
* Minimum Requirement is Version 7.3+

View file

@ -9,14 +9,6 @@
namespace phpbb\db\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Sqlite Database Abstraction Layer
* Minimum Requirement: 2.8.2+

View file

@ -9,14 +9,6 @@
namespace phpbb\db\migration;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* The migrator is responsible for applying new migrations in the correct order.
*

View file

@ -9,14 +9,6 @@
namespace phpbb\db\migration;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Abstract base class for database migrations
*

View file

@ -9,14 +9,6 @@
namespace phpbb\db;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* The migrator is responsible for applying new migrations in the correct order.
*

View file

@ -9,14 +9,6 @@
namespace phpbb\db;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Collects rows for insert into a database until the buffer size is reached.
* Then flushes the buffer to the database and starts over again.

View file

@ -9,14 +9,6 @@
namespace phpbb\db;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Database Tools for handling cross-db actions such as altering columns, etc.
* Currently not supported is returning SQL for creating tables.

View file

@ -9,14 +9,6 @@
namespace phpbb\di\extension;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;

View file

@ -9,14 +9,6 @@
namespace phpbb\di\extension;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;

View file

@ -9,14 +9,6 @@
namespace phpbb\di\extension;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;

View file

@ -9,14 +9,6 @@
namespace phpbb\di\pass;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

View file

@ -9,14 +9,6 @@
namespace phpbb\di\pass;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

View file

@ -9,14 +9,6 @@
namespace phpbb\di;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
use Symfony\Component\DependencyInjection\ContainerInterface;
/**

View file

@ -9,14 +9,6 @@
namespace phpbb;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
class error_collector
{
var $errors;

View file

@ -9,62 +9,54 @@
namespace phpbb\event;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
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]);
}
}

View file

@ -9,14 +9,6 @@
namespace phpbb\event;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
/**

View file

@ -9,14 +9,6 @@
namespace phpbb\event;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class extension_subscriber_loader

View file

@ -9,14 +9,6 @@
namespace phpbb\event;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;

View file

@ -9,14 +9,6 @@
namespace phpbb\event;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;

View file

@ -9,14 +9,6 @@
namespace phpbb\event;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\PostResponseEvent;

Some files were not shown because too many files have changed in this diff Show more