composer-update-patch
This commit is contained in:
2
vendor/maximebf/debugbar/composer.json
vendored
2
vendor/maximebf/debugbar/composer.json
vendored
@@ -36,7 +36,7 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.12-dev"
|
||||
"dev-master": "1.13-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -11,6 +11,7 @@
|
||||
namespace DebugBar\DataCollector;
|
||||
|
||||
use Exception;
|
||||
use Symfony\Component\Debug\Exception\FatalThrowableError;
|
||||
|
||||
/**
|
||||
* Collects info about exceptions
|
||||
@@ -24,12 +25,23 @@ class ExceptionsCollector extends DataCollector implements Renderable
|
||||
* Adds an exception to be profiled in the debug bar
|
||||
*
|
||||
* @param Exception $e
|
||||
* @deprecated in favor on addThrowable
|
||||
*/
|
||||
public function addException(Exception $e)
|
||||
{
|
||||
$this->addThrowable($e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a Throwable to be profiled in the debug bar
|
||||
*
|
||||
* @param \Throwable $e
|
||||
*/
|
||||
public function addThrowable($e)
|
||||
{
|
||||
$this->exceptions[] = $e;
|
||||
if ($this->chainExceptions && $previous = $e->getPrevious()) {
|
||||
$this->addException($previous);
|
||||
$this->addThrowable($previous);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +58,7 @@ class ExceptionsCollector extends DataCollector implements Renderable
|
||||
/**
|
||||
* Returns the list of exceptions being profiled
|
||||
*
|
||||
* @return array[Exception]
|
||||
* @return array[\Throwable]
|
||||
*/
|
||||
public function getExceptions()
|
||||
{
|
||||
@@ -57,7 +69,7 @@ class ExceptionsCollector extends DataCollector implements Renderable
|
||||
{
|
||||
return array(
|
||||
'count' => count($this->exceptions),
|
||||
'exceptions' => array_map(array($this, 'formatExceptionData'), $this->exceptions)
|
||||
'exceptions' => array_map(array($this, 'formatThrowableData'), $this->exceptions)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -66,8 +78,20 @@ class ExceptionsCollector extends DataCollector implements Renderable
|
||||
*
|
||||
* @param Exception $e
|
||||
* @return array
|
||||
* @deprecated in favor on formatThrowableData
|
||||
*/
|
||||
public function formatExceptionData(Exception $e)
|
||||
{
|
||||
return $this->formatThrowableData($e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Throwable data as an array
|
||||
*
|
||||
* @param \Throwable $e
|
||||
* @return array
|
||||
*/
|
||||
public function formatThrowableData($e)
|
||||
{
|
||||
$filePath = $e->getFile();
|
||||
if ($filePath && file_exists($filePath)) {
|
||||
|
@@ -4,14 +4,17 @@ namespace DebugBar\DataCollector\PDO;
|
||||
|
||||
use PDO;
|
||||
use PDOException;
|
||||
use DebugBar\DataCollector\PDO\TraceablePDOStatement;
|
||||
|
||||
/**
|
||||
* A PDO proxy which traces statements
|
||||
*/
|
||||
class TraceablePDO extends PDO
|
||||
{
|
||||
/** @var PDO */
|
||||
protected $pdo;
|
||||
|
||||
/** @var array */
|
||||
protected $executedStatements = array();
|
||||
|
||||
public function __construct(PDO $pdo)
|
||||
@@ -20,78 +23,177 @@ class TraceablePDO extends PDO
|
||||
$this->pdo->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('DebugBar\DataCollector\PDO\TraceablePDOStatement', array($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initiates a transaction
|
||||
*
|
||||
* @link http://php.net/manual/en/pdo.begintransaction.php
|
||||
* @return bool TRUE on success or FALSE on failure.
|
||||
*/
|
||||
public function beginTransaction()
|
||||
{
|
||||
return $this->pdo->beginTransaction();
|
||||
}
|
||||
|
||||
/**
|
||||
* Commits a transaction
|
||||
*
|
||||
* @link http://php.net/manual/en/pdo.commit.php
|
||||
* @return bool TRUE on success or FALSE on failure.
|
||||
*/
|
||||
public function commit()
|
||||
{
|
||||
return $this->pdo->commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch extended error information associated with the last operation on the database handle
|
||||
*
|
||||
* @link http://php.net/manual/en/pdo.errorinfo.php
|
||||
* @return array PDO::errorInfo returns an array of error information
|
||||
*/
|
||||
public function errorCode()
|
||||
{
|
||||
return $this->pdo->errorCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch extended error information associated with the last operation on the database handle
|
||||
*
|
||||
* @link http://php.net/manual/en/pdo.errorinfo.php
|
||||
* @return array PDO::errorInfo returns an array of error information
|
||||
*/
|
||||
public function errorInfo()
|
||||
{
|
||||
return $this->pdo->errorInfo();
|
||||
}
|
||||
|
||||
public function exec($sql)
|
||||
/**
|
||||
* Execute an SQL statement and return the number of affected rows
|
||||
*
|
||||
* @link http://php.net/manual/en/pdo.exec.php
|
||||
* @param string $statement
|
||||
* @return int|bool PDO::exec returns the number of rows that were modified or deleted by the
|
||||
* SQL statement you issued. If no rows were affected, PDO::exec returns 0. This function may
|
||||
* return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE.
|
||||
* Please read the section on Booleans for more information
|
||||
*/
|
||||
public function exec($statement)
|
||||
{
|
||||
return $this->profileCall('exec', $sql, func_get_args());
|
||||
return $this->profileCall('exec', $statement, func_get_args());
|
||||
}
|
||||
|
||||
public function getAttribute($attr)
|
||||
/**
|
||||
* Retrieve a database connection attribute
|
||||
*
|
||||
* @link http://php.net/manual/en/pdo.getattribute.php
|
||||
* @param int $attribute One of the PDO::ATTR_* constants
|
||||
* @return mixed A successful call returns the value of the requested PDO attribute.
|
||||
* An unsuccessful call returns null.
|
||||
*/
|
||||
public function getAttribute($attribute)
|
||||
{
|
||||
return $this->pdo->getAttribute($attr);
|
||||
return $this->pdo->getAttribute($attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if inside a transaction
|
||||
*
|
||||
* @link http://php.net/manual/en/pdo.intransaction.php
|
||||
* @return bool TRUE if a transaction is currently active, and FALSE if not.
|
||||
*/
|
||||
public function inTransaction()
|
||||
{
|
||||
return $this->pdo->inTransaction();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the last inserted row or sequence value
|
||||
*
|
||||
* @link http://php.net/manual/en/pdo.lastinsertid.php
|
||||
* @param string $name [optional]
|
||||
* @return string If a sequence name was not specified for the name parameter, PDO::lastInsertId
|
||||
* returns a string representing the row ID of the last row that was inserted into the database.
|
||||
*/
|
||||
public function lastInsertId($name = null)
|
||||
{
|
||||
return $this->pdo->lastInsertId($name);
|
||||
}
|
||||
|
||||
public function prepare($sql, $driver_options = array())
|
||||
/**
|
||||
* Prepares a statement for execution and returns a statement object
|
||||
*
|
||||
* @link http://php.net/manual/en/pdo.prepare.php
|
||||
* @param string $statement This must be a valid SQL statement template for the target DB server.
|
||||
* @param array $driver_options [optional] This array holds one or more key=>value pairs to
|
||||
* set attribute values for the PDOStatement object that this method returns.
|
||||
* @return TraceablePDOStatement|bool If the database server successfully prepares the statement,
|
||||
* PDO::prepare returns a PDOStatement object. If the database server cannot successfully prepare
|
||||
* the statement, PDO::prepare returns FALSE or emits PDOException (depending on error handling).
|
||||
*/
|
||||
public function prepare($statement, $driver_options = array())
|
||||
{
|
||||
return $this->pdo->prepare($sql, $driver_options);
|
||||
return $this->pdo->prepare($statement, $driver_options);
|
||||
}
|
||||
|
||||
public function query($sql)
|
||||
/**
|
||||
* Executes an SQL statement, returning a result set as a PDOStatement object
|
||||
*
|
||||
* @link http://php.net/manual/en/pdo.query.php
|
||||
* @param string $statement
|
||||
* @return TraceablePDOStatement|bool PDO::query returns a PDOStatement object, or FALSE on
|
||||
* failure.
|
||||
*/
|
||||
public function query($statement)
|
||||
{
|
||||
return $this->profileCall('query', $sql, func_get_args());
|
||||
return $this->profileCall('query', $statement, func_get_args());
|
||||
}
|
||||
|
||||
public function quote($expr, $parameter_type = PDO::PARAM_STR)
|
||||
/**
|
||||
* Quotes a string for use in a query.
|
||||
*
|
||||
* @link http://php.net/manual/en/pdo.quote.php
|
||||
* @param string $string The string to be quoted.
|
||||
* @param int $parameter_type [optional] Provides a data type hint for drivers that have
|
||||
* alternate quoting styles.
|
||||
* @return string|bool A quoted string that is theoretically safe to pass into an SQL statement.
|
||||
* Returns FALSE if the driver does not support quoting in this way.
|
||||
*/
|
||||
public function quote($string, $parameter_type = PDO::PARAM_STR)
|
||||
{
|
||||
return $this->pdo->quote($expr, $parameter_type);
|
||||
return $this->pdo->quote($string, $parameter_type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rolls back a transaction
|
||||
*
|
||||
* @link http://php.net/manual/en/pdo.rollback.php
|
||||
* @return bool TRUE on success or FALSE on failure.
|
||||
*/
|
||||
public function rollBack()
|
||||
{
|
||||
return $this->pdo->rollBack();
|
||||
}
|
||||
|
||||
public function setAttribute($attr, $value)
|
||||
/**
|
||||
* Set an attribute
|
||||
*
|
||||
* @link http://php.net/manual/en/pdo.setattribute.php
|
||||
* @param int $attribute
|
||||
* @param mixed $value
|
||||
* @return bool TRUE on success or FALSE on failure.
|
||||
*/
|
||||
public function setAttribute($attribute, $value)
|
||||
{
|
||||
return $this->pdo->setAttribute($attr, $value);
|
||||
return $this->pdo->setAttribute($attribute, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Profiles a call to a PDO method
|
||||
*
|
||||
* @param string $method
|
||||
* @param string $sql
|
||||
* @param array $args
|
||||
* @return mixed The result of the call
|
||||
* @param string $method
|
||||
* @param string $sql
|
||||
* @param array $args
|
||||
* @return mixed The result of the call
|
||||
*/
|
||||
protected function profileCall($method, $sql, array $args)
|
||||
{
|
||||
|
@@ -11,12 +11,15 @@ use PDOStatement;
|
||||
*/
|
||||
class TraceablePDOStatement extends PDOStatement
|
||||
{
|
||||
/** @var PDO */
|
||||
protected $pdo;
|
||||
|
||||
/** @var array */
|
||||
protected $boundParameters = array();
|
||||
|
||||
/**
|
||||
* TraceablePDOStatement constructor.
|
||||
*
|
||||
* @param TraceablePDO $pdo
|
||||
*/
|
||||
protected function __construct(TraceablePDO $pdo)
|
||||
@@ -25,12 +28,16 @@ class TraceablePDOStatement extends PDOStatement
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $column
|
||||
* @param mixed $param
|
||||
* @param null $type
|
||||
* @param null $maxlen
|
||||
* @param null $driverdata
|
||||
* @return mixed
|
||||
* Bind a column to a PHP variable
|
||||
*
|
||||
* @link http://php.net/manual/en/pdostatement.bindcolumn.php
|
||||
* @param mixed $column Number of the column (1-indexed) or name of the column in the result set
|
||||
* @param mixed $param Name of the PHP variable to which the column will be bound.
|
||||
* @param int $type [optional] Data type of the parameter, specified by the PDO::PARAM_*
|
||||
* constants.
|
||||
* @param int $maxlen [optional] A hint for pre-allocation.
|
||||
* @param mixed $driverdata [optional] Optional parameter(s) for the driver.
|
||||
* @return bool TRUE on success or FALSE on failure.
|
||||
*/
|
||||
public function bindColumn($column, &$param, $type = null, $maxlen = null, $driverdata = null)
|
||||
{
|
||||
@@ -40,43 +47,60 @@ class TraceablePDOStatement extends PDOStatement
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $param
|
||||
* @param mixed $var
|
||||
* @param int $data_type
|
||||
* @param null $length
|
||||
* @param null $driver_options
|
||||
* @return mixed
|
||||
* Binds a parameter to the specified variable name
|
||||
*
|
||||
* @link http://php.net/manual/en/pdostatement.bindparam.php
|
||||
* @param mixed $parameter Parameter identifier. For a prepared statement using named
|
||||
* placeholders, this will be a parameter name of the form :name. For a prepared statement using
|
||||
* question mark placeholders, this will be the 1-indexed position of the parameter.
|
||||
* @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter.
|
||||
* @param int $data_type [optional] Explicit data type for the parameter using the PDO::PARAM_*
|
||||
* constants.
|
||||
* @param int $length [optional] Length of the data type. To indicate that a parameter is an OUT
|
||||
* parameter from a stored procedure, you must explicitly set the length.
|
||||
* @param mixed $driver_options [optional]
|
||||
* @return bool TRUE on success or FALSE on failure.
|
||||
*/
|
||||
public function bindParam($param, &$var, $data_type = PDO::PARAM_STR, $length = null, $driver_options = null)
|
||||
public function bindParam($parameter, &$variable, $data_type = PDO::PARAM_STR, $length = null, $driver_options = null)
|
||||
{
|
||||
$this->boundParameters[$param] = $var;
|
||||
$args = array_merge(array($param, &$var), array_slice(func_get_args(), 2));
|
||||
$this->boundParameters[$parameter] = $variable;
|
||||
$args = array_merge(array($parameter, &$variable), array_slice(func_get_args(), 2));
|
||||
return call_user_func_array(array("parent", 'bindParam'), $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $param
|
||||
* @param mixed $value
|
||||
* @param int $data_type
|
||||
* @return mixed
|
||||
* Binds a value to a parameter
|
||||
*
|
||||
* @link http://php.net/manual/en/pdostatement.bindvalue.php
|
||||
* @param mixed $parameter Parameter identifier. For a prepared statement using named
|
||||
* placeholders, this will be a parameter name of the form :name. For a prepared statement using
|
||||
* question mark placeholders, this will be the 1-indexed position of the parameter.
|
||||
* @param mixed $value The value to bind to the parameter.
|
||||
* @param int $data_type [optional] Explicit data type for the parameter using the PDO::PARAM_*
|
||||
* constants.
|
||||
* @return bool TRUE on success or FALSE on failure.
|
||||
*/
|
||||
public function bindValue($param, $value, $data_type = PDO::PARAM_STR)
|
||||
public function bindValue($parameter, $value, $data_type = PDO::PARAM_STR)
|
||||
{
|
||||
$this->boundParameters[$param] = $value;
|
||||
$this->boundParameters[$parameter] = $value;
|
||||
return call_user_func_array(array("parent", 'bindValue'), func_get_args());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $params
|
||||
* @return bool
|
||||
* @throws null
|
||||
* Executes a prepared statement
|
||||
*
|
||||
* @link http://php.net/manual/en/pdostatement.execute.php
|
||||
* @param array $input_parameters [optional] An array of values with as many elements as there
|
||||
* are bound parameters in the SQL statement being executed. All values are treated as
|
||||
* PDO::PARAM_STR.
|
||||
* @return bool TRUE on success or FALSE on failure.
|
||||
*/
|
||||
public function execute($params = null)
|
||||
public function execute($input_parameters = null)
|
||||
{
|
||||
$preparedId = spl_object_hash($this);
|
||||
$boundParameters = $this->boundParameters;
|
||||
if (is_array($params)) {
|
||||
$boundParameters = array_merge($boundParameters, $params);
|
||||
if (is_array($input_parameters)) {
|
||||
$boundParameters = array_merge($boundParameters, $input_parameters);
|
||||
}
|
||||
|
||||
$trace = new TracedStatement($this->queryString, $boundParameters, $preparedId);
|
||||
@@ -84,7 +108,7 @@ class TraceablePDOStatement extends PDOStatement
|
||||
|
||||
$ex = null;
|
||||
try {
|
||||
$result = parent::execute($params);
|
||||
$result = parent::execute($input_parameters);
|
||||
} catch (PDOException $e) {
|
||||
$ex = $e;
|
||||
}
|
||||
|
Reference in New Issue
Block a user