1
0
mirror of synced 2025-02-20 06:03:15 +03:00

set svn:eol-style property on plain text files

This commit is contained in:
piccoloprincipe 2009-06-02 18:05:26 +00:00
parent 9837cd79ff
commit bdd2241fb5
38 changed files with 6172 additions and 6172 deletions

View File

@ -1,49 +1,49 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\Common;
/**
* EventArgs is the base class for classes containing event data.
*
* This class contains no event data. It is used by events that do not pass state
* information to an event handler when an event is raised. The single empty EventArgs
* instance can be obtained through {@link getEmptyInstance()}.
*
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision$
*/
class EventArgs
{
private static $_emptyEventArgsInstance;
public static function getEmptyInstance()
{
if ( ! self::$_emptyEventArgsInstance) {
self::$_emptyEventArgsInstance = new EventArgs;
}
return self::$_emptyEventArgsInstance;
}
}
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\Common;
/**
* EventArgs is the base class for classes containing event data.
*
* This class contains no event data. It is used by events that do not pass state
* information to an event handler when an event is raised. The single empty EventArgs
* instance can be obtained through {@link getEmptyInstance()}.
*
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision$
*/
class EventArgs
{
private static $_emptyEventArgsInstance;
public static function getEmptyInstance()
{
if ( ! self::$_emptyEventArgsInstance) {
self::$_emptyEventArgsInstance = new EventArgs;
}
return self::$_emptyEventArgsInstance;
}
}

View File

@ -1,39 +1,39 @@
<?php
/*
* $Id: EventListener.php 4653 2008-07-10 17:17:58Z romanb $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
namespace Doctrine\Common;
/**
* An EventSubscriber knows himself what events he is interested in.
* If an EventSubscriber is added to an EventManager, the manager invokes
* getSubscribedEvents() and registers the subscriber as a listener for all
* returned events.
*
* @author Roman Borschel <roman@code-factory.org>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 2.0
* @version $Revision: 4653 $
*/
interface EventSubscriber
{
public function getSubscribedEvents();
}
<?php
/*
* $Id: EventListener.php 4653 2008-07-10 17:17:58Z romanb $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
namespace Doctrine\Common;
/**
* An EventSubscriber knows himself what events he is interested in.
* If an EventSubscriber is added to an EventManager, the manager invokes
* getSubscribedEvents() and registers the subscriber as a listener for all
* returned events.
*
* @author Roman Borschel <roman@code-factory.org>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 2.0
* @version $Revision: 4653 $
*/
interface EventSubscriber
{
public function getSubscribedEvents();
}

View File

@ -1,293 +1,293 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver;
/**
* Statement interface.
* Drivers must implement this interface.
*
* This resembles the PDOStatement interface.
*
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision$
*/
interface Statement
{
/**
* Bind a column to a PHP variable
*
* @param mixed $column Number of the column (1-indexed) or name of the column in the result set.
* If using the column name, be aware that the name should match
* the case of the column, as returned by the driver.
* @param string $param Name of the PHP variable to which the column will be bound.
* @param integer $type Data type of the parameter, specified by the PDO::PARAM_* constants.
* @return boolean Returns TRUE on success or FALSE on failure
*/
public function bindColumn($column, &$param, $type = null);
/**
* Binds a value to a corresponding named or positional
* placeholder in the SQL statement that was used to prepare the statement.
*
* @param mixed $param 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 integer $type Explicit data type for the parameter using the PDO::PARAM_* constants.
*
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function bindValue($param, $value, $type = null);
/**
* Binds a PHP variable to a corresponding named or question mark placeholder in the
* SQL statement that was use to prepare the statement. Unlike PDOStatement->bindValue(),
* the variable is bound as a reference and will only be evaluated at the time
* that PDOStatement->execute() is called.
*
* Most parameters are input parameters, that is, parameters that are
* used in a read-only fashion to build up the query. Some drivers support the invocation
* of stored procedures that return data as output parameters, and some also as input/output
* parameters that both send in data and are updated to receive it.
*
* @param mixed $param 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 integer $type Explicit data type for the parameter using the PDO::PARAM_* constants. To return
* an INOUT parameter from a stored procedure, use the bitwise OR operator to set the
* PDO::PARAM_INPUT_OUTPUT bits for the data_type parameter.
*
* @param integer $length 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 $driverOptions
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function bindParam($column, &$variable, $type = null, $length = null, $driverOptions = array());
/**
* closeCursor
* Closes the cursor, enabling the statement to be executed again.
*
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function closeCursor();
/**
* columnCount
* Returns the number of columns in the result set
*
* @return integer Returns the number of columns in the result set represented
* by the PDOStatement object. If there is no result set,
* this method should return 0.
*/
public function columnCount();
/**
* errorCode
* Fetch the SQLSTATE associated with the last operation on the statement handle
*
* @see Doctrine_Adapter_Interface::errorCode()
* @return string error code string
*/
public function errorCode();
/**
* errorInfo
* Fetch extended error information associated with the last operation on the statement handle
*
* @see Doctrine_Adapter_Interface::errorInfo()
* @return array error info array
*/
public function errorInfo();
/**
* Executes a prepared statement
*
* If the prepared statement included parameter markers, you must either:
* call PDOStatement->bindParam() to bind PHP variables to the parameter markers:
* bound variables pass their value as input and receive the output value,
* if any, of their associated parameter markers or pass an array of input-only
* parameter values
*
*
* @param array $params An array of values with as many elements as there are
* bound parameters in the SQL statement being executed.
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function execute($params = null);
/**
* fetch
*
* @see Query::HYDRATE_* constants
* @param integer $fetchStyle Controls how the next row will be returned to the caller.
* This value must be one of the Query::HYDRATE_* constants,
* defaulting to Query::HYDRATE_BOTH
*
* @param integer $cursorOrientation For a PDOStatement object representing a scrollable cursor,
* this value determines which row will be returned to the caller.
* This value must be one of the Query::HYDRATE_ORI_* constants, defaulting to
* Query::HYDRATE_ORI_NEXT. To request a scrollable cursor for your
* PDOStatement object,
* you must set the PDO::ATTR_CURSOR attribute to Doctrine::CURSOR_SCROLL when you
* prepare the SQL statement with Doctrine_Adapter_Interface->prepare().
*
* @param integer $cursorOffset For a PDOStatement object representing a scrollable cursor for which the
* $cursorOrientation parameter is set to Query::HYDRATE_ORI_ABS, this value specifies
* the absolute number of the row in the result set that shall be fetched.
*
* For a PDOStatement object representing a scrollable cursor for
* which the $cursorOrientation parameter is set to Query::HYDRATE_ORI_REL, this value
* specifies the row to fetch relative to the cursor position before
* PDOStatement->fetch() was called.
*
* @return mixed
*/
public function fetch($fetchStyle = Query::HYDRATE_BOTH,
$cursorOrientation = Query::HYDRATE_ORI_NEXT,
$cursorOffset = null);
/**
* fetchAll
* Returns an array containing all of the result set rows
*
* @param integer $fetchStyle Controls how the next row will be returned to the caller.
* This value must be one of the Query::HYDRATE_* constants,
* defaulting to Query::HYDRATE_BOTH
*
* @param integer $columnIndex Returns the indicated 0-indexed column when the value of $fetchStyle is
* Query::HYDRATE_COLUMN. Defaults to 0.
*
* @return array
*/
public function fetchAll($fetchStyle = Query::HYDRATE_BOTH);
/**
* fetchColumn
* Returns a single column from the next row of a
* result set or FALSE if there are no more rows.
*
* @param integer $columnIndex 0-indexed number of the column you wish to retrieve from the row. If no
* value is supplied, PDOStatement->fetchColumn()
* fetches the first column.
*
* @return string returns a single column in the next row of a result set.
*/
public function fetchColumn($columnIndex = 0);
/**
* fetchObject
* Fetches the next row and returns it as an object.
*
* Fetches the next row and returns it as an object. This function is an alternative to
* PDOStatement->fetch() with Query::HYDRATE_CLASS or Query::HYDRATE_OBJ style.
*
* @param string $className Name of the created class, defaults to stdClass.
* @param array $args Elements of this array are passed to the constructor.
*
* @return mixed an instance of the required class with property names that correspond
* to the column names or FALSE in case of an error.
*/
public function fetchObject($className = 'stdClass', $args = array());
/**
* getAttribute
* Retrieve a statement attribute
*
* @param integer $attribute
* @see Doctrine::ATTR_* constants
* @return mixed the attribute value
*/
public function getAttribute($attribute);
/**
* getColumnMeta
* Returns metadata for a column in a result set
*
* @param integer $column The 0-indexed column in the result set.
*
* @return array Associative meta data array with the following structure:
*
* native_type The PHP native type used to represent the column value.
* driver:decl_ type The SQL type used to represent the column value in the database. If the column in the result set is the result of a function, this value is not returned by PDOStatement->getColumnMeta().
* flags Any flags set for this column.
* name The name of this column as returned by the database.
* len The length of this column. Normally -1 for types other than floating point decimals.
* precision The numeric precision of this column. Normally 0 for types other than floating point decimals.
* pdo_type The type of this column as represented by the PDO::PARAM_* constants.
*/
public function getColumnMeta($column);
/**
* nextRowset
* Advances to the next rowset in a multi-rowset statement handle
*
* Some database servers support stored procedures that return more than one rowset
* (also known as a result set). The nextRowset() method enables you to access the second
* and subsequent rowsets associated with a PDOStatement object. Each rowset can have a
* different set of columns from the preceding rowset.
*
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function nextRowset();
/**
* rowCount
* rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement
* executed by the corresponding object.
*
* If the last SQL statement executed by the associated Statement object was a SELECT statement,
* some databases may return the number of rows returned by that statement. However,
* this behaviour is not guaranteed for all databases and should not be
* relied on for portable applications.
*
* @return integer Returns the number of rows.
*/
public function rowCount();
/**
* setAttribute
* Set a statement attribute
*
* @param integer $attribute
* @param mixed $value the value of given attribute
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function setAttribute($attribute, $value);
/**
* setFetchMode
* Set the default fetch mode for this statement
*
* @param integer $mode The fetch mode must be one of the Query::HYDRATE_* constants.
* @return boolean Returns 1 on success or FALSE on failure.
*/
public function setFetchMode($mode, $arg1);
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver;
/**
* Statement interface.
* Drivers must implement this interface.
*
* This resembles the PDOStatement interface.
*
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision$
*/
interface Statement
{
/**
* Bind a column to a PHP variable
*
* @param mixed $column Number of the column (1-indexed) or name of the column in the result set.
* If using the column name, be aware that the name should match
* the case of the column, as returned by the driver.
* @param string $param Name of the PHP variable to which the column will be bound.
* @param integer $type Data type of the parameter, specified by the PDO::PARAM_* constants.
* @return boolean Returns TRUE on success or FALSE on failure
*/
public function bindColumn($column, &$param, $type = null);
/**
* Binds a value to a corresponding named or positional
* placeholder in the SQL statement that was used to prepare the statement.
*
* @param mixed $param 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 integer $type Explicit data type for the parameter using the PDO::PARAM_* constants.
*
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function bindValue($param, $value, $type = null);
/**
* Binds a PHP variable to a corresponding named or question mark placeholder in the
* SQL statement that was use to prepare the statement. Unlike PDOStatement->bindValue(),
* the variable is bound as a reference and will only be evaluated at the time
* that PDOStatement->execute() is called.
*
* Most parameters are input parameters, that is, parameters that are
* used in a read-only fashion to build up the query. Some drivers support the invocation
* of stored procedures that return data as output parameters, and some also as input/output
* parameters that both send in data and are updated to receive it.
*
* @param mixed $param 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 integer $type Explicit data type for the parameter using the PDO::PARAM_* constants. To return
* an INOUT parameter from a stored procedure, use the bitwise OR operator to set the
* PDO::PARAM_INPUT_OUTPUT bits for the data_type parameter.
*
* @param integer $length 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 $driverOptions
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function bindParam($column, &$variable, $type = null, $length = null, $driverOptions = array());
/**
* closeCursor
* Closes the cursor, enabling the statement to be executed again.
*
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function closeCursor();
/**
* columnCount
* Returns the number of columns in the result set
*
* @return integer Returns the number of columns in the result set represented
* by the PDOStatement object. If there is no result set,
* this method should return 0.
*/
public function columnCount();
/**
* errorCode
* Fetch the SQLSTATE associated with the last operation on the statement handle
*
* @see Doctrine_Adapter_Interface::errorCode()
* @return string error code string
*/
public function errorCode();
/**
* errorInfo
* Fetch extended error information associated with the last operation on the statement handle
*
* @see Doctrine_Adapter_Interface::errorInfo()
* @return array error info array
*/
public function errorInfo();
/**
* Executes a prepared statement
*
* If the prepared statement included parameter markers, you must either:
* call PDOStatement->bindParam() to bind PHP variables to the parameter markers:
* bound variables pass their value as input and receive the output value,
* if any, of their associated parameter markers or pass an array of input-only
* parameter values
*
*
* @param array $params An array of values with as many elements as there are
* bound parameters in the SQL statement being executed.
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function execute($params = null);
/**
* fetch
*
* @see Query::HYDRATE_* constants
* @param integer $fetchStyle Controls how the next row will be returned to the caller.
* This value must be one of the Query::HYDRATE_* constants,
* defaulting to Query::HYDRATE_BOTH
*
* @param integer $cursorOrientation For a PDOStatement object representing a scrollable cursor,
* this value determines which row will be returned to the caller.
* This value must be one of the Query::HYDRATE_ORI_* constants, defaulting to
* Query::HYDRATE_ORI_NEXT. To request a scrollable cursor for your
* PDOStatement object,
* you must set the PDO::ATTR_CURSOR attribute to Doctrine::CURSOR_SCROLL when you
* prepare the SQL statement with Doctrine_Adapter_Interface->prepare().
*
* @param integer $cursorOffset For a PDOStatement object representing a scrollable cursor for which the
* $cursorOrientation parameter is set to Query::HYDRATE_ORI_ABS, this value specifies
* the absolute number of the row in the result set that shall be fetched.
*
* For a PDOStatement object representing a scrollable cursor for
* which the $cursorOrientation parameter is set to Query::HYDRATE_ORI_REL, this value
* specifies the row to fetch relative to the cursor position before
* PDOStatement->fetch() was called.
*
* @return mixed
*/
public function fetch($fetchStyle = Query::HYDRATE_BOTH,
$cursorOrientation = Query::HYDRATE_ORI_NEXT,
$cursorOffset = null);
/**
* fetchAll
* Returns an array containing all of the result set rows
*
* @param integer $fetchStyle Controls how the next row will be returned to the caller.
* This value must be one of the Query::HYDRATE_* constants,
* defaulting to Query::HYDRATE_BOTH
*
* @param integer $columnIndex Returns the indicated 0-indexed column when the value of $fetchStyle is
* Query::HYDRATE_COLUMN. Defaults to 0.
*
* @return array
*/
public function fetchAll($fetchStyle = Query::HYDRATE_BOTH);
/**
* fetchColumn
* Returns a single column from the next row of a
* result set or FALSE if there are no more rows.
*
* @param integer $columnIndex 0-indexed number of the column you wish to retrieve from the row. If no
* value is supplied, PDOStatement->fetchColumn()
* fetches the first column.
*
* @return string returns a single column in the next row of a result set.
*/
public function fetchColumn($columnIndex = 0);
/**
* fetchObject
* Fetches the next row and returns it as an object.
*
* Fetches the next row and returns it as an object. This function is an alternative to
* PDOStatement->fetch() with Query::HYDRATE_CLASS or Query::HYDRATE_OBJ style.
*
* @param string $className Name of the created class, defaults to stdClass.
* @param array $args Elements of this array are passed to the constructor.
*
* @return mixed an instance of the required class with property names that correspond
* to the column names or FALSE in case of an error.
*/
public function fetchObject($className = 'stdClass', $args = array());
/**
* getAttribute
* Retrieve a statement attribute
*
* @param integer $attribute
* @see Doctrine::ATTR_* constants
* @return mixed the attribute value
*/
public function getAttribute($attribute);
/**
* getColumnMeta
* Returns metadata for a column in a result set
*
* @param integer $column The 0-indexed column in the result set.
*
* @return array Associative meta data array with the following structure:
*
* native_type The PHP native type used to represent the column value.
* driver:decl_ type The SQL type used to represent the column value in the database. If the column in the result set is the result of a function, this value is not returned by PDOStatement->getColumnMeta().
* flags Any flags set for this column.
* name The name of this column as returned by the database.
* len The length of this column. Normally -1 for types other than floating point decimals.
* precision The numeric precision of this column. Normally 0 for types other than floating point decimals.
* pdo_type The type of this column as represented by the PDO::PARAM_* constants.
*/
public function getColumnMeta($column);
/**
* nextRowset
* Advances to the next rowset in a multi-rowset statement handle
*
* Some database servers support stored procedures that return more than one rowset
* (also known as a result set). The nextRowset() method enables you to access the second
* and subsequent rowsets associated with a PDOStatement object. Each rowset can have a
* different set of columns from the preceding rowset.
*
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function nextRowset();
/**
* rowCount
* rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement
* executed by the corresponding object.
*
* If the last SQL statement executed by the associated Statement object was a SELECT statement,
* some databases may return the number of rows returned by that statement. However,
* this behaviour is not guaranteed for all databases and should not be
* relied on for portable applications.
*
* @return integer Returns the number of rows.
*/
public function rowCount();
/**
* setAttribute
* Set a statement attribute
*
* @param integer $attribute
* @param mixed $value the value of given attribute
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function setAttribute($attribute, $value);
/**
* setFetchMode
* Set the default fetch mode for this statement
*
* @param integer $mode The fetch mode must be one of the Query::HYDRATE_* constants.
* @return boolean Returns 1 on success or FALSE on failure.
*/
public function setFetchMode($mode, $arg1);
}

View File

@ -1,438 +1,438 @@
<?php
/*
* $Id: Statement.php 1532 2007-05-31 17:45:07Z zYne $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
namespace Doctrine\DBAL;
/**
* A thin wrapper around PDOStatement.
*
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 1532 $
* @todo Do we seriously need this wrapper?
*/
class Statement
{
/**
* @var Doctrine_Connection $conn Doctrine_Connection object, every connection
* statement holds an instance of Doctrine_Connection
*/
protected $_conn;
/**
* @var Doctrine::DBAL::Driver::Statement
*/
protected $_stmt;
/**
* constructor
*
* @param Doctrine_Connection $conn Doctrine_Connection object, every connection
* statement holds an instance of Doctrine_Connection
* @param mixed $stmt
*/
public function __construct(Connection $conn, $stmt)
{
$this->_conn = $conn;
$this->_stmt = $stmt;
if ($stmt === false) {
throw \Doctrine\Common\DoctrineException::updateMe('Unknown statement object given.');
}
}
/**
* getConnection
* returns the connection object this statement uses
*
* @return Doctrine_Connection
*/
public function getConnection()
{
return $this->_conn;
}
public function getStatement()
{
return $this->_stmt;
}
public function getQuery()
{
return $this->_stmt->queryString;
}
/**
* Bind a column to a PHP variable
*
* @param mixed $column Number of the column (1-indexed) or name of the column in the result set.
* If using the column name, be aware that the name should match
* the case of the column, as returned by the driver.
*
* @param string $param Name of the PHP variable to which the column will be bound.
* @param integer $type Data type of the parameter, specified by the PDO::PARAM_* constants.
* @return boolean Returns TRUE on success or FALSE on failure
*/
public function bindColumn($column, $param, $type = null)
{
if ($type === null) {
return $this->_stmt->bindColumn($column, $param);
} else {
return $this->_stmt->bindColumn($column, $param, $type);
}
}
/**
* bindValue
* Binds a value to a corresponding named or question mark
* placeholder in the SQL statement that was use to prepare the statement.
*
* @param mixed $param 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 integer $type Explicit data type for the parameter using the PDO::PARAM_* constants.
*
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function bindValue($param, $value, $type = null)
{
if ($type === null) {
return $this->_stmt->bindValue($param, $value);
} else {
return $this->_stmt->bindValue($param, $value, $type);
}
}
/**
* Binds a PHP variable to a corresponding named or question mark placeholder in the
* SQL statement that was use to prepare the statement. Unlike PDOStatement->bindValue(),
* the variable is bound as a reference and will only be evaluated at the time
* that PDOStatement->execute() is called.
*
* Most parameters are input parameters, that is, parameters that are
* used in a read-only fashion to build up the query. Some drivers support the invocation
* of stored procedures that return data as output parameters, and some also as input/output
* parameters that both send in data and are updated to receive it.
*
* @param mixed $param 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 integer $type Explicit data type for the parameter using the PDO::PARAM_* constants. To return
* an INOUT parameter from a stored procedure, use the bitwise OR operator to set the
* PDO::PARAM_INPUT_OUTPUT bits for the data_type parameter.
*
* @param integer $length 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 $driverOptions
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function bindParam($column, &$variable, $type = null, $length = null, $driverOptions = array())
{
if ($type === null) {
return $this->_stmt->bindParam($column, $variable);
} else {
return $this->_stmt->bindParam($column, $variable, $type, $length, $driverOptions);
}
}
/**
* Closes the cursor, enabling the statement to be executed again.
*
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function closeCursor()
{
return $this->_stmt->closeCursor();
}
/**
* Returns the number of columns in the result set
*
* @return integer Returns the number of columns in the result set represented
* by the PDOStatement object. If there is no result set,
* this method should return 0.
*/
public function columnCount()
{
return $this->_stmt->columnCount();
}
/**
* Fetch the SQLSTATE associated with the last operation on the statement handle
*
* @see Doctrine_Adapter_Interface::errorCode()
* @return string error code string
*/
public function errorCode()
{
return $this->_stmt->errorCode();
}
/**
* Fetch extended error information associated with the last operation on the statement handle
*
* @see Doctrine_Adapter_Interface::errorInfo()
* @return array error info array
*/
public function errorInfo()
{
return $this->_stmt->errorInfo();
}
/**
* Executes a prepared statement
*
* If the prepared statement included parameter markers, you must either:
* call PDOStatement->bindParam() to bind PHP variables to the parameter markers:
* bound variables pass their value as input and receive the output value,
* if any, of their associated parameter markers or pass an array of input-only
* parameter values
*
*
* @param array $params An array of values with as many elements as there are
* bound parameters in the SQL statement being executed.
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function execute($params = null)
{
try {
//$event = new Doctrine_Event($this, Doctrine_Event::STMT_EXECUTE, $this->getQuery(), $params);
//$this->_conn->getListener()->preStmtExecute($event);
$result = true;
//if ( ! $event->skipOperation) {
$result = $this->_stmt->execute($params);
//$this->_conn->incrementQueryCount();
//}
//$this->_conn->getListener()->postStmtExecute($event);
return $result;
} catch (PDOException $e) {
$this->_conn->rethrowException($e, $this);
}
return false;
}
/**
* fetch
*
* @see Query::HYDRATE_* constants
* @param integer $fetchStyle Controls how the next row will be returned to the caller.
* This value must be one of the Query::HYDRATE_* constants,
* defaulting to Query::HYDRATE_BOTH
*
* @param integer $cursorOrientation For a PDOStatement object representing a scrollable cursor,
* this value determines which row will be returned to the caller.
* This value must be one of the Query::HYDRATE_ORI_* constants, defaulting to
* Query::HYDRATE_ORI_NEXT. To request a scrollable cursor for your
* PDOStatement object,
* you must set the PDO::ATTR_CURSOR attribute to Doctrine::CURSOR_SCROLL when you
* prepare the SQL statement with Doctrine_Adapter_Interface->prepare().
*
* @param integer $cursorOffset For a PDOStatement object representing a scrollable cursor for which the
* $cursorOrientation parameter is set to Query::HYDRATE_ORI_ABS, this value specifies
* the absolute number of the row in the result set that shall be fetched.
*
* For a PDOStatement object representing a scrollable cursor for
* which the $cursorOrientation parameter is set to Query::HYDRATE_ORI_REL, this value
* specifies the row to fetch relative to the cursor position before
* PDOStatement->fetch() was called.
*
* @return mixed
*/
public function fetch($fetchMode = Query::HYDRATE_BOTH,
$cursorOrientation = Query::HYDRATE_ORI_NEXT,
$cursorOffset = null)
{
//$event = new Doctrine_Event($this, Doctrine_Event::STMT_FETCH, $this->getQuery());
//$event->fetchMode = $fetchMode;
//$event->cursorOrientation = $cursorOrientation;
//$event->cursorOffset = $cursorOffset;
//$data = $this->_conn->getListener()->preFetch($event);
//if ( ! $event->skipOperation) {
$data = $this->_stmt->fetch($fetchMode, $cursorOrientation, $cursorOffset);
//}
//$this->_conn->getListener()->postFetch($event);
return $data;
}
/**
* Returns an array containing all of the result set rows
*
* @param integer $fetchMode Controls how the next row will be returned to the caller.
* This value must be one of the Query::HYDRATE_* constants,
* defaulting to Query::HYDRATE_BOTH
*
* @param integer $columnIndex Returns the indicated 0-indexed column when the value of $fetchStyle is
* Query::HYDRATE_COLUMN. Defaults to 0.
*
* @return array
*/
public function fetchAll($fetchMode = Query::HYDRATE_BOTH, $columnIndex = null)
{
//$event = new Doctrine_Event($this, Doctrine_Event::STMT_FETCHALL, $this->getQuery());
//$event->fetchMode = $fetchMode;
//$event->columnIndex = $columnIndex;
//$this->_conn->getListener()->preFetchAll($event);
//if ( ! $event->skipOperation) {
if ($columnIndex !== null) {
$data = $this->_stmt->fetchAll($fetchMode, $columnIndex);
} else {
$data = $this->_stmt->fetchAll($fetchMode);
}
//$event->data = $data;
//}
//$this->_conn->getListener()->postFetchAll($event);
return $data;
}
/**
* Returns a single column from the next row of a
* result set or FALSE if there are no more rows.
*
* @param integer $columnIndex 0-indexed number of the column you wish to retrieve from the row. If no
* value is supplied, PDOStatement->fetchColumn()
* fetches the first column.
*
* @return string returns a single column in the next row of a result set.
*/
public function fetchColumn($columnIndex = 0)
{
return $this->_stmt->fetchColumn($columnIndex);
}
/**
* Fetches the next row and returns it as an object.
*
* Fetches the next row and returns it as an object. This function is an alternative to
* PDOStatement->fetch() with Query::HYDRATE_CLASS or Query::HYDRATE_OBJ style.
*
* @param string $className Name of the created class, defaults to stdClass.
* @param array $args Elements of this array are passed to the constructor.
*
* @return mixed an instance of the required class with property names that correspond
* to the column names or FALSE in case of an error.
*/
public function fetchObject($className = 'stdClass', $args = array())
{
return $this->_stmt->fetchObject($className, $args);
}
/**
* Retrieve a statement attribute
*
* @param integer $attribute
* @see Doctrine::ATTR_* constants
* @return mixed the attribute value
*/
public function getAttribute($attribute)
{
return $this->_stmt->getAttribute($attribute);
}
/**
* Returns metadata for a column in a result set
*
* @param integer $column The 0-indexed column in the result set.
*
* @return array Associative meta data array with the following structure:
*
* native_type The PHP native type used to represent the column value.
* driver:decl_ type The SQL type used to represent the column value in the database. If the column in the result set is the result of a function, this value is not returned by PDOStatement->getColumnMeta().
* flags Any flags set for this column.
* name The name of this column as returned by the database.
* len The length of this column. Normally -1 for types other than floating point decimals.
* precision The numeric precision of this column. Normally 0 for types other than floating point decimals.
* pdo_type The type of this column as represented by the PDO::PARAM_* constants.
*/
public function getColumnMeta($column)
{
return $this->_stmt->getColumnMeta($column);
}
/**
* Advances to the next rowset in a multi-rowset statement handle
*
* Some database servers support stored procedures that return more than one rowset
* (also known as a result set). The nextRowset() method enables you to access the second
* and subsequent rowsets associated with a PDOStatement object. Each rowset can have a
* different set of columns from the preceding rowset.
*
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function nextRowset()
{
return $this->_stmt->nextRowset();
}
/**
* rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement
* executed by the corresponding object.
*
* If the last SQL statement executed by the associated Statement object was a SELECT statement,
* some databases may return the number of rows returned by that statement. However,
* this behaviour is not guaranteed for all databases and should not be
* relied on for portable applications.
*
* @return integer Returns the number of rows.
*/
public function rowCount()
{
return $this->_stmt->rowCount();
}
/**
* Set a statement attribute
*
* @param integer $attribute
* @param mixed $value the value of given attribute
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function setAttribute($attribute, $value)
{
return $this->_stmt->setAttribute($attribute, $value);
}
/**
* Set the default fetch mode for this statement
*
* @param integer $mode The fetch mode must be one of the Query::HYDRATE_* constants.
* @return boolean Returns 1 on success or FALSE on failure.
*/
public function setFetchMode($mode, $arg1 = null, $arg2 = null)
{
return $this->_stmt->setFetchMode($mode, $arg1, $arg2);
}
<?php
/*
* $Id: Statement.php 1532 2007-05-31 17:45:07Z zYne $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
namespace Doctrine\DBAL;
/**
* A thin wrapper around PDOStatement.
*
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 1532 $
* @todo Do we seriously need this wrapper?
*/
class Statement
{
/**
* @var Doctrine_Connection $conn Doctrine_Connection object, every connection
* statement holds an instance of Doctrine_Connection
*/
protected $_conn;
/**
* @var Doctrine::DBAL::Driver::Statement
*/
protected $_stmt;
/**
* constructor
*
* @param Doctrine_Connection $conn Doctrine_Connection object, every connection
* statement holds an instance of Doctrine_Connection
* @param mixed $stmt
*/
public function __construct(Connection $conn, $stmt)
{
$this->_conn = $conn;
$this->_stmt = $stmt;
if ($stmt === false) {
throw \Doctrine\Common\DoctrineException::updateMe('Unknown statement object given.');
}
}
/**
* getConnection
* returns the connection object this statement uses
*
* @return Doctrine_Connection
*/
public function getConnection()
{
return $this->_conn;
}
public function getStatement()
{
return $this->_stmt;
}
public function getQuery()
{
return $this->_stmt->queryString;
}
/**
* Bind a column to a PHP variable
*
* @param mixed $column Number of the column (1-indexed) or name of the column in the result set.
* If using the column name, be aware that the name should match
* the case of the column, as returned by the driver.
*
* @param string $param Name of the PHP variable to which the column will be bound.
* @param integer $type Data type of the parameter, specified by the PDO::PARAM_* constants.
* @return boolean Returns TRUE on success or FALSE on failure
*/
public function bindColumn($column, $param, $type = null)
{
if ($type === null) {
return $this->_stmt->bindColumn($column, $param);
} else {
return $this->_stmt->bindColumn($column, $param, $type);
}
}
/**
* bindValue
* Binds a value to a corresponding named or question mark
* placeholder in the SQL statement that was use to prepare the statement.
*
* @param mixed $param 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 integer $type Explicit data type for the parameter using the PDO::PARAM_* constants.
*
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function bindValue($param, $value, $type = null)
{
if ($type === null) {
return $this->_stmt->bindValue($param, $value);
} else {
return $this->_stmt->bindValue($param, $value, $type);
}
}
/**
* Binds a PHP variable to a corresponding named or question mark placeholder in the
* SQL statement that was use to prepare the statement. Unlike PDOStatement->bindValue(),
* the variable is bound as a reference and will only be evaluated at the time
* that PDOStatement->execute() is called.
*
* Most parameters are input parameters, that is, parameters that are
* used in a read-only fashion to build up the query. Some drivers support the invocation
* of stored procedures that return data as output parameters, and some also as input/output
* parameters that both send in data and are updated to receive it.
*
* @param mixed $param 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 integer $type Explicit data type for the parameter using the PDO::PARAM_* constants. To return
* an INOUT parameter from a stored procedure, use the bitwise OR operator to set the
* PDO::PARAM_INPUT_OUTPUT bits for the data_type parameter.
*
* @param integer $length 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 $driverOptions
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function bindParam($column, &$variable, $type = null, $length = null, $driverOptions = array())
{
if ($type === null) {
return $this->_stmt->bindParam($column, $variable);
} else {
return $this->_stmt->bindParam($column, $variable, $type, $length, $driverOptions);
}
}
/**
* Closes the cursor, enabling the statement to be executed again.
*
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function closeCursor()
{
return $this->_stmt->closeCursor();
}
/**
* Returns the number of columns in the result set
*
* @return integer Returns the number of columns in the result set represented
* by the PDOStatement object. If there is no result set,
* this method should return 0.
*/
public function columnCount()
{
return $this->_stmt->columnCount();
}
/**
* Fetch the SQLSTATE associated with the last operation on the statement handle
*
* @see Doctrine_Adapter_Interface::errorCode()
* @return string error code string
*/
public function errorCode()
{
return $this->_stmt->errorCode();
}
/**
* Fetch extended error information associated with the last operation on the statement handle
*
* @see Doctrine_Adapter_Interface::errorInfo()
* @return array error info array
*/
public function errorInfo()
{
return $this->_stmt->errorInfo();
}
/**
* Executes a prepared statement
*
* If the prepared statement included parameter markers, you must either:
* call PDOStatement->bindParam() to bind PHP variables to the parameter markers:
* bound variables pass their value as input and receive the output value,
* if any, of their associated parameter markers or pass an array of input-only
* parameter values
*
*
* @param array $params An array of values with as many elements as there are
* bound parameters in the SQL statement being executed.
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function execute($params = null)
{
try {
//$event = new Doctrine_Event($this, Doctrine_Event::STMT_EXECUTE, $this->getQuery(), $params);
//$this->_conn->getListener()->preStmtExecute($event);
$result = true;
//if ( ! $event->skipOperation) {
$result = $this->_stmt->execute($params);
//$this->_conn->incrementQueryCount();
//}
//$this->_conn->getListener()->postStmtExecute($event);
return $result;
} catch (PDOException $e) {
$this->_conn->rethrowException($e, $this);
}
return false;
}
/**
* fetch
*
* @see Query::HYDRATE_* constants
* @param integer $fetchStyle Controls how the next row will be returned to the caller.
* This value must be one of the Query::HYDRATE_* constants,
* defaulting to Query::HYDRATE_BOTH
*
* @param integer $cursorOrientation For a PDOStatement object representing a scrollable cursor,
* this value determines which row will be returned to the caller.
* This value must be one of the Query::HYDRATE_ORI_* constants, defaulting to
* Query::HYDRATE_ORI_NEXT. To request a scrollable cursor for your
* PDOStatement object,
* you must set the PDO::ATTR_CURSOR attribute to Doctrine::CURSOR_SCROLL when you
* prepare the SQL statement with Doctrine_Adapter_Interface->prepare().
*
* @param integer $cursorOffset For a PDOStatement object representing a scrollable cursor for which the
* $cursorOrientation parameter is set to Query::HYDRATE_ORI_ABS, this value specifies
* the absolute number of the row in the result set that shall be fetched.
*
* For a PDOStatement object representing a scrollable cursor for
* which the $cursorOrientation parameter is set to Query::HYDRATE_ORI_REL, this value
* specifies the row to fetch relative to the cursor position before
* PDOStatement->fetch() was called.
*
* @return mixed
*/
public function fetch($fetchMode = Query::HYDRATE_BOTH,
$cursorOrientation = Query::HYDRATE_ORI_NEXT,
$cursorOffset = null)
{
//$event = new Doctrine_Event($this, Doctrine_Event::STMT_FETCH, $this->getQuery());
//$event->fetchMode = $fetchMode;
//$event->cursorOrientation = $cursorOrientation;
//$event->cursorOffset = $cursorOffset;
//$data = $this->_conn->getListener()->preFetch($event);
//if ( ! $event->skipOperation) {
$data = $this->_stmt->fetch($fetchMode, $cursorOrientation, $cursorOffset);
//}
//$this->_conn->getListener()->postFetch($event);
return $data;
}
/**
* Returns an array containing all of the result set rows
*
* @param integer $fetchMode Controls how the next row will be returned to the caller.
* This value must be one of the Query::HYDRATE_* constants,
* defaulting to Query::HYDRATE_BOTH
*
* @param integer $columnIndex Returns the indicated 0-indexed column when the value of $fetchStyle is
* Query::HYDRATE_COLUMN. Defaults to 0.
*
* @return array
*/
public function fetchAll($fetchMode = Query::HYDRATE_BOTH, $columnIndex = null)
{
//$event = new Doctrine_Event($this, Doctrine_Event::STMT_FETCHALL, $this->getQuery());
//$event->fetchMode = $fetchMode;
//$event->columnIndex = $columnIndex;
//$this->_conn->getListener()->preFetchAll($event);
//if ( ! $event->skipOperation) {
if ($columnIndex !== null) {
$data = $this->_stmt->fetchAll($fetchMode, $columnIndex);
} else {
$data = $this->_stmt->fetchAll($fetchMode);
}
//$event->data = $data;
//}
//$this->_conn->getListener()->postFetchAll($event);
return $data;
}
/**
* Returns a single column from the next row of a
* result set or FALSE if there are no more rows.
*
* @param integer $columnIndex 0-indexed number of the column you wish to retrieve from the row. If no
* value is supplied, PDOStatement->fetchColumn()
* fetches the first column.
*
* @return string returns a single column in the next row of a result set.
*/
public function fetchColumn($columnIndex = 0)
{
return $this->_stmt->fetchColumn($columnIndex);
}
/**
* Fetches the next row and returns it as an object.
*
* Fetches the next row and returns it as an object. This function is an alternative to
* PDOStatement->fetch() with Query::HYDRATE_CLASS or Query::HYDRATE_OBJ style.
*
* @param string $className Name of the created class, defaults to stdClass.
* @param array $args Elements of this array are passed to the constructor.
*
* @return mixed an instance of the required class with property names that correspond
* to the column names or FALSE in case of an error.
*/
public function fetchObject($className = 'stdClass', $args = array())
{
return $this->_stmt->fetchObject($className, $args);
}
/**
* Retrieve a statement attribute
*
* @param integer $attribute
* @see Doctrine::ATTR_* constants
* @return mixed the attribute value
*/
public function getAttribute($attribute)
{
return $this->_stmt->getAttribute($attribute);
}
/**
* Returns metadata for a column in a result set
*
* @param integer $column The 0-indexed column in the result set.
*
* @return array Associative meta data array with the following structure:
*
* native_type The PHP native type used to represent the column value.
* driver:decl_ type The SQL type used to represent the column value in the database. If the column in the result set is the result of a function, this value is not returned by PDOStatement->getColumnMeta().
* flags Any flags set for this column.
* name The name of this column as returned by the database.
* len The length of this column. Normally -1 for types other than floating point decimals.
* precision The numeric precision of this column. Normally 0 for types other than floating point decimals.
* pdo_type The type of this column as represented by the PDO::PARAM_* constants.
*/
public function getColumnMeta($column)
{
return $this->_stmt->getColumnMeta($column);
}
/**
* Advances to the next rowset in a multi-rowset statement handle
*
* Some database servers support stored procedures that return more than one rowset
* (also known as a result set). The nextRowset() method enables you to access the second
* and subsequent rowsets associated with a PDOStatement object. Each rowset can have a
* different set of columns from the preceding rowset.
*
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function nextRowset()
{
return $this->_stmt->nextRowset();
}
/**
* rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement
* executed by the corresponding object.
*
* If the last SQL statement executed by the associated Statement object was a SELECT statement,
* some databases may return the number of rows returned by that statement. However,
* this behaviour is not guaranteed for all databases and should not be
* relied on for portable applications.
*
* @return integer Returns the number of rows.
*/
public function rowCount()
{
return $this->_stmt->rowCount();
}
/**
* Set a statement attribute
*
* @param integer $attribute
* @param mixed $value the value of given attribute
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function setAttribute($attribute, $value)
{
return $this->_stmt->setAttribute($attribute, $value);
}
/**
* Set the default fetch mode for this statement
*
* @param integer $mode The fetch mode must be one of the Query::HYDRATE_* constants.
* @return boolean Returns 1 on success or FALSE on failure.
*/
public function setFetchMode($mode, $arg1 = null, $arg2 = null)
{
return $this->_stmt->setFetchMode($mode, $arg1, $arg2);
}
}

View File

@ -1,77 +1,77 @@
<?php
/*
* $Id: Apc.php 4910 2008-09-12 08:51:56Z romanb $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Cache;
/**
* APC cache driver.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 1.0
* @version $Revision: 4910 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
*/
class ApcCache implements Cache
{
/**
* {@inheritdoc}
*/
public function __construct()
{
if ( ! extension_loaded('apc')) {
\Doctrine\Common\DoctrineException::updateMe('The apc extension must be loaded in order to use the ApcCache.');
}
}
/**
* {@inheritdoc}
*/
public function fetch($id)
{
return apc_fetch($id);
}
/**
* {@inheritdoc}
*/
public function contains($id)
{
return apc_fetch($id) === false ? false : true;
}
/**
* {@inheritdoc}
*/
public function save($id, $data, $lifeTime = false)
{
return (bool) apc_store($id, $data, $lifeTime);
}
/**
* {@inheritdoc}
*/
public function delete($id)
{
return apc_delete($id);
}
<?php
/*
* $Id: Apc.php 4910 2008-09-12 08:51:56Z romanb $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Cache;
/**
* APC cache driver.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 1.0
* @version $Revision: 4910 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
*/
class ApcCache implements Cache
{
/**
* {@inheritdoc}
*/
public function __construct()
{
if ( ! extension_loaded('apc')) {
\Doctrine\Common\DoctrineException::updateMe('The apc extension must be loaded in order to use the ApcCache.');
}
}
/**
* {@inheritdoc}
*/
public function fetch($id)
{
return apc_fetch($id);
}
/**
* {@inheritdoc}
*/
public function contains($id)
{
return apc_fetch($id) === false ? false : true;
}
/**
* {@inheritdoc}
*/
public function save($id, $data, $lifeTime = false)
{
return (bool) apc_store($id, $data, $lifeTime);
}
/**
* {@inheritdoc}
*/
public function delete($id)
{
return apc_delete($id);
}
}

View File

@ -1,92 +1,92 @@
<?php
/*
* $Id: Array.php 4910 2008-09-12 08:51:56Z romanb $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Cache;
/**
* Array cache driver.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 1.0
* @version $Revision: 4910 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class ArrayCache implements Cache
{
/**
* @var array $data
*/
private $data;
/**
* {@inheritdoc}
*/
public function fetch($id)
{
if (isset($this->data[$id])) {
return $this->data[$id];
}
return false;
}
/**
* {@inheritdoc}
*/
public function contains($id)
{
return isset($this->data[$id]);
}
/**
* {@inheritdoc}
*/
public function save($id, $data, $lifeTime = false)
{
$this->data[$id] = $data;
}
/**
* {@inheritdoc}
*/
public function delete($id)
{
unset($this->data[$id]);
}
/**
* {@inheritdoc}
*/
public function deleteAll()
{
$this->data = array();
}
/**
* count
*
* @return integer
*/
public function count()
{
return count($this->data);
}
<?php
/*
* $Id: Array.php 4910 2008-09-12 08:51:56Z romanb $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Cache;
/**
* Array cache driver.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 1.0
* @version $Revision: 4910 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class ArrayCache implements Cache
{
/**
* @var array $data
*/
private $data;
/**
* {@inheritdoc}
*/
public function fetch($id)
{
if (isset($this->data[$id])) {
return $this->data[$id];
}
return false;
}
/**
* {@inheritdoc}
*/
public function contains($id)
{
return isset($this->data[$id]);
}
/**
* {@inheritdoc}
*/
public function save($id, $data, $lifeTime = false)
{
$this->data[$id] = $data;
}
/**
* {@inheritdoc}
*/
public function delete($id)
{
unset($this->data[$id]);
}
/**
* {@inheritdoc}
*/
public function deleteAll()
{
$this->data = array();
}
/**
* count
*
* @return integer
*/
public function count()
{
return count($this->data);
}
}

View File

@ -1,71 +1,71 @@
<?php
/*
* $Id: Interface.php 3931 2008-03-05 11:24:33Z romanb $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Cache;
/**
* Interface for cache drivers.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 1.0
* @version $Revision: 3931 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
*/
interface Cache
{
/**
* Test if a cache entry is available for the given id and (if yes) return it (false else).
*
* Note : return value is always "string" (unserialization is done by the core not by the backend)
*
* @param string $id cache id
* @return string cached datas (or false)
*/
public function fetch($id);
/**
* Test if a cache is available or not (for the given id)
*
* @param string $id cache id
* @return mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record
*/
public function contains($id);
/**
* Puts data into the cache.
*
* @param string $id cache id
* @param string $data data to cache
* @param int $lifeTime if != false, set a specific lifetime for this cache record (null => infinite lifeTime)
* @return boolean true if no problem
*/
public function save($id, $data, $lifeTime = false);
/**
* Remove a cache record
*
* @param string $id cache id
* @return boolean true if no problem
*/
public function delete($id);
<?php
/*
* $Id: Interface.php 3931 2008-03-05 11:24:33Z romanb $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Cache;
/**
* Interface for cache drivers.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 1.0
* @version $Revision: 3931 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
*/
interface Cache
{
/**
* Test if a cache entry is available for the given id and (if yes) return it (false else).
*
* Note : return value is always "string" (unserialization is done by the core not by the backend)
*
* @param string $id cache id
* @return string cached datas (or false)
*/
public function fetch($id);
/**
* Test if a cache is available or not (for the given id)
*
* @param string $id cache id
* @return mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record
*/
public function contains($id);
/**
* Puts data into the cache.
*
* @param string $id cache id
* @param string $data data to cache
* @param int $lifeTime if != false, set a specific lifetime for this cache record (null => infinite lifeTime)
* @return boolean true if no problem
*/
public function save($id, $data, $lifeTime = false);
/**
* Remove a cache record
*
* @param string $id cache id
* @return boolean true if no problem
*/
public function delete($id);
}

View File

@ -1,181 +1,181 @@
<?php
/*
* $Id: Db.php 3931 2008-03-05 11:24:33Z romanb $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Cache;
/**
* Doctrine_Cache_Db
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 1.0
* @version $Revision: 3931 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @todo Needs some maintenance. Any takers?
*/
class DbCache implements Cache, \Countable
{
private $_options = array();
/**
* {@inheritdoc}
*/
public function __construct($options)
{
if ( ! isset($options['connection']) ||
! ($options['connection'] instanceof Doctrine_DBAL_Connection)) {
throw \Doctrine\Common\DoctrineException::updateMe('Connection option not set.');
}
if ( ! isset($options['tableName']) ||
! is_string($options['tableName'])) {
throw \Doctrine\Common\DoctrineException::updateMe('Table name option not set.');
}
$this->_options = $options;
}
/**
* getConnection
* returns the connection object associated with this cache driver
*
* @return Doctrine_Connection connection object
*/
public function getConnection()
{
return $this->_options['connection'];
}
/**
* {@inheritdoc}
*/
public function fetch($id)
{
$sql = 'SELECT data, expire FROM ' . $this->_options['tableName']
. ' WHERE id = ?';
if ($testCacheValidity) {
$sql .= ' AND (expire=0 OR expire > ' . time() . ')';
}
$result = $this->getConnection()->fetchAssoc($sql, array($id));
if ( ! isset($result[0])) {
return false;
}
return unserialize($result[0]['data']);
}
/**
* {@inheritdoc}
*/
public function contains($id)
{
$sql = 'SELECT expire FROM ' . $this->_options['tableName']
. ' WHERE id = ? AND (expire=0 OR expire > ' . time() . ')';
return $this->getConnection()->fetchOne($sql, array($id));
}
/**
* {@inheritdoc}
*/
public function save($data, $id, $lifeTime = false)
{
$sql = 'INSERT INTO ' . $this->_options['tableName']
. ' (id, data, expire) VALUES (?, ?, ?)';
if ($lifeTime) {
$expire = time() + $lifeTime;
} else {
$expire = 0;
}
$params = array($id, serialize($data), $expire);
return (bool) $this->getConnection()->exec($sql, $params);
}
/**
* {@inheritdoc}
*/
public function delete($id)
{
$sql = 'DELETE FROM ' . $this->_options['tableName'] . ' WHERE id = ?';
return (bool) $this->getConnection()->exec($sql, array($id));
}
/**
* Removes all cache records
*
* $return bool true on success, false on failure
*/
public function deleteAll()
{
$sql = 'DELETE FROM ' . $this->_options['tableName'];
return (bool) $this->getConnection()->exec($sql);
}
/**
* count
* returns the number of cached elements
*
* @return integer
*/
public function count()
{
$sql = 'SELECT COUNT(*) FROM ' . $this->_options['tableName'];
return (int) $this->getConnection()->fetchOne($sql);
}
/**
* Creates the cache table.
*/
public function createTable()
{
$name = $this->_options['tableName'];
$fields = array(
'id' => array(
'type' => 'string',
'length' => 255
),
'data' => array(
'type' => 'blob'
),
'expire' => array(
'type' => 'timestamp'
)
);
$options = array(
'primary' => array('id')
);
$this->getConnection()->export->createTable($name, $fields, $options);
}
<?php
/*
* $Id: Db.php 3931 2008-03-05 11:24:33Z romanb $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Cache;
/**
* Doctrine_Cache_Db
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 1.0
* @version $Revision: 3931 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @todo Needs some maintenance. Any takers?
*/
class DbCache implements Cache, \Countable
{
private $_options = array();
/**
* {@inheritdoc}
*/
public function __construct($options)
{
if ( ! isset($options['connection']) ||
! ($options['connection'] instanceof Doctrine_DBAL_Connection)) {
throw \Doctrine\Common\DoctrineException::updateMe('Connection option not set.');
}
if ( ! isset($options['tableName']) ||
! is_string($options['tableName'])) {
throw \Doctrine\Common\DoctrineException::updateMe('Table name option not set.');
}
$this->_options = $options;
}
/**
* getConnection
* returns the connection object associated with this cache driver
*
* @return Doctrine_Connection connection object
*/
public function getConnection()
{
return $this->_options['connection'];
}
/**
* {@inheritdoc}
*/
public function fetch($id)
{
$sql = 'SELECT data, expire FROM ' . $this->_options['tableName']
. ' WHERE id = ?';
if ($testCacheValidity) {
$sql .= ' AND (expire=0 OR expire > ' . time() . ')';
}
$result = $this->getConnection()->fetchAssoc($sql, array($id));
if ( ! isset($result[0])) {
return false;
}
return unserialize($result[0]['data']);
}
/**
* {@inheritdoc}
*/
public function contains($id)
{
$sql = 'SELECT expire FROM ' . $this->_options['tableName']
. ' WHERE id = ? AND (expire=0 OR expire > ' . time() . ')';
return $this->getConnection()->fetchOne($sql, array($id));
}
/**
* {@inheritdoc}
*/
public function save($data, $id, $lifeTime = false)
{
$sql = 'INSERT INTO ' . $this->_options['tableName']
. ' (id, data, expire) VALUES (?, ?, ?)';
if ($lifeTime) {
$expire = time() + $lifeTime;
} else {
$expire = 0;
}
$params = array($id, serialize($data), $expire);
return (bool) $this->getConnection()->exec($sql, $params);
}
/**
* {@inheritdoc}
*/
public function delete($id)
{
$sql = 'DELETE FROM ' . $this->_options['tableName'] . ' WHERE id = ?';
return (bool) $this->getConnection()->exec($sql, array($id));
}
/**
* Removes all cache records
*
* $return bool true on success, false on failure
*/
public function deleteAll()
{
$sql = 'DELETE FROM ' . $this->_options['tableName'];
return (bool) $this->getConnection()->exec($sql);
}
/**
* count
* returns the number of cached elements
*
* @return integer
*/
public function count()
{
$sql = 'SELECT COUNT(*) FROM ' . $this->_options['tableName'];
return (int) $this->getConnection()->fetchOne($sql);
}
/**
* Creates the cache table.
*/
public function createTable()
{
$name = $this->_options['tableName'];
$fields = array(
'id' => array(
'type' => 'string',
'length' => 255
),
'data' => array(
'type' => 'blob'
),
'expire' => array(
'type' => 'timestamp'
)
);
$options = array(
'primary' => array('id')
);
$this->getConnection()->export->createTable($name, $fields, $options);
}
}

View File

@ -1,101 +1,101 @@
<?php
/*
* $Id: Memcache.php 4910 2008-09-12 08:51:56Z romanb $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Cache;
/**
* Memcache cache driver.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 4910 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class MemcacheCache implements Cache
{
/**
* @var Memcache $_memcache memcache object
*/
private $_memcache;
/**
* {@inheritdoc}
*/
public function __construct()
{
if ( ! extension_loaded('memcache')) {
throw \Doctrine\Common\DoctrineException::updateMe('In order to use Memcache driver, the memcache extension must be loaded.');
}
}
/**
* Sets the memcache instance to use.
*
* @param Memcache $memcache
*/
public function setMemcache(Memcache $memcache)
{
$this->_memcache = $memcache;
}
/**
* Gets the memcache instance used by the cache.
*
* @return Memcache
*/
public function getMemcache()
{
return $this->_memcache;
}
/**
* {@inheritdoc}
*/
public function fetch($id)
{
return $this->_memcache->get($id);
}
/**
* {@inheritdoc}
*/
public function contains($id)
{
return (bool) $this->_memcache->get($id);
}
/**
* {@inheritdoc}
*/
public function save($id, $data, $lifeTime = false)
{
return $this->_memcache->set($id, $data, 0, $lifeTime);
}
/**
* {@inheritdoc}
*/
public function delete($id)
{
return $this->_memcache->delete($id);
}
<?php
/*
* $Id: Memcache.php 4910 2008-09-12 08:51:56Z romanb $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Cache;
/**
* Memcache cache driver.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 4910 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class MemcacheCache implements Cache
{
/**
* @var Memcache $_memcache memcache object
*/
private $_memcache;
/**
* {@inheritdoc}
*/
public function __construct()
{
if ( ! extension_loaded('memcache')) {
throw \Doctrine\Common\DoctrineException::updateMe('In order to use Memcache driver, the memcache extension must be loaded.');
}
}
/**
* Sets the memcache instance to use.
*
* @param Memcache $memcache
*/
public function setMemcache(Memcache $memcache)
{
$this->_memcache = $memcache;
}
/**
* Gets the memcache instance used by the cache.
*
* @return Memcache
*/
public function getMemcache()
{
return $this->_memcache;
}
/**
* {@inheritdoc}
*/
public function fetch($id)
{
return $this->_memcache->get($id);
}
/**
* {@inheritdoc}
*/
public function contains($id)
{
return (bool) $this->_memcache->get($id);
}
/**
* {@inheritdoc}
*/
public function save($id, $data, $lifeTime = false)
{
return $this->_memcache->set($id, $data, 0, $lifeTime);
}
/**
* {@inheritdoc}
*/
public function delete($id)
{
return $this->_memcache->delete($id);
}
}

View File

@ -1,62 +1,62 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* DeleteStatement = DeleteClause [WhereClause]
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 2.0
* @version $Revision$
*/
class DeleteStatement extends Node
{
private $_deleteClause;
private $_whereClause;
public function __construct($deleteClause)
{
$this->_deleteClause = $deleteClause;
}
public function setWhereClause($whereClause)
{
$this->_whereClause = $whereClause;
}
public function getDeleteClause()
{
return $this->_deleteClause;
}
public function getWhereClause()
{
return $this->_whereClause;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkDeleteStatement($this);
}
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* DeleteStatement = DeleteClause [WhereClause]
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 2.0
* @version $Revision$
*/
class DeleteStatement extends Node
{
private $_deleteClause;
private $_whereClause;
public function __construct($deleteClause)
{
$this->_deleteClause = $deleteClause;
}
public function setWhereClause($whereClause)
{
$this->_whereClause = $whereClause;
}
public function getDeleteClause()
{
return $this->_deleteClause;
}
public function getWhereClause()
{
return $this->_whereClause;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkDeleteStatement($this);
}
}

View File

@ -1,52 +1,52 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* FromClause ::= "FROM" IdentificationVariableDeclaration {"," IdentificationVariableDeclaration}
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 2.0
* @version $Revision$
*/
class FromClause extends Node
{
protected $_identificationVariableDeclarations = array();
public function __construct(array $identificationVariableDeclarations)
{
$this->_identificationVariableDeclarations = $identificationVariableDeclarations;
}
/* Getters */
public function getIdentificationVariableDeclarations()
{
return $this->_identificationVariableDeclarations;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkFromClause($this);
}
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* FromClause ::= "FROM" IdentificationVariableDeclaration {"," IdentificationVariableDeclaration}
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 2.0
* @version $Revision$
*/
class FromClause extends Node
{
protected $_identificationVariableDeclarations = array();
public function __construct(array $identificationVariableDeclarations)
{
$this->_identificationVariableDeclarations = $identificationVariableDeclarations;
}
/* Getters */
public function getIdentificationVariableDeclarations()
{
return $this->_identificationVariableDeclarations;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkFromClause($this);
}
}

View File

@ -1,70 +1,70 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* IdentificationVariableDeclaration ::= RangeVariableDeclaration [IndexBy] {JoinVariableDeclaration}*
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.doctrine-project.org
* @since 2.0
* @version $Revision$
*/
class IdentificationVariableDeclaration extends Node
{
protected $_rangeVariableDeclaration = null;
protected $_indexBy = null;
protected $_joinVariableDeclarations = array();
public function __construct($rangeVariableDecl, $indexBy, array $joinVariableDecls)
{
$this->_rangeVariableDeclaration = $rangeVariableDecl;
$this->_indexBy = $indexBy;
$this->_joinVariableDeclarations = $joinVariableDecls;
}
/* Getters */
public function getRangeVariableDeclaration()
{
return $this->_rangeVariableDeclaration;
}
public function getIndexBy()
{
return $this->_indexBy;
}
public function getJoinVariableDeclarations()
{
return $this->_joinVariableDeclarations;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkIdentificationVariableDeclaration($this);
}
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* IdentificationVariableDeclaration ::= RangeVariableDeclaration [IndexBy] {JoinVariableDeclaration}*
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.doctrine-project.org
* @since 2.0
* @version $Revision$
*/
class IdentificationVariableDeclaration extends Node
{
protected $_rangeVariableDeclaration = null;
protected $_indexBy = null;
protected $_joinVariableDeclarations = array();
public function __construct($rangeVariableDecl, $indexBy, array $joinVariableDecls)
{
$this->_rangeVariableDeclaration = $rangeVariableDecl;
$this->_indexBy = $indexBy;
$this->_joinVariableDeclarations = $joinVariableDecls;
}
/* Getters */
public function getRangeVariableDeclaration()
{
return $this->_rangeVariableDeclaration;
}
public function getIndexBy()
{
return $this->_indexBy;
}
public function getJoinVariableDeclarations()
{
return $this->_joinVariableDeclarations;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkIdentificationVariableDeclaration($this);
}
}

View File

@ -1,52 +1,52 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* IndexBy ::= "INDEX" "BY" SimpleStateFieldPathExpression
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.doctrine-project.org
* @since 2.0
* @version $Revision$
*/
class IndexBy extends Node
{
protected $_simpleStateFieldPathExpression = null;
public function __construct($simpleStateFieldPathExpression)
{
$this->_simpleStateFieldPathExpression = $simpleStateFieldPathExpression;
}
/* Getters */
public function getSimpleStateFieldPathExpression()
{
return $this->_simpleStateFieldPathExpression;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkIndexBy($this);
}
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* IndexBy ::= "INDEX" "BY" SimpleStateFieldPathExpression
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.doctrine-project.org
* @since 2.0
* @version $Revision$
*/
class IndexBy extends Node
{
protected $_simpleStateFieldPathExpression = null;
public function __construct($simpleStateFieldPathExpression)
{
$this->_simpleStateFieldPathExpression = $simpleStateFieldPathExpression;
}
/* Getters */
public function getSimpleStateFieldPathExpression()
{
return $this->_simpleStateFieldPathExpression;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkIndexBy($this);
}
}

View File

@ -1,97 +1,97 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* Join ::= ["LEFT" ["OUTER"] | "INNER"] "JOIN" JoinAssociationPathExpression
* ["AS"] AliasIdentificationVariable [("ON" | "WITH") ConditionalExpression]
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 2.0
* @version $Revision$
*/
class Join extends Node
{
const JOIN_TYPE_LEFT = 1;
const JOIN_TYPE_LEFTOUTER = 2;
const JOIN_TYPE_INNER = 3;
const JOIN_WHERE_ON = 1;
const JOIN_WHERE_WITH = 2;
protected $_joinType = self::JOIN_TYPE_INNER;
protected $_joinAssociationPathExpression = null;
protected $_aliasIdentificationVariable = null;
protected $_whereType = self::JOIN_WHERE_WITH;
protected $_conditionalExpression = null;
public function __construct($joinType, $joinAssocPathExpr, $aliasIdentVar)
{
$this->_joinType = $joinType;
$this->_joinAssociationPathExpression = $joinAssocPathExpr;
$this->_aliasIdentificationVariable = $aliasIdentVar;
}
/* Setters */
public function setWhereType($whereType)
{
$this->_whereType = $whereType;
}
public function setConditionalExpression($conditionalExpression)
{
$this->_conditionalExpression = $conditionalExpression;
}
/* Getters */
public function getJoinType()
{
return $this->_joinType;
}
public function getJoinAssociationPathExpression()
{
return $this->_joinAssociationPathExpression;
}
public function getAliasIdentificationVariable()
{
return $this->_aliasIdentificationVariable;
}
public function getWhereType()
{
return $this->_whereType;
}
public function getConditionalExpression()
{
return $this->_conditionalExpression;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkJoin($this);
}
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* Join ::= ["LEFT" ["OUTER"] | "INNER"] "JOIN" JoinAssociationPathExpression
* ["AS"] AliasIdentificationVariable [("ON" | "WITH") ConditionalExpression]
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 2.0
* @version $Revision$
*/
class Join extends Node
{
const JOIN_TYPE_LEFT = 1;
const JOIN_TYPE_LEFTOUTER = 2;
const JOIN_TYPE_INNER = 3;
const JOIN_WHERE_ON = 1;
const JOIN_WHERE_WITH = 2;
protected $_joinType = self::JOIN_TYPE_INNER;
protected $_joinAssociationPathExpression = null;
protected $_aliasIdentificationVariable = null;
protected $_whereType = self::JOIN_WHERE_WITH;
protected $_conditionalExpression = null;
public function __construct($joinType, $joinAssocPathExpr, $aliasIdentVar)
{
$this->_joinType = $joinType;
$this->_joinAssociationPathExpression = $joinAssocPathExpr;
$this->_aliasIdentificationVariable = $aliasIdentVar;
}
/* Setters */
public function setWhereType($whereType)
{
$this->_whereType = $whereType;
}
public function setConditionalExpression($conditionalExpression)
{
$this->_conditionalExpression = $conditionalExpression;
}
/* Getters */
public function getJoinType()
{
return $this->_joinType;
}
public function getJoinAssociationPathExpression()
{
return $this->_joinAssociationPathExpression;
}
public function getAliasIdentificationVariable()
{
return $this->_aliasIdentificationVariable;
}
public function getWhereType()
{
return $this->_whereType;
}
public function getConditionalExpression()
{
return $this->_conditionalExpression;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkJoin($this);
}
}

View File

@ -1,59 +1,59 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* JoinVariableDeclaration ::= Join [IndexBy]
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 2.0
* @version $Revision$
*/
class JoinVariableDeclaration extends Node
{
protected $_join = null;
protected $_indexBy = null;
public function __construct($join, $indexBy)
{
$this->_join = $join;
$this->_indexBy = $indexBy;
}
/* Getters */
public function getJoin()
{
return $this->_join;
}
public function getIndexBy()
{
return $this->_indexBy;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkJoinVariableDeclaration($this);
}
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* JoinVariableDeclaration ::= Join [IndexBy]
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 2.0
* @version $Revision$
*/
class JoinVariableDeclaration extends Node
{
protected $_join = null;
protected $_indexBy = null;
public function __construct($join, $indexBy)
{
$this->_join = $join;
$this->_indexBy = $indexBy;
}
/* Getters */
public function getJoin()
{
return $this->_join;
}
public function getIndexBy()
{
return $this->_indexBy;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkJoinVariableDeclaration($this);
}
}

View File

@ -1,38 +1,38 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* Abstract class of an AST node
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.doctrine-project.org
* @since 2.0
* @version $Revision$
*/
abstract class Node
{
abstract public function dispatch($sqlWalker);
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* Abstract class of an AST node
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.doctrine-project.org
* @since 2.0
* @version $Revision$
*/
abstract class Node
{
abstract public function dispatch($sqlWalker);
}

View File

@ -1,66 +1,66 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* RangeVariableDeclaration ::= AbstractSchemaName ["AS"] AliasIdentificationVariable
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.doctrine-project.org
* @since 2.0
* @version $Revision$
*/
class RangeVariableDeclaration extends Node
{
private $_classMetadata;
private $_abstractSchemaName;
private $_aliasIdentificationVariable;
public function __construct($classMetadata, $aliasIdentificationVar)
{
$this->_classMetadata = $classMetadata;
$this->_abstractSchemaName = $classMetadata->name;
$this->_aliasIdentificationVariable = $aliasIdentificationVar;
}
/* Getters */
public function getAbstractSchemaName()
{
return $this->_abstractSchemaName;
}
public function getAliasIdentificationVariable()
{
return $this->_aliasIdentificationVariable;
}
public function getClassMetadata()
{
return $this->_classMetadata;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkRangeVariableDeclaration($this);
}
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* RangeVariableDeclaration ::= AbstractSchemaName ["AS"] AliasIdentificationVariable
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.doctrine-project.org
* @since 2.0
* @version $Revision$
*/
class RangeVariableDeclaration extends Node
{
private $_classMetadata;
private $_abstractSchemaName;
private $_aliasIdentificationVariable;
public function __construct($classMetadata, $aliasIdentificationVar)
{
$this->_classMetadata = $classMetadata;
$this->_abstractSchemaName = $classMetadata->name;
$this->_aliasIdentificationVariable = $aliasIdentificationVar;
}
/* Getters */
public function getAbstractSchemaName()
{
return $this->_abstractSchemaName;
}
public function getAliasIdentificationVariable()
{
return $this->_aliasIdentificationVariable;
}
public function getClassMetadata()
{
return $this->_classMetadata;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkRangeVariableDeclaration($this);
}
}

View File

@ -1,77 +1,77 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* SelectClause = "SELECT" ["DISTINCT"] SelectExpression {"," SelectExpression}
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.doctrine-project.org
* @since 2.0
* @version $Revision$
*/
class SelectClause extends Node
{
protected $_isDistinct;
protected $_selectExpressions = array();
public function __construct(array $selectExpressions, $isDistinct)
{
$this->_isDistinct = $isDistinct;
$this->_selectExpressions = $selectExpressions;
}
/* Getters */
public function isDistinct()
{
return $this->_isDistinct;
}
public function getSelectExpressions()
{
return $this->_selectExpressions;
}
/* REMOVE ME LATER. COPIED METHODS FROM SPLIT OF PRODUCTION INTO "AST" AND "PARSER" */
public function buildSql()
{
return 'SELECT ' . (($this->_isDistinct) ? 'DISTINCT ' : '')
. implode(', ', $this->_mapSelectExpressions());
}
protected function _mapSelectExpressions()
{
return array_map(array(&$this, '_mapSelectExpression'), $this->_selectExpressions);
}
protected function _mapSelectExpression($value)
{
return is_object($value) ? $value->buildSql() : $value;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkSelectClause($this);
}
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* SelectClause = "SELECT" ["DISTINCT"] SelectExpression {"," SelectExpression}
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.doctrine-project.org
* @since 2.0
* @version $Revision$
*/
class SelectClause extends Node
{
protected $_isDistinct;
protected $_selectExpressions = array();
public function __construct(array $selectExpressions, $isDistinct)
{
$this->_isDistinct = $isDistinct;
$this->_selectExpressions = $selectExpressions;
}
/* Getters */
public function isDistinct()
{
return $this->_isDistinct;
}
public function getSelectExpressions()
{
return $this->_selectExpressions;
}
/* REMOVE ME LATER. COPIED METHODS FROM SPLIT OF PRODUCTION INTO "AST" AND "PARSER" */
public function buildSql()
{
return 'SELECT ' . (($this->_isDistinct) ? 'DISTINCT ' : '')
. implode(', ', $this->_mapSelectExpressions());
}
protected function _mapSelectExpressions()
{
return array_map(array(&$this, '_mapSelectExpression'), $this->_selectExpressions);
}
protected function _mapSelectExpression($value)
{
return is_object($value) ? $value->buildSql() : $value;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkSelectClause($this);
}
}

View File

@ -1,60 +1,60 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* SelectExpression ::= IdentificationVariable ["." "*"] | StateFieldPathExpression |
* (AggregateExpression | "(" Subselect ")") [["AS"] FieldAliasIdentificationVariable]
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 2.0
* @version $Revision$
*/
class SelectExpression extends Node
{
protected $_expression;
protected $_fieldIdentificationVariable;
public function __construct($expression, $fieldIdentificationVariable)
{
$this->_expression = $expression;
$this->_fieldIdentificationVariable = $fieldIdentificationVariable;
}
/* Getters */
public function getExpression()
{
return $this->_expression;
}
public function getFieldIdentificationVariable()
{
return $this->_fieldIdentificationVariable;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkSelectExpression($this);
}
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* SelectExpression ::= IdentificationVariable ["." "*"] | StateFieldPathExpression |
* (AggregateExpression | "(" Subselect ")") [["AS"] FieldAliasIdentificationVariable]
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 2.0
* @version $Revision$
*/
class SelectExpression extends Node
{
protected $_expression;
protected $_fieldIdentificationVariable;
public function __construct($expression, $fieldIdentificationVariable)
{
$this->_expression = $expression;
$this->_fieldIdentificationVariable = $fieldIdentificationVariable;
}
/* Getters */
public function getExpression()
{
return $this->_expression;
}
public function getFieldIdentificationVariable()
{
return $this->_fieldIdentificationVariable;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkSelectExpression($this);
}
}

View File

@ -1,87 +1,87 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* SelectStatement = SelectClause FromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 2.0
* @version $Revision$
*/
class SelectStatement extends Node
{
protected $_selectClause;
protected $_fromClause;
protected $_whereClause;
protected $_groupByClause;
protected $_havingClause;
protected $_orderByClause;
public function __construct($selectClause, $fromClause, $whereClause, $groupByClause,
$havingClause, $orderByClause) {
$this->_selectClause = $selectClause;
$this->_fromClause = $fromClause;
$this->_whereClause = $whereClause;
$this->_groupByClause = $groupByClause;
$this->_havingClause = $havingClause;
$this->_orderByClause = $orderByClause;
}
/* Getters */
public function getSelectClause()
{
return $this->_selectClause;
}
public function getFromClause()
{
return $this->_fromClause;
}
public function getWhereClause()
{
return $this->_whereClause;
}
public function getGroupByClause()
{
return $this->_groupByClause;
}
public function getHavingClause()
{
return $this->_havingClause;
}
public function getOrderByClause()
{
return $this->_orderByClause;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkSelectStatement($this);
}
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* SelectStatement = SelectClause FromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 2.0
* @version $Revision$
*/
class SelectStatement extends Node
{
protected $_selectClause;
protected $_fromClause;
protected $_whereClause;
protected $_groupByClause;
protected $_havingClause;
protected $_orderByClause;
public function __construct($selectClause, $fromClause, $whereClause, $groupByClause,
$havingClause, $orderByClause) {
$this->_selectClause = $selectClause;
$this->_fromClause = $fromClause;
$this->_whereClause = $whereClause;
$this->_groupByClause = $groupByClause;
$this->_havingClause = $havingClause;
$this->_orderByClause = $orderByClause;
}
/* Getters */
public function getSelectClause()
{
return $this->_selectClause;
}
public function getFromClause()
{
return $this->_fromClause;
}
public function getWhereClause()
{
return $this->_whereClause;
}
public function getGroupByClause()
{
return $this->_groupByClause;
}
public function getHavingClause()
{
return $this->_havingClause;
}
public function getOrderByClause()
{
return $this->_orderByClause;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkSelectStatement($this);
}
}

View File

@ -1,63 +1,63 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* SimpleSelectClause ::= "SELECT" ["DISTINCT"] SimpleSelectExpression
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.doctrine-project.org
* @since 2.0
* @version $Revision$
*/
class SimpleSelectClause extends Node
{
private $_isDistinct = false;
private $_simpleSelectExpression;
public function __construct($simpleSelectExpression)
{
$this->_simpleSelectExpression = $simpleSelectExpression;
}
/* Getters */
public function isDistinct()
{
return $this->_isDistinct;
}
public function setDistinct($bool)
{
$this->_isDistinct = $bool;
}
public function getSimpleSelectExpression()
{
return $this->_simpleSelectExpression;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkSimpleSelectClause($this);
}
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* SimpleSelectClause ::= "SELECT" ["DISTINCT"] SimpleSelectExpression
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.doctrine-project.org
* @since 2.0
* @version $Revision$
*/
class SimpleSelectClause extends Node
{
private $_isDistinct = false;
private $_simpleSelectExpression;
public function __construct($simpleSelectExpression)
{
$this->_simpleSelectExpression = $simpleSelectExpression;
}
/* Getters */
public function isDistinct()
{
return $this->_isDistinct;
}
public function setDistinct($bool)
{
$this->_isDistinct = $bool;
}
public function getSimpleSelectExpression()
{
return $this->_simpleSelectExpression;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkSimpleSelectClause($this);
}
}

View File

@ -1,63 +1,63 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* SimpleSelectExpression ::= StateFieldPathExpression | IdentificationVariable
* | (AggregateExpression [["AS"] FieldAliasIdentificationVariable])
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.doctrine-project.org
* @since 2.0
* @version $Revision$
*/
class SimpleSelectExpression extends Node
{
private $_expression;
private $_fieldIdentificationVariable;
public function __construct($expression)
{
$this->_expression = $expression;
}
public function getExpression()
{
return $this->_expression;
}
public function getFieldIdentificationVariable()
{
return $this->_fieldIdentificationVariable;
}
public function setFieldIdentificationVariable($fieldAlias)
{
$this->_fieldIdentificationVariable = $fieldAlias;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkSimpleSelectExpression($this);
}
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* SimpleSelectExpression ::= StateFieldPathExpression | IdentificationVariable
* | (AggregateExpression [["AS"] FieldAliasIdentificationVariable])
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.doctrine-project.org
* @since 2.0
* @version $Revision$
*/
class SimpleSelectExpression extends Node
{
private $_expression;
private $_fieldIdentificationVariable;
public function __construct($expression)
{
$this->_expression = $expression;
}
public function getExpression()
{
return $this->_expression;
}
public function getFieldIdentificationVariable()
{
return $this->_fieldIdentificationVariable;
}
public function setFieldIdentificationVariable($fieldAlias)
{
$this->_fieldIdentificationVariable = $fieldAlias;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkSimpleSelectExpression($this);
}
}

View File

@ -1,59 +1,59 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* SimpleStateFieldPathExpression ::= IdentificationVariable "." SimpleStateField
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.doctrine-project.org
* @since 2.0
* @version $Revision$
*/
class SimpleStateFieldPathExpression extends Node
{
private $_identificationVariable = null;
private $_simpleStateField = null;
public function __construct($identificationVariable, $simpleStateField)
{
$this->_identificationVariable = $identificationVariable;
$this->_simpleStateField = $simpleStateField;
}
/* Getters */
public function getIdentificationVariable()
{
return $this->_identificationVariable;
}
public function getSimpleStateField()
{
return $this->_simpleStateField;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkSimpleStateFieldPathExpression($this);
}
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* SimpleStateFieldPathExpression ::= IdentificationVariable "." SimpleStateField
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.doctrine-project.org
* @since 2.0
* @version $Revision$
*/
class SimpleStateFieldPathExpression extends Node
{
private $_identificationVariable = null;
private $_simpleStateField = null;
public function __construct($identificationVariable, $simpleStateField)
{
$this->_identificationVariable = $identificationVariable;
$this->_simpleStateField = $simpleStateField;
}
/* Getters */
public function getIdentificationVariable()
{
return $this->_identificationVariable;
}
public function getSimpleStateField()
{
return $this->_simpleStateField;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkSimpleStateFieldPathExpression($this);
}
}

View File

@ -1,103 +1,103 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* Subselect ::= SimpleSelectClause SubselectFromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.doctrine-project.org
* @since 2.0
* @version $Revision$
*/
class Subselect extends Node
{
private $_simpleSelectClause;
private $_subselectFromClause;
private $_whereClause;
private $_groupByClause;
private $_havingClause;
private $_orderByClause;
public function __construct($simpleSelectClause, $subselectFromClause)
{
$this->_simpleSelectClause = $simpleSelectClause;
$this->_subselectFromClause = $subselectFromClause;
}
/* Getters */
public function getSimpleSelectClause()
{
return $this->_simpleSelectClause;
}
public function getSubselectFromClause()
{
return $this->_subselectFromClause;
}
public function getWhereClause()
{
return $this->_whereClause;
}
public function setWhereClause($whereClause)
{
$this->_whereClause = $whereClause;
}
public function getGroupByClause()
{
return $this->_groupByClause;
}
public function setGroupByClause($groupByClause)
{
$this->_groupByClause = $groupByClause;
}
public function getHavingClause()
{
return $this->_havingClause;
}
public function setHavingClause($havingClause)
{
$this->_havingClause = $havingClause;
}
public function getOrderByClause()
{
return $this->_orderByClause;
}
public function setOrderByClause($orderByClause)
{
$this->_orderByClause = $orderByClause;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkSubselect($this);
}
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* Subselect ::= SimpleSelectClause SubselectFromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.doctrine-project.org
* @since 2.0
* @version $Revision$
*/
class Subselect extends Node
{
private $_simpleSelectClause;
private $_subselectFromClause;
private $_whereClause;
private $_groupByClause;
private $_havingClause;
private $_orderByClause;
public function __construct($simpleSelectClause, $subselectFromClause)
{
$this->_simpleSelectClause = $simpleSelectClause;
$this->_subselectFromClause = $subselectFromClause;
}
/* Getters */
public function getSimpleSelectClause()
{
return $this->_simpleSelectClause;
}
public function getSubselectFromClause()
{
return $this->_subselectFromClause;
}
public function getWhereClause()
{
return $this->_whereClause;
}
public function setWhereClause($whereClause)
{
$this->_whereClause = $whereClause;
}
public function getGroupByClause()
{
return $this->_groupByClause;
}
public function setGroupByClause($groupByClause)
{
$this->_groupByClause = $groupByClause;
}
public function getHavingClause()
{
return $this->_havingClause;
}
public function setHavingClause($havingClause)
{
$this->_havingClause = $havingClause;
}
public function getOrderByClause()
{
return $this->_orderByClause;
}
public function setOrderByClause($orderByClause)
{
$this->_orderByClause = $orderByClause;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkSubselect($this);
}
}

View File

@ -1,52 +1,52 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* SubselectFromClause ::= "FROM" SubselectIdentificationVariableDeclaration {"," SubselectIdentificationVariableDeclaration}*
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.doctrine-project.org
* @since 2.0
* @version $Revision$
*/
class SubselectFromClause extends Node
{
private $_identificationVariableDeclarations = array();
public function __construct(array $identificationVariableDeclarations)
{
$this->_identificationVariableDeclarations = $identificationVariableDeclarations;
}
/* Getters */
public function getSubselectIdentificationVariableDeclarations()
{
return $this->_identificationVariableDeclarations;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkSubselectFromClause($this);
}
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* SubselectFromClause ::= "FROM" SubselectIdentificationVariableDeclaration {"," SubselectIdentificationVariableDeclaration}*
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.doctrine-project.org
* @since 2.0
* @version $Revision$
*/
class SubselectFromClause extends Node
{
private $_identificationVariableDeclarations = array();
public function __construct(array $identificationVariableDeclarations)
{
$this->_identificationVariableDeclarations = $identificationVariableDeclarations;
}
/* Getters */
public function getSubselectIdentificationVariableDeclarations()
{
return $this->_identificationVariableDeclarations;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkSubselectFromClause($this);
}
}

View File

@ -1,62 +1,62 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* UpdateStatement = UpdateClause [WhereClause]
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.doctrine-project.org
* @since 2.0
* @version $Revision$
*/
class UpdateStatement extends Node
{
private $_updateClause;
private $_whereClause;
public function __construct($updateClause)
{
$this->_updateClause = $updateClause;
}
public function setWhereClause($whereClause)
{
$this->_whereClause = $whereClause;
}
public function getUpdateClause()
{
return $this->_updateClause;
}
public function getWhereClause()
{
return $this->_whereClause;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkUpdateStatement($this);
}
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* UpdateStatement = UpdateClause [WhereClause]
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.doctrine-project.org
* @since 2.0
* @version $Revision$
*/
class UpdateStatement extends Node
{
private $_updateClause;
private $_whereClause;
public function __construct($updateClause)
{
$this->_updateClause = $updateClause;
}
public function setWhereClause($whereClause)
{
$this->_whereClause = $whereClause;
}
public function getUpdateClause()
{
return $this->_updateClause;
}
public function getWhereClause()
{
return $this->_whereClause;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkUpdateStatement($this);
}
}

View File

@ -1,146 +1,146 @@
<?php
/*
* $Id: Cache.php 3938 2008-03-06 19:36:50Z romanb $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query;
/**
* Doctrine\ORM\Query\CacheHandler
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.com
* @since 2.0
* @version $Revision: 1393 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*
* @todo Re-document this class
*/
abstract class CacheHandler
{
/**
* Static factory method. Receives a Doctrine_ORM_Query object and generates
* the object after processing queryComponents. Table aliases are retrieved
* directly from Doctrine_ORM_Query_Parser.
*
* @param mixed $result Data to be stored.
* @param Doctrine_ORM_Query_ParserResult $parserResult Parser results that enables to have important data retrieved.
*/
public static function fromResultSet($result, $parserResult)
{
$queryComponents = array();
foreach ($parserResult->getQueryComponents() as $alias => $components) {
if ( ! isset($components['parent'])) {
$queryComponents[$alias][] = $components['mapper']->getComponentName();
//$queryComponents[$alias][] = $components['mapper']->getComponentName();
} else {
$queryComponents[$alias][] = $components['parent'] . '.' . $components['relation']->getAlias();
}
if (isset($components['agg'])) {
$queryComponents[$alias][] = $components['agg'];
}
if (isset($components['map'])) {
$queryComponents[$alias][] = $components['map'];
}
}
return new QueryResult(
$result,
$queryComponents,
$parserResult->getTableAliasMap(),
$parserResult->getEnumParams()
);
}
/**
* Static factory method. Receives a Doctrine_ORM_Query object and a cached data.
* It handles the cache and generates the object after processing queryComponents.
* Table aliases are retrieved from cache.
*
* @param Doctrine_ORM_Query $query Doctrine_ORM_Query_Object related to this cache item.
* @param mixed $cached Cached data.
*/
public static function fromCachedResult($query, $cached = false)
{
$cached = unserialize($cached);
return new QueryResult(
$cached[0],
self::_getQueryComponents($cached[1]),
$cached[2],
$cached[3]
);
}
/**
* Static factory method. Receives a Doctrine_ORM_Query object and a cached data.
* It handles the cache and generates the object after processing queryComponents.
* Table aliases are retrieved from cache.
*
* @param Doctrine_ORM_Query $query Doctrine_ORM_Query_Object related to this cache item.
* @param mixed $cached Cached data.
*/
public static function fromCachedQuery($query, $cached = false)
{
$cached = unserialize($cached);
return new ParserResult(
$cached[0],
self::_getQueryComponents($cached[1]),
$cached[2],
$cached[3]
);
}
/**
* @nodoc
*/
protected static function _getQueryComponents($query, $cachedQueryComponents)
{
$queryComponents = array();
foreach ($cachedQueryComponents as $alias => $components) {
$e = explode('.', $components[0]);
if (count($e) === 1) {
$queryComponents[$alias]['mapper'] = $query->getConnection()->getMapper($e[0]);
$queryComponents[$alias]['table'] = $queryComponents[$alias]['mapper']->getTable();
} else {
$queryComponents[$alias]['parent'] = $e[0];
$queryComponents[$alias]['relation'] = $queryComponents[$e[0]]['table']->getAssociation($e[1]);
$queryComponents[$alias]['mapper'] = $query->getConnection()->getMapper($queryComponents[$alias]['relation']->getTargetEntityName());
$queryComponents[$alias]['table'] = $queryComponents[$alias]['mapper']->getTable();
}
if (isset($v[1])) {
$queryComponents[$alias]['agg'] = $components[1];
}
if (isset($v[2])) {
$queryComponents[$alias]['map'] = $components[2];
}
}
return $queryComponents;
}
<?php
/*
* $Id: Cache.php 3938 2008-03-06 19:36:50Z romanb $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query;
/**
* Doctrine\ORM\Query\CacheHandler
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.com
* @since 2.0
* @version $Revision: 1393 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*
* @todo Re-document this class
*/
abstract class CacheHandler
{
/**
* Static factory method. Receives a Doctrine_ORM_Query object and generates
* the object after processing queryComponents. Table aliases are retrieved
* directly from Doctrine_ORM_Query_Parser.
*
* @param mixed $result Data to be stored.
* @param Doctrine_ORM_Query_ParserResult $parserResult Parser results that enables to have important data retrieved.
*/
public static function fromResultSet($result, $parserResult)
{
$queryComponents = array();
foreach ($parserResult->getQueryComponents() as $alias => $components) {
if ( ! isset($components['parent'])) {
$queryComponents[$alias][] = $components['mapper']->getComponentName();
//$queryComponents[$alias][] = $components['mapper']->getComponentName();
} else {
$queryComponents[$alias][] = $components['parent'] . '.' . $components['relation']->getAlias();
}
if (isset($components['agg'])) {
$queryComponents[$alias][] = $components['agg'];
}
if (isset($components['map'])) {
$queryComponents[$alias][] = $components['map'];
}
}
return new QueryResult(
$result,
$queryComponents,
$parserResult->getTableAliasMap(),
$parserResult->getEnumParams()
);
}
/**
* Static factory method. Receives a Doctrine_ORM_Query object and a cached data.
* It handles the cache and generates the object after processing queryComponents.
* Table aliases are retrieved from cache.
*
* @param Doctrine_ORM_Query $query Doctrine_ORM_Query_Object related to this cache item.
* @param mixed $cached Cached data.
*/
public static function fromCachedResult($query, $cached = false)
{
$cached = unserialize($cached);
return new QueryResult(
$cached[0],
self::_getQueryComponents($cached[1]),
$cached[2],
$cached[3]
);
}
/**
* Static factory method. Receives a Doctrine_ORM_Query object and a cached data.
* It handles the cache and generates the object after processing queryComponents.
* Table aliases are retrieved from cache.
*
* @param Doctrine_ORM_Query $query Doctrine_ORM_Query_Object related to this cache item.
* @param mixed $cached Cached data.
*/
public static function fromCachedQuery($query, $cached = false)
{
$cached = unserialize($cached);
return new ParserResult(
$cached[0],
self::_getQueryComponents($cached[1]),
$cached[2],
$cached[3]
);
}
/**
* @nodoc
*/
protected static function _getQueryComponents($query, $cachedQueryComponents)
{
$queryComponents = array();
foreach ($cachedQueryComponents as $alias => $components) {
$e = explode('.', $components[0]);
if (count($e) === 1) {
$queryComponents[$alias]['mapper'] = $query->getConnection()->getMapper($e[0]);
$queryComponents[$alias]['table'] = $queryComponents[$alias]['mapper']->getTable();
} else {
$queryComponents[$alias]['parent'] = $e[0];
$queryComponents[$alias]['relation'] = $queryComponents[$e[0]]['table']->getAssociation($e[1]);
$queryComponents[$alias]['mapper'] = $query->getConnection()->getMapper($queryComponents[$alias]['relation']->getTargetEntityName());
$queryComponents[$alias]['table'] = $queryComponents[$alias]['mapper']->getTable();
}
if (isset($v[1])) {
$queryComponents[$alias]['agg'] = $components[1];
}
if (isset($v[2])) {
$queryComponents[$alias]['map'] = $components[2];
}
}
return $queryComponents;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,341 +1,341 @@
<?php
/**
* Addendum PHP Reflection Annotations
* http://code.google.com/p/addendum/
*
* Copyright (C) 2006 Jan "johno Suchal <johno@jsmf.net>
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**/
require_once(dirname(__FILE__).'/annotations/annotation_parser.php');
class Annotation {
public $value;
public final function __construct($data, $target) {
$reflection = new ReflectionClass($this);
foreach($data as $key => $value) {
if($reflection->hasProperty($key)) {
$this->$key = $value;
} else {
$class = $reflection->getName();
trigger_error("Property '$key' not defined for annotation '$class'");
}
}
$this->checkTargetConstraints($target);
$this->checkConstraints($target);
}
private function checkTargetConstraints($target) {
$reflection = new ReflectionAnnotatedClass($this);
if($reflection->hasAnnotation('Target')) {
$value = $reflection->getAnnotation('Target')->value;
$values = is_array($value) ? $value : array($value);
foreach($values as $value) {
if($value == 'class' && $target instanceof ReflectionClass) return;
if($value == 'method' && $target instanceof ReflectionMethod) return;
if($value == 'property' && $target instanceof ReflectionProperty) return;
}
trigger_error("Annotation '".get_class($this)."' not allowed on ".$this->createName($target), E_USER_ERROR);
}
}
private function createName($target) {
if($target instanceof ReflectionMethod) {
return $target->getDeclaringClass()->getName().'::'.$target->getName();
} elseif($target instanceof ReflectionProperty) {
return $target->getDeclaringClass()->getName().'::$'.$target->getName();
} else {
return $target->getName();
}
}
protected function checkConstraints($target) {}
}
class Target extends Annotation {}
class AnnotationsBuilder {
private static $cache = array();
public function build($targetReflection) {
$data = $this->parse($targetReflection);
$annotations = array();
foreach($data as $class => $parameters) {
if(!Addendum::ignores($class)) {
foreach($parameters as $params) {
$annotationReflection = new ReflectionClass($class);
$annotations[$class][] = $annotationReflection->newInstance($params, $targetReflection);
}
}
}
return $annotations;
}
private function parse($reflection) {
$key = $this->createName($reflection);
if(!isset(self::$cache[$key])) {
$parser = new AnnotationsMatcher;
$parser->matches($this->getDocComment($reflection), $data);
self::$cache[$key] = $data;
}
return self::$cache[$key];
}
private function createName($target) {
if($target instanceof ReflectionMethod) {
return $target->getDeclaringClass()->getName().'::'.$target->getName();
} elseif($target instanceof ReflectionProperty) {
return $target->getDeclaringClass()->getName().'::$'.$target->getName();
} else {
return $target->getName();
}
}
protected function getDocComment($reflection) {
return Addendum::getDocComment($reflection);
}
public static function clearCache() {
self::$cache = array();
}
}
class ReflectionAnnotatedClass extends ReflectionClass {
private $annotations;
public function __construct($class) {
parent::__construct($class);
$this->annotations = $this->createAnnotationBuilder()->build($this);
}
public function hasAnnotation($annotation) {
return isset($this->annotations[$annotation]);
}
public function getAnnotation($annotation) {
return $this->hasAnnotation($annotation) ? end($this->annotations[$annotation]) : false;
}
public function getAnnotations() {
$result = array();
foreach($this->annotations as $instances) {
$result[] = end($instances);
}
return $result;
}
public function getAllAnnotations($restriction = false) {
$result = array();
foreach($this->annotations as $class => $instances) {
if(!$restriction || $restriction == $class) {
$result = array_merge($result, $instances);
}
}
return $result;
}
public function getConstructor() {
return $this->createReflectionAnnotatedMethod(parent::getConstructor());
}
public function getMethod($name) {
return $this->createReflectionAnnotatedMethod(parent::getMethod($name));
}
public function getMethods($filter = -1) {
$result = array();
foreach(parent::getMethods($filter) as $method) {
$result[] = $this->createReflectionAnnotatedMethod($method);
}
return $result;
}
public function getProperty($name) {
return $this->createReflectionAnnotatedProperty(parent::getProperty($name));
}
public function getProperties($filter = -1) {
$result = array();
foreach(parent::getProperties($filter) as $property) {
$result[] = $this->createReflectionAnnotatedProperty($property);
}
return $result;
}
public function getInterfaces() {
$result = array();
foreach(parent::getInterfaces() as $interface) {
$result[] = $this->createReflectionAnnotatedClass($interface);
}
return $result;
}
public function getParentClass() {
$class = parent::getParentClass();
return $this->createReflectionAnnotatedClass($class);
}
protected function createAnnotationBuilder() {
return new AnnotationsBuilder();
}
private function createReflectionAnnotatedClass($class) {
return ($class !== false) ? new ReflectionAnnotatedClass($class->getName()) : false;
}
private function createReflectionAnnotatedMethod($method) {
return ($method !== null) ? new ReflectionAnnotatedMethod($this->getName(), $method->getName()) : null;
}
private function createReflectionAnnotatedProperty($property) {
return ($property !== null) ? new ReflectionAnnotatedProperty($this->getName(), $property->getName()) : null;
}
}
class ReflectionAnnotatedMethod extends ReflectionMethod {
private $annotations;
public function __construct($class, $name) {
parent::__construct($class, $name);
$this->annotations = $this->createAnnotationBuilder()->build($this);
}
public function hasAnnotation($annotation) {
return isset($this->annotations[$annotation]);
}
public function getAnnotation($annotation) {
return ($this->hasAnnotation($annotation)) ? end($this->annotations[$annotation]) : false;
}
public function getAnnotations() {
$result = array();
foreach($this->annotations as $instances) {
$result[] = end($instances);
}
return $result;
}
public function getAllAnnotations($restriction = false) {
$result = array();
foreach($this->annotations as $class => $instances) {
if(!$restriction || $restriction == $class) {
$result = array_merge($result, $instances);
}
}
return $result;
}
public function getDeclaringClass() {
$class = parent::getDeclaringClass();
return new ReflectionAnnotatedClass($class->getName());
}
protected function createAnnotationBuilder() {
return new AnnotationsBuilder();
}
}
class ReflectionAnnotatedProperty extends ReflectionProperty {
private $annotations;
public function __construct($class, $name) {
parent::__construct($class, $name);
$this->annotations = $this->createAnnotationBuilder()->build($this);
}
public function hasAnnotation($annotation) {
return isset($this->annotations[$annotation]);
}
public function getAnnotation($annotation) {
return ($this->hasAnnotation($annotation)) ? end($this->annotations[$annotation]) : false;
}
public function getAnnotations() {
$result = array();
foreach($this->annotations as $instances) {
$result[] = end($instances);
}
return $result;
}
public function getAllAnnotations($restriction = false) {
$result = array();
foreach($this->annotations as $class => $instances) {
if(!$restriction || $restriction == $class) {
$result = array_merge($result, $instances);
}
}
return $result;
}
public function getDeclaringClass() {
$class = parent::getDeclaringClass();
return new ReflectionAnnotatedClass($class->getName());
}
protected function createAnnotationBuilder() {
return new AnnotationsBuilder();
}
}
class Addendum {
private static $rawMode;
private static $ignore;
public static function getDocComment($reflection) {
if(self::checkRawDocCommentParsingNeeded()) {
$docComment = new DocComment();
return $docComment->get($reflection);
} else {
return $reflection->getDocComment();
}
}
/** Raw mode test */
private static function checkRawDocCommentParsingNeeded() {
if(self::$rawMode === null) {
$reflection = new ReflectionClass('Addendum');
$method = $reflection->getMethod('checkRawDocCommentParsingNeeded');
self::setRawMode($method->getDocComment() === false);
}
return self::$rawMode;
}
public static function setRawMode($enabled = true) {
if($enabled) {
require_once(dirname(__FILE__).'/annotations/doc_comment.php');
}
self::$rawMode = $enabled;
}
public static function resetIgnoredAnnotations() {
self::$ignore = array();
}
public static function ignores($class) {
return isset(self::$ignore[$class]);
}
public static function ignore() {
foreach(func_get_args() as $class) {
self::$ignore[$class] = true;
}
}
}
?>
<?php
/**
* Addendum PHP Reflection Annotations
* http://code.google.com/p/addendum/
*
* Copyright (C) 2006 Jan "johno Suchal <johno@jsmf.net>
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**/
require_once(dirname(__FILE__).'/annotations/annotation_parser.php');
class Annotation {
public $value;
public final function __construct($data, $target) {
$reflection = new ReflectionClass($this);
foreach($data as $key => $value) {
if($reflection->hasProperty($key)) {
$this->$key = $value;
} else {
$class = $reflection->getName();
trigger_error("Property '$key' not defined for annotation '$class'");
}
}
$this->checkTargetConstraints($target);
$this->checkConstraints($target);
}
private function checkTargetConstraints($target) {
$reflection = new ReflectionAnnotatedClass($this);
if($reflection->hasAnnotation('Target')) {
$value = $reflection->getAnnotation('Target')->value;
$values = is_array($value) ? $value : array($value);
foreach($values as $value) {
if($value == 'class' && $target instanceof ReflectionClass) return;
if($value == 'method' && $target instanceof ReflectionMethod) return;
if($value == 'property' && $target instanceof ReflectionProperty) return;
}
trigger_error("Annotation '".get_class($this)."' not allowed on ".$this->createName($target), E_USER_ERROR);
}
}
private function createName($target) {
if($target instanceof ReflectionMethod) {
return $target->getDeclaringClass()->getName().'::'.$target->getName();
} elseif($target instanceof ReflectionProperty) {
return $target->getDeclaringClass()->getName().'::$'.$target->getName();
} else {
return $target->getName();
}
}
protected function checkConstraints($target) {}
}
class Target extends Annotation {}
class AnnotationsBuilder {
private static $cache = array();
public function build($targetReflection) {
$data = $this->parse($targetReflection);
$annotations = array();
foreach($data as $class => $parameters) {
if(!Addendum::ignores($class)) {
foreach($parameters as $params) {
$annotationReflection = new ReflectionClass($class);
$annotations[$class][] = $annotationReflection->newInstance($params, $targetReflection);
}
}
}
return $annotations;
}
private function parse($reflection) {
$key = $this->createName($reflection);
if(!isset(self::$cache[$key])) {
$parser = new AnnotationsMatcher;
$parser->matches($this->getDocComment($reflection), $data);
self::$cache[$key] = $data;
}
return self::$cache[$key];
}
private function createName($target) {
if($target instanceof ReflectionMethod) {
return $target->getDeclaringClass()->getName().'::'.$target->getName();
} elseif($target instanceof ReflectionProperty) {
return $target->getDeclaringClass()->getName().'::$'.$target->getName();
} else {
return $target->getName();
}
}
protected function getDocComment($reflection) {
return Addendum::getDocComment($reflection);
}
public static function clearCache() {
self::$cache = array();
}
}
class ReflectionAnnotatedClass extends ReflectionClass {
private $annotations;
public function __construct($class) {
parent::__construct($class);
$this->annotations = $this->createAnnotationBuilder()->build($this);
}
public function hasAnnotation($annotation) {
return isset($this->annotations[$annotation]);
}
public function getAnnotation($annotation) {
return $this->hasAnnotation($annotation) ? end($this->annotations[$annotation]) : false;
}
public function getAnnotations() {
$result = array();
foreach($this->annotations as $instances) {
$result[] = end($instances);
}
return $result;
}
public function getAllAnnotations($restriction = false) {
$result = array();
foreach($this->annotations as $class => $instances) {
if(!$restriction || $restriction == $class) {
$result = array_merge($result, $instances);
}
}
return $result;
}
public function getConstructor() {
return $this->createReflectionAnnotatedMethod(parent::getConstructor());
}
public function getMethod($name) {
return $this->createReflectionAnnotatedMethod(parent::getMethod($name));
}
public function getMethods($filter = -1) {
$result = array();
foreach(parent::getMethods($filter) as $method) {
$result[] = $this->createReflectionAnnotatedMethod($method);
}
return $result;
}
public function getProperty($name) {
return $this->createReflectionAnnotatedProperty(parent::getProperty($name));
}
public function getProperties($filter = -1) {
$result = array();
foreach(parent::getProperties($filter) as $property) {
$result[] = $this->createReflectionAnnotatedProperty($property);
}
return $result;
}
public function getInterfaces() {
$result = array();
foreach(parent::getInterfaces() as $interface) {
$result[] = $this->createReflectionAnnotatedClass($interface);
}
return $result;
}
public function getParentClass() {
$class = parent::getParentClass();
return $this->createReflectionAnnotatedClass($class);
}
protected function createAnnotationBuilder() {
return new AnnotationsBuilder();
}
private function createReflectionAnnotatedClass($class) {
return ($class !== false) ? new ReflectionAnnotatedClass($class->getName()) : false;
}
private function createReflectionAnnotatedMethod($method) {
return ($method !== null) ? new ReflectionAnnotatedMethod($this->getName(), $method->getName()) : null;
}
private function createReflectionAnnotatedProperty($property) {
return ($property !== null) ? new ReflectionAnnotatedProperty($this->getName(), $property->getName()) : null;
}
}
class ReflectionAnnotatedMethod extends ReflectionMethod {
private $annotations;
public function __construct($class, $name) {
parent::__construct($class, $name);
$this->annotations = $this->createAnnotationBuilder()->build($this);
}
public function hasAnnotation($annotation) {
return isset($this->annotations[$annotation]);
}
public function getAnnotation($annotation) {
return ($this->hasAnnotation($annotation)) ? end($this->annotations[$annotation]) : false;
}
public function getAnnotations() {
$result = array();
foreach($this->annotations as $instances) {
$result[] = end($instances);
}
return $result;
}
public function getAllAnnotations($restriction = false) {
$result = array();
foreach($this->annotations as $class => $instances) {
if(!$restriction || $restriction == $class) {
$result = array_merge($result, $instances);
}
}
return $result;
}
public function getDeclaringClass() {
$class = parent::getDeclaringClass();
return new ReflectionAnnotatedClass($class->getName());
}
protected function createAnnotationBuilder() {
return new AnnotationsBuilder();
}
}
class ReflectionAnnotatedProperty extends ReflectionProperty {
private $annotations;
public function __construct($class, $name) {
parent::__construct($class, $name);
$this->annotations = $this->createAnnotationBuilder()->build($this);
}
public function hasAnnotation($annotation) {
return isset($this->annotations[$annotation]);
}
public function getAnnotation($annotation) {
return ($this->hasAnnotation($annotation)) ? end($this->annotations[$annotation]) : false;
}
public function getAnnotations() {
$result = array();
foreach($this->annotations as $instances) {
$result[] = end($instances);
}
return $result;
}
public function getAllAnnotations($restriction = false) {
$result = array();
foreach($this->annotations as $class => $instances) {
if(!$restriction || $restriction == $class) {
$result = array_merge($result, $instances);
}
}
return $result;
}
public function getDeclaringClass() {
$class = parent::getDeclaringClass();
return new ReflectionAnnotatedClass($class->getName());
}
protected function createAnnotationBuilder() {
return new AnnotationsBuilder();
}
}
class Addendum {
private static $rawMode;
private static $ignore;
public static function getDocComment($reflection) {
if(self::checkRawDocCommentParsingNeeded()) {
$docComment = new DocComment();
return $docComment->get($reflection);
} else {
return $reflection->getDocComment();
}
}
/** Raw mode test */
private static function checkRawDocCommentParsingNeeded() {
if(self::$rawMode === null) {
$reflection = new ReflectionClass('Addendum');
$method = $reflection->getMethod('checkRawDocCommentParsingNeeded');
self::setRawMode($method->getDocComment() === false);
}
return self::$rawMode;
}
public static function setRawMode($enabled = true) {
if($enabled) {
require_once(dirname(__FILE__).'/annotations/doc_comment.php');
}
self::$rawMode = $enabled;
}
public static function resetIgnoredAnnotations() {
self::$ignore = array();
}
public static function ignores($class) {
return isset(self::$ignore[$class]);
}
public static function ignore() {
foreach(func_get_args() as $class) {
self::$ignore[$class] = true;
}
}
}
?>

View File

@ -1,335 +1,335 @@
<?php
/**
* Addendum PHP Reflection Annotations
* http://code.google.com/p/addendum/
*
* Copyright (C) 2006 Jan "johno Suchal <johno@jsmf.net>
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**/
class CompositeMatcher {
protected $matchers = array();
private $wasConstructed = false;
public function add($matcher) {
$this->matchers[] = $matcher;
}
public function matches($string, &$value) {
if(!$this->wasConstructed) {
$this->build();
$this->wasConstructed = true;
}
return $this->match($string, $value);
}
protected function build() {}
}
class ParallelMatcher extends CompositeMatcher {
protected function match($string, &$value) {
$maxLength = false;
$result = null;
foreach($this->matchers as $matcher) {
$length = $matcher->matches($string, $subvalue);
if($maxLength === false || $length > $maxLength) {
$maxLength = $length;
$result = $subvalue;
}
}
$value = $this->process($result);
return $maxLength;
}
protected function process($value) {
return $value;
}
}
class SerialMatcher extends CompositeMatcher {
protected function match($string, &$value) {
$results = array();
$total_length = 0;
foreach($this->matchers as $matcher) {
if(($length = $matcher->matches($string, $result)) === false) return false;
$total_length += $length;
$results[] = $result;
$string = substr($string, $length);
}
$value = $this->process($results);
return $total_length;
}
protected function process($results) {
return implode('', $results);
}
}
class SimpleSerialMatcher extends SerialMatcher {
private $return_part_index;
public function __construct($return_part_index = 0) {
$this->return_part_index = $return_part_index;
}
public function process($parts) {
return $parts[$this->return_part_index];
}
}
class RegexMatcher {
private $regex;
public function __construct($regex) {
$this->regex = $regex;
}
public function matches($string, &$value) {
if(preg_match("/^{$this->regex}/", $string, $matches)) {
$value = $this->process($matches);
return strlen($matches[0]);
}
$value = false;
return false;
}
protected function process($matches) {
return $matches[0];
}
}
class AnnotationsMatcher {
public function matches($string, &$annotations) {
$annotations = array();
$annotation_matcher = new AnnotationMatcher;
while(true) {
if(preg_match('/\s(?=@)/', $string, $matches, PREG_OFFSET_CAPTURE)) {
$offset = $matches[0][1] + 1;
$string = substr($string, $offset);
} else {
return; // no more annotations
}
if(($length = $annotation_matcher->matches($string, $data)) !== false) {
$string = substr($string, $length);
list($name, $params) = $data;
$annotations[$name][] = $params;
}
}
}
}
class AnnotationMatcher extends SerialMatcher {
protected function build() {
$this->add(new RegexMatcher('@'));
$this->add(new RegexMatcher('[A-Z][a-zA-Z0-9_]+'));
$this->add(new AnnotationParametersMatcher);
}
protected function process($results) {
return array($results[1], $results[2]);
}
}
class ConstantMatcher extends RegexMatcher {
private $constant;
public function __construct($regex, $constant) {
parent::__construct($regex);
$this->constant = $constant;
}
protected function process($matches) {
return $this->constant;
}
}
class AnnotationParametersMatcher extends ParallelMatcher {
protected function build() {
$this->add(new ConstantMatcher('', array()));
$this->add(new ConstantMatcher('\(\)', array()));
$params_matcher = new SimpleSerialMatcher(1);
$params_matcher->add(new RegexMatcher('\(\s*'));
$params_matcher->add(new AnnotationValuesMatcher);
$params_matcher->add(new RegexMatcher('\s*\)'));
$this->add($params_matcher);
}
}
class AnnotationValuesMatcher extends ParallelMatcher {
protected function build() {
$this->add(new AnnotationTopValueMatcher);
$this->add(new AnnotationHashMatcher);
}
}
class AnnotationTopValueMatcher extends AnnotationValueMatcher {
protected function process($value) {
return array('value' => $value);
}
}
class AnnotationValueMatcher extends ParallelMatcher {
protected function build() {
$this->add(new ConstantMatcher('true', true));
$this->add(new ConstantMatcher('false', false));
$this->add(new ConstantMatcher('TRUE', true));
$this->add(new ConstantMatcher('FALSE', false));
$this->add(new AnnotationStringMatcher);
$this->add(new AnnotationNumberMatcher);
$this->add(new AnnotationArrayMatcher);
}
}
class AnnotationKeyMatcher extends ParallelMatcher {
protected function build() {
$this->add(new RegexMatcher('[a-zA-Z][a-zA-Z0-9_]*'));
$this->add(new AnnotationStringMatcher);
$this->add(new AnnotationIntegerMatcher);
}
}
class AnnotationPairMatcher extends SerialMatcher {
protected function build() {
$this->add(new AnnotationKeyMatcher);
$this->add(new RegexMatcher('\s*=\s*'));
$this->add(new AnnotationValueMatcher);
}
protected function process($parts) {
return array($parts[0] => $parts[2]);
}
}
class AnnotationHashMatcher extends ParallelMatcher {
protected function build() {
$this->add(new AnnotationPairMatcher);
$this->add(new AnnotationMorePairsMatcher);
}
}
class AnnotationMorePairsMatcher extends SerialMatcher {
protected function build() {
$this->add(new AnnotationPairMatcher);
$this->add(new RegexMatcher('\s*,\s*'));
$this->add(new AnnotationHashMatcher);
}
protected function match($string, &$value) {
$result = parent::match($string, $value);
return $result;
}
public function process($parts) {
return array_merge($parts[0], $parts[2]);
}
}
class AnnotationArrayMatcher extends ParallelMatcher {
protected function build() {
$this->add(new ConstantMatcher('{}', array()));
$values_matcher = new SimpleSerialMatcher(1);
$values_matcher->add(new RegexMatcher('\s*{\s*'));
$values_matcher->add(new AnnotationArrayValuesMatcher);
$values_matcher->add(new RegexMatcher('\s*}\s*'));
$this->add($values_matcher);
}
}
class AnnotationArrayValuesMatcher extends ParallelMatcher {
protected function build() {
$this->add(new AnnotationArrayValueMatcher);
$this->add(new AnnotationMoreValuesMatcher);
}
}
class AnnotationMoreValuesMatcher extends SimpleSerialMatcher {
protected function build() {
$this->add(new AnnotationArrayValueMatcher);
$this->add(new RegexMatcher('\s*,\s*'));
$this->add(new AnnotationArrayValuesMatcher);
}
protected function match($string, &$value) {
$result = parent::match($string, $value);
return $result;
}
public function process($parts) {
return array_merge($parts[0], $parts[2]);
}
}
class AnnotationArrayValueMatcher extends ParallelMatcher {
protected function build() {
$this->add(new AnnotationValueInArrayMatcher);
$this->add(new AnnotationPairMatcher);
}
}
class AnnotationValueInArrayMatcher extends AnnotationValueMatcher {
public function process($value) {
return array($value);
}
}
class AnnotationStringMatcher extends ParallelMatcher {
protected function build() {
$this->add(new AnnotationSingleQuotedStringMatcher);
$this->add(new AnnotationDoubleQuotedStringMatcher);
}
}
class AnnotationNumberMatcher extends RegexMatcher {
public function __construct() {
parent::__construct("-?[0-9]*\.?[0-9]*");
}
protected function process($matches) {
$isFloat = strpos($matches[0], '.') !== false;
return $isFloat ? (float) $matches[0] : (int) $matches[0];
}
}
class AnnotationIntegerMatcher extends RegexMatcher {
public function __construct() {
parent::__construct("-?[0-9]*");
}
protected function process($matches) {
return (int) $matches[0];
}
}
class AnnotationSingleQuotedStringMatcher extends RegexMatcher {
public function __construct() {
parent::__construct("'([^']*)'");
}
protected function process($matches) {
return $matches[1];
}
}
class AnnotationDoubleQuotedStringMatcher extends RegexMatcher {
public function __construct() {
parent::__construct('"([^"]*)"');
}
protected function process($matches) {
return $matches[1];
}
}
?>
<?php
/**
* Addendum PHP Reflection Annotations
* http://code.google.com/p/addendum/
*
* Copyright (C) 2006 Jan "johno Suchal <johno@jsmf.net>
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**/
class CompositeMatcher {
protected $matchers = array();
private $wasConstructed = false;
public function add($matcher) {
$this->matchers[] = $matcher;
}
public function matches($string, &$value) {
if(!$this->wasConstructed) {
$this->build();
$this->wasConstructed = true;
}
return $this->match($string, $value);
}
protected function build() {}
}
class ParallelMatcher extends CompositeMatcher {
protected function match($string, &$value) {
$maxLength = false;
$result = null;
foreach($this->matchers as $matcher) {
$length = $matcher->matches($string, $subvalue);
if($maxLength === false || $length > $maxLength) {
$maxLength = $length;
$result = $subvalue;
}
}
$value = $this->process($result);
return $maxLength;
}
protected function process($value) {
return $value;
}
}
class SerialMatcher extends CompositeMatcher {
protected function match($string, &$value) {
$results = array();
$total_length = 0;
foreach($this->matchers as $matcher) {
if(($length = $matcher->matches($string, $result)) === false) return false;
$total_length += $length;
$results[] = $result;
$string = substr($string, $length);
}
$value = $this->process($results);
return $total_length;
}
protected function process($results) {
return implode('', $results);
}
}
class SimpleSerialMatcher extends SerialMatcher {
private $return_part_index;
public function __construct($return_part_index = 0) {
$this->return_part_index = $return_part_index;
}
public function process($parts) {
return $parts[$this->return_part_index];
}
}
class RegexMatcher {
private $regex;
public function __construct($regex) {
$this->regex = $regex;
}
public function matches($string, &$value) {
if(preg_match("/^{$this->regex}/", $string, $matches)) {
$value = $this->process($matches);
return strlen($matches[0]);
}
$value = false;
return false;
}
protected function process($matches) {
return $matches[0];
}
}
class AnnotationsMatcher {
public function matches($string, &$annotations) {
$annotations = array();
$annotation_matcher = new AnnotationMatcher;
while(true) {
if(preg_match('/\s(?=@)/', $string, $matches, PREG_OFFSET_CAPTURE)) {
$offset = $matches[0][1] + 1;
$string = substr($string, $offset);
} else {
return; // no more annotations
}
if(($length = $annotation_matcher->matches($string, $data)) !== false) {
$string = substr($string, $length);
list($name, $params) = $data;
$annotations[$name][] = $params;
}
}
}
}
class AnnotationMatcher extends SerialMatcher {
protected function build() {
$this->add(new RegexMatcher('@'));
$this->add(new RegexMatcher('[A-Z][a-zA-Z0-9_]+'));
$this->add(new AnnotationParametersMatcher);
}
protected function process($results) {
return array($results[1], $results[2]);
}
}
class ConstantMatcher extends RegexMatcher {
private $constant;
public function __construct($regex, $constant) {
parent::__construct($regex);
$this->constant = $constant;
}
protected function process($matches) {
return $this->constant;
}
}
class AnnotationParametersMatcher extends ParallelMatcher {
protected function build() {
$this->add(new ConstantMatcher('', array()));
$this->add(new ConstantMatcher('\(\)', array()));
$params_matcher = new SimpleSerialMatcher(1);
$params_matcher->add(new RegexMatcher('\(\s*'));
$params_matcher->add(new AnnotationValuesMatcher);
$params_matcher->add(new RegexMatcher('\s*\)'));
$this->add($params_matcher);
}
}
class AnnotationValuesMatcher extends ParallelMatcher {
protected function build() {
$this->add(new AnnotationTopValueMatcher);
$this->add(new AnnotationHashMatcher);
}
}
class AnnotationTopValueMatcher extends AnnotationValueMatcher {
protected function process($value) {
return array('value' => $value);
}
}
class AnnotationValueMatcher extends ParallelMatcher {
protected function build() {
$this->add(new ConstantMatcher('true', true));
$this->add(new ConstantMatcher('false', false));
$this->add(new ConstantMatcher('TRUE', true));
$this->add(new ConstantMatcher('FALSE', false));
$this->add(new AnnotationStringMatcher);
$this->add(new AnnotationNumberMatcher);
$this->add(new AnnotationArrayMatcher);
}
}
class AnnotationKeyMatcher extends ParallelMatcher {
protected function build() {
$this->add(new RegexMatcher('[a-zA-Z][a-zA-Z0-9_]*'));
$this->add(new AnnotationStringMatcher);
$this->add(new AnnotationIntegerMatcher);
}
}
class AnnotationPairMatcher extends SerialMatcher {
protected function build() {
$this->add(new AnnotationKeyMatcher);
$this->add(new RegexMatcher('\s*=\s*'));
$this->add(new AnnotationValueMatcher);
}
protected function process($parts) {
return array($parts[0] => $parts[2]);
}
}
class AnnotationHashMatcher extends ParallelMatcher {
protected function build() {
$this->add(new AnnotationPairMatcher);
$this->add(new AnnotationMorePairsMatcher);
}
}
class AnnotationMorePairsMatcher extends SerialMatcher {
protected function build() {
$this->add(new AnnotationPairMatcher);
$this->add(new RegexMatcher('\s*,\s*'));
$this->add(new AnnotationHashMatcher);
}
protected function match($string, &$value) {
$result = parent::match($string, $value);
return $result;
}
public function process($parts) {
return array_merge($parts[0], $parts[2]);
}
}
class AnnotationArrayMatcher extends ParallelMatcher {
protected function build() {
$this->add(new ConstantMatcher('{}', array()));
$values_matcher = new SimpleSerialMatcher(1);
$values_matcher->add(new RegexMatcher('\s*{\s*'));
$values_matcher->add(new AnnotationArrayValuesMatcher);
$values_matcher->add(new RegexMatcher('\s*}\s*'));
$this->add($values_matcher);
}
}
class AnnotationArrayValuesMatcher extends ParallelMatcher {
protected function build() {
$this->add(new AnnotationArrayValueMatcher);
$this->add(new AnnotationMoreValuesMatcher);
}
}
class AnnotationMoreValuesMatcher extends SimpleSerialMatcher {
protected function build() {
$this->add(new AnnotationArrayValueMatcher);
$this->add(new RegexMatcher('\s*,\s*'));
$this->add(new AnnotationArrayValuesMatcher);
}
protected function match($string, &$value) {
$result = parent::match($string, $value);
return $result;
}
public function process($parts) {
return array_merge($parts[0], $parts[2]);
}
}
class AnnotationArrayValueMatcher extends ParallelMatcher {
protected function build() {
$this->add(new AnnotationValueInArrayMatcher);
$this->add(new AnnotationPairMatcher);
}
}
class AnnotationValueInArrayMatcher extends AnnotationValueMatcher {
public function process($value) {
return array($value);
}
}
class AnnotationStringMatcher extends ParallelMatcher {
protected function build() {
$this->add(new AnnotationSingleQuotedStringMatcher);
$this->add(new AnnotationDoubleQuotedStringMatcher);
}
}
class AnnotationNumberMatcher extends RegexMatcher {
public function __construct() {
parent::__construct("-?[0-9]*\.?[0-9]*");
}
protected function process($matches) {
$isFloat = strpos($matches[0], '.') !== false;
return $isFloat ? (float) $matches[0] : (int) $matches[0];
}
}
class AnnotationIntegerMatcher extends RegexMatcher {
public function __construct() {
parent::__construct("-?[0-9]*");
}
protected function process($matches) {
return (int) $matches[0];
}
}
class AnnotationSingleQuotedStringMatcher extends RegexMatcher {
public function __construct() {
parent::__construct("'([^']*)'");
}
protected function process($matches) {
return $matches[1];
}
}
class AnnotationDoubleQuotedStringMatcher extends RegexMatcher {
public function __construct() {
parent::__construct('"([^"]*)"');
}
protected function process($matches) {
return $matches[1];
}
}
?>

View File

@ -1,130 +1,130 @@
<?php
class DocComment {
private static $classes = array();
private static $methods = array();
private static $fields = array();
private static $parsedFiles = array();
public static function clearCache() {
self::$classes = array();
self::$methods = array();
self::$fields = array();
self::$parsedFiles = array();
}
public function get($reflection) {
if($reflection instanceof ReflectionClass) {
return $this->forClass($reflection);
} elseif($reflection instanceof ReflectionMethod) {
return $this->forMethod($reflection);
} elseif($reflection instanceof ReflectionProperty) {
return $this->forProperty($reflection);
}
}
public function forClass($reflection) {
$this->process($reflection->getFileName());
$name = $reflection->getName();
return isset(self::$classes[$name]) ? self::$classes[$name] : false;
}
public function forMethod($reflection) {
$this->process($reflection->getDeclaringClass()->getFileName());
$class = $reflection->getDeclaringClass()->getName();
$method = $reflection->getName();
return isset(self::$methods[$class][$method]) ? self::$methods[$class][$method] : false;
}
public function forProperty($reflection) {
$this->process($reflection->getDeclaringClass()->getFileName());
$class = $reflection->getDeclaringClass()->getName();
$field = $reflection->getName();
return isset(self::$fields[$class][$field]) ? self::$fields[$class][$field] : false;
}
private function process($file) {
if(!isset(self::$parsedFiles[$file])) {
$this->parse($file);
self::$parsedFiles[$file] = true;
}
}
protected function parse($file) {
$tokens = $this->getTokens($file);
$currentClass = false;
$currentBlock = false;
$max = count($tokens);
$i = 0;
while($i < $max) {
$token = $tokens[$i];
if(is_array($token)) {
list($code, $value) = $token;
switch($code) {
case T_DOC_COMMENT:
$comment = $value;
break;
case T_CLASS:
$class = $this->getString($tokens, $i, $max);
if($comment !== false) {
self::$classes[$class] = $comment;
$comment = false;
}
break;
case T_VARIABLE:
if($comment !== false) {
$field = substr($token[1], 1);
self::$fields[$class][$field] = $comment;
$comment = false;
}
break;
case T_FUNCTION:
if($comment !== false) {
$function = $this->getString($tokens, $i, $max);
self::$methods[$class][$function] = $comment;
$comment = false;
}
break;
// ignore
case T_WHITESPACE:
case T_PUBLIC:
case T_PROTECTED:
case T_PRIVATE:
case T_ABSTRACT:
case T_FINAL:
case T_VAR:
break;
default:
$comment = false;
break;
}
} else {
$comment = false;
}
$i++;
}
}
private function getString($tokens, &$i, $max) {
do {
$token = $tokens[$i];
$i++;
if(is_array($token)) {
if($token[0] == T_STRING) {
return $token[1];
}
}
} while($i <= $max);
return false;
}
private function getTokens($file) {
return token_get_all(file_get_contents($file));
}
}
<?php
class DocComment {
private static $classes = array();
private static $methods = array();
private static $fields = array();
private static $parsedFiles = array();
public static function clearCache() {
self::$classes = array();
self::$methods = array();
self::$fields = array();
self::$parsedFiles = array();
}
public function get($reflection) {
if($reflection instanceof ReflectionClass) {
return $this->forClass($reflection);
} elseif($reflection instanceof ReflectionMethod) {
return $this->forMethod($reflection);
} elseif($reflection instanceof ReflectionProperty) {
return $this->forProperty($reflection);
}
}
public function forClass($reflection) {
$this->process($reflection->getFileName());
$name = $reflection->getName();
return isset(self::$classes[$name]) ? self::$classes[$name] : false;
}
public function forMethod($reflection) {
$this->process($reflection->getDeclaringClass()->getFileName());
$class = $reflection->getDeclaringClass()->getName();
$method = $reflection->getName();
return isset(self::$methods[$class][$method]) ? self::$methods[$class][$method] : false;
}
public function forProperty($reflection) {
$this->process($reflection->getDeclaringClass()->getFileName());
$class = $reflection->getDeclaringClass()->getName();
$field = $reflection->getName();
return isset(self::$fields[$class][$field]) ? self::$fields[$class][$field] : false;
}
private function process($file) {
if(!isset(self::$parsedFiles[$file])) {
$this->parse($file);
self::$parsedFiles[$file] = true;
}
}
protected function parse($file) {
$tokens = $this->getTokens($file);
$currentClass = false;
$currentBlock = false;
$max = count($tokens);
$i = 0;
while($i < $max) {
$token = $tokens[$i];
if(is_array($token)) {
list($code, $value) = $token;
switch($code) {
case T_DOC_COMMENT:
$comment = $value;
break;
case T_CLASS:
$class = $this->getString($tokens, $i, $max);
if($comment !== false) {
self::$classes[$class] = $comment;
$comment = false;
}
break;
case T_VARIABLE:
if($comment !== false) {
$field = substr($token[1], 1);
self::$fields[$class][$field] = $comment;
$comment = false;
}
break;
case T_FUNCTION:
if($comment !== false) {
$function = $this->getString($tokens, $i, $max);
self::$methods[$class][$function] = $comment;
$comment = false;
}
break;
// ignore
case T_WHITESPACE:
case T_PUBLIC:
case T_PROTECTED:
case T_PRIVATE:
case T_ABSTRACT:
case T_FINAL:
case T_VAR:
break;
default:
$comment = false;
break;
}
} else {
$comment = false;
}
$i++;
}
}
private function getString($tokens, &$i, $max) {
do {
$token = $tokens[$i];
$i++;
if(is_array($token)) {
if($token[0] == T_STRING) {
return $token[1];
}
}
} while($i <= $max);
return false;
}
private function getTokens($file) {
return token_get_all(file_get_contents($file));
}
}
?>

View File

@ -1,233 +1,233 @@
<?php
require_once('simpletest/autorun.php');
require_once('simpletest/mock_objects.php');
require_once(dirname(__FILE__).'/../../annotations.php');
interface DummyInterface {}
class ParentExample {}
/** @FirstAnnotation @SecondAnnotation */
class Example extends ParentExample implements DummyInterface {
/** @SecondAnnotation */
private $exampleProperty;
public $publicOne;
public function __construct() {}
/** @FirstAnnotation */
public function exampleMethod() {
}
private function justPrivate() {}
}
/** @FirstAnnotation(1) @FirstAnnotation(2) @SecondAnnotation(3) */
class MultiExample {
/** @FirstAnnotation(1) @FirstAnnotation(2) @SecondAnnotation(3) */
public $property;
/** @FirstAnnotation(1) @FirstAnnotation(2) @SecondAnnotation(3) */
public function aMethod() {}
}
class FirstAnnotation extends Annotation {}
class SecondAnnotation extends Annotation {}
class TestOfAnnotations extends UnitTestCase {
public function testReflectionAnnotatedClass() {
$reflection = new ReflectionAnnotatedClass('Example');
$this->assertTrue($reflection->hasAnnotation('FirstAnnotation'));
$this->assertTrue($reflection->hasAnnotation('SecondAnnotation'));
$this->assertFalse($reflection->hasAnnotation('NonExistentAnnotation'));
$this->assertIsA($reflection->getAnnotation('FirstAnnotation'), 'FirstAnnotation');
$this->assertIsA($reflection->getAnnotation('SecondAnnotation'), 'SecondAnnotation');
$annotations = $reflection->getAnnotations();
$this->assertEqual(count($annotations), 2);
$this->assertIsA($annotations[0], 'FirstAnnotation');
$this->assertIsA($annotations[1], 'SecondAnnotation');
$this->assertFalse($reflection->getAnnotation('NonExistentAnnotation'));
$this->assertIsA($reflection->getConstructor(), 'ReflectionAnnotatedMethod');
$this->assertIsA($reflection->getMethod('exampleMethod'), 'ReflectionAnnotatedMethod');
foreach($reflection->getMethods() as $method) {
$this->assertIsA($method, 'ReflectionAnnotatedMethod');
}
$this->assertIsA($reflection->getProperty('exampleProperty'), 'ReflectionAnnotatedProperty');
foreach($reflection->getProperties() as $property) {
$this->assertIsA($property, 'ReflectionAnnotatedProperty');
}
foreach($reflection->getInterfaces() as $interface) {
$this->assertIsA($interface, 'ReflectionAnnotatedClass');
}
$this->assertIsA($reflection->getParentClass(), 'ReflectionAnnotatedClass');
}
public function testReflectionAnnotatedMethod() {
$reflection = new ReflectionAnnotatedMethod('Example', 'exampleMethod');
$this->assertTrue($reflection->hasAnnotation('FirstAnnotation'));
$this->assertFalse($reflection->hasAnnotation('NonExistentAnnotation'));
$this->assertIsA($reflection->getAnnotation('FirstAnnotation'), 'FirstAnnotation');
$this->assertFalse($reflection->getAnnotation('NonExistentAnnotation'));
$annotations = $reflection->getAnnotations();
$this->assertEqual(count($annotations), 1);
$this->assertIsA($annotations[0], 'FirstAnnotation');
$this->assertIsA($reflection->getDeclaringClass(), 'ReflectionAnnotatedClass');
}
public function testReflectionAnnotatedProperty() {
$reflection = new ReflectionAnnotatedProperty('Example', 'exampleProperty');
$this->assertTrue($reflection->hasAnnotation('SecondAnnotation'));
$this->assertFalse($reflection->hasAnnotation('FirstAnnotation'));
$this->assertIsA($reflection->getAnnotation('SecondAnnotation'), 'SecondAnnotation');
$this->assertFalse($reflection->getAnnotation('NonExistentAnnotation'));
$annotations = $reflection->getAnnotations();
$this->assertEqual(count($annotations), 1);
$this->assertIsA($annotations[0], 'SecondAnnotation');
$this->assertIsA($reflection->getDeclaringClass(), 'ReflectionAnnotatedClass');
}
public function testReflectionClassCanFilterMethodsByAccess() {
$reflection = new ReflectionAnnotatedClass('Example');
$privateMethods = $reflection->getMethods(ReflectionMethod::IS_PRIVATE);
$this->assertEqual(count($privateMethods), 1);
$this->assertEqual($privateMethods[0]->getName(), 'justPrivate');
}
public function testReflectionClassCanFilterPropertiesByAccess() {
$reflection = new ReflectionAnnotatedClass('Example');
$privateProperties = $reflection->getProperties(ReflectionProperty::IS_PUBLIC);
$this->assertEqual(count($privateProperties), 1);
$this->assertEqual($privateProperties[0]->getName(), 'publicOne');
}
public function testReflectionClassShouldReturnAllMethodsWithNoFilter() {
$reflection = new ReflectionAnnotatedClass('Example');
$methods = $reflection->getMethods();
$this->assertEqual(count($methods), 3);
}
public function testReflectionClassShouldReturnAllPropertiesWithNoFilter() {
$reflection = new ReflectionAnnotatedClass('Example');
$properties = $reflection->getProperties();
$this->assertEqual(count($properties), 2);
}
public function testMultipleAnnotationsOnClass() {
$reflection = new ReflectionAnnotatedClass('MultiExample');
$annotations = $reflection->getAllAnnotations();
$this->assertEqual(count($annotations), 3);
$this->assertEqual($annotations[0]->value, 1);
$this->assertEqual($annotations[1]->value, 2);
$this->assertEqual($annotations[2]->value, 3);
$this->assertIsA($annotations[0], 'FirstAnnotation');
$this->assertIsA($annotations[1], 'FirstAnnotation');
$this->assertIsA($annotations[2], 'SecondAnnotation');
}
public function testMultipleAnnotationsOnClassWithRestriction() {
$reflection = new ReflectionAnnotatedClass('MultiExample');
$annotations = $reflection->getAllAnnotations('FirstAnnotation');
$this->assertEqual(count($annotations), 2);
$this->assertEqual($annotations[0]->value, 1);
$this->assertEqual($annotations[1]->value, 2);
$this->assertIsA($annotations[0], 'FirstAnnotation');
$this->assertIsA($annotations[1], 'FirstAnnotation');
}
public function testMultipleAnnotationsOnProperty() {
$reflection = new ReflectionAnnotatedClass('MultiExample');
$reflection = $reflection->getProperty('property');
$annotations = $reflection->getAllAnnotations();
$this->assertEqual(count($annotations), 3);
$this->assertEqual($annotations[0]->value, 1);
$this->assertEqual($annotations[1]->value, 2);
$this->assertEqual($annotations[2]->value, 3);
$this->assertIsA($annotations[0], 'FirstAnnotation');
$this->assertIsA($annotations[1], 'FirstAnnotation');
$this->assertIsA($annotations[2], 'SecondAnnotation');
}
public function testMultipleAnnotationsOnPropertyWithRestriction() {
$reflection = new ReflectionAnnotatedClass('MultiExample');
$reflection = $reflection->getProperty('property');
$annotations = $reflection->getAllAnnotations('FirstAnnotation');
$this->assertEqual(count($annotations), 2);
$this->assertEqual($annotations[0]->value, 1);
$this->assertEqual($annotations[1]->value, 2);
$this->assertIsA($annotations[0], 'FirstAnnotation');
$this->assertIsA($annotations[1], 'FirstAnnotation');
}
public function testMultipleAnnotationsOnMethod() {
$reflection = new ReflectionAnnotatedClass('MultiExample');
$reflection = $reflection->getMethod('aMethod');
$annotations = $reflection->getAllAnnotations();
$this->assertEqual(count($annotations), 3);
$this->assertEqual($annotations[0]->value, 1);
$this->assertEqual($annotations[1]->value, 2);
$this->assertEqual($annotations[2]->value, 3);
$this->assertIsA($annotations[0], 'FirstAnnotation');
$this->assertIsA($annotations[1], 'FirstAnnotation');
$this->assertIsA($annotations[2], 'SecondAnnotation');
}
public function testMultipleAnnotationsOnMethodWithRestriction() {
$reflection = new ReflectionAnnotatedClass('MultiExample');
$reflection = $reflection->getMethod('aMethod');
$annotations = $reflection->getAllAnnotations('FirstAnnotation');
$this->assertEqual(count($annotations), 2);
$this->assertEqual($annotations[0]->value, 1);
$this->assertEqual($annotations[1]->value, 2);
$this->assertIsA($annotations[0], 'FirstAnnotation');
$this->assertIsA($annotations[1], 'FirstAnnotation');
}
}
Mock::generatePartial('AnnotationsBuilder', 'MockedAnnotationsBuilder', array('getDocComment'));
class TestOfPerformanceFeatures extends UnitTestCase {
public function setUp() {
AnnotationsBuilder::clearCache();
}
public function tearDown() {
AnnotationsBuilder::clearCache();
}
public function testBuilderShouldCacheResults() {
$builder = new MockedAnnotationsBuilder;
$reflection = new ReflectionClass('Example');
$builder->build($reflection);
$builder->build($reflection);
$builder->expectOnce('getDocComment');
}
}
class TestOfSupportingFeatures extends UnitTestCase {
public function setUp() {
Addendum::resetIgnoredAnnotations();
}
public function tearDown() {
Addendum::resetIgnoredAnnotations();
}
public function testIgnoredAnnotationsAreNotUsed() {
Addendum::ignore('FirstAnnotation', 'SecondAnnotation');
$reflection = new ReflectionAnnotatedClass('Example');
$this->assertFalse($reflection->hasAnnotation('FirstAnnotation'));
$this->assertFalse($reflection->hasAnnotation('SecondAnnotation'));
}
}
?>
<?php
require_once('simpletest/autorun.php');
require_once('simpletest/mock_objects.php');
require_once(dirname(__FILE__).'/../../annotations.php');
interface DummyInterface {}
class ParentExample {}
/** @FirstAnnotation @SecondAnnotation */
class Example extends ParentExample implements DummyInterface {
/** @SecondAnnotation */
private $exampleProperty;
public $publicOne;
public function __construct() {}
/** @FirstAnnotation */
public function exampleMethod() {
}
private function justPrivate() {}
}
/** @FirstAnnotation(1) @FirstAnnotation(2) @SecondAnnotation(3) */
class MultiExample {
/** @FirstAnnotation(1) @FirstAnnotation(2) @SecondAnnotation(3) */
public $property;
/** @FirstAnnotation(1) @FirstAnnotation(2) @SecondAnnotation(3) */
public function aMethod() {}
}
class FirstAnnotation extends Annotation {}
class SecondAnnotation extends Annotation {}
class TestOfAnnotations extends UnitTestCase {
public function testReflectionAnnotatedClass() {
$reflection = new ReflectionAnnotatedClass('Example');
$this->assertTrue($reflection->hasAnnotation('FirstAnnotation'));
$this->assertTrue($reflection->hasAnnotation('SecondAnnotation'));
$this->assertFalse($reflection->hasAnnotation('NonExistentAnnotation'));
$this->assertIsA($reflection->getAnnotation('FirstAnnotation'), 'FirstAnnotation');
$this->assertIsA($reflection->getAnnotation('SecondAnnotation'), 'SecondAnnotation');
$annotations = $reflection->getAnnotations();
$this->assertEqual(count($annotations), 2);
$this->assertIsA($annotations[0], 'FirstAnnotation');
$this->assertIsA($annotations[1], 'SecondAnnotation');
$this->assertFalse($reflection->getAnnotation('NonExistentAnnotation'));
$this->assertIsA($reflection->getConstructor(), 'ReflectionAnnotatedMethod');
$this->assertIsA($reflection->getMethod('exampleMethod'), 'ReflectionAnnotatedMethod');
foreach($reflection->getMethods() as $method) {
$this->assertIsA($method, 'ReflectionAnnotatedMethod');
}
$this->assertIsA($reflection->getProperty('exampleProperty'), 'ReflectionAnnotatedProperty');
foreach($reflection->getProperties() as $property) {
$this->assertIsA($property, 'ReflectionAnnotatedProperty');
}
foreach($reflection->getInterfaces() as $interface) {
$this->assertIsA($interface, 'ReflectionAnnotatedClass');
}
$this->assertIsA($reflection->getParentClass(), 'ReflectionAnnotatedClass');
}
public function testReflectionAnnotatedMethod() {
$reflection = new ReflectionAnnotatedMethod('Example', 'exampleMethod');
$this->assertTrue($reflection->hasAnnotation('FirstAnnotation'));
$this->assertFalse($reflection->hasAnnotation('NonExistentAnnotation'));
$this->assertIsA($reflection->getAnnotation('FirstAnnotation'), 'FirstAnnotation');
$this->assertFalse($reflection->getAnnotation('NonExistentAnnotation'));
$annotations = $reflection->getAnnotations();
$this->assertEqual(count($annotations), 1);
$this->assertIsA($annotations[0], 'FirstAnnotation');
$this->assertIsA($reflection->getDeclaringClass(), 'ReflectionAnnotatedClass');
}
public function testReflectionAnnotatedProperty() {
$reflection = new ReflectionAnnotatedProperty('Example', 'exampleProperty');
$this->assertTrue($reflection->hasAnnotation('SecondAnnotation'));
$this->assertFalse($reflection->hasAnnotation('FirstAnnotation'));
$this->assertIsA($reflection->getAnnotation('SecondAnnotation'), 'SecondAnnotation');
$this->assertFalse($reflection->getAnnotation('NonExistentAnnotation'));
$annotations = $reflection->getAnnotations();
$this->assertEqual(count($annotations), 1);
$this->assertIsA($annotations[0], 'SecondAnnotation');
$this->assertIsA($reflection->getDeclaringClass(), 'ReflectionAnnotatedClass');
}
public function testReflectionClassCanFilterMethodsByAccess() {
$reflection = new ReflectionAnnotatedClass('Example');
$privateMethods = $reflection->getMethods(ReflectionMethod::IS_PRIVATE);
$this->assertEqual(count($privateMethods), 1);
$this->assertEqual($privateMethods[0]->getName(), 'justPrivate');
}
public function testReflectionClassCanFilterPropertiesByAccess() {
$reflection = new ReflectionAnnotatedClass('Example');
$privateProperties = $reflection->getProperties(ReflectionProperty::IS_PUBLIC);
$this->assertEqual(count($privateProperties), 1);
$this->assertEqual($privateProperties[0]->getName(), 'publicOne');
}
public function testReflectionClassShouldReturnAllMethodsWithNoFilter() {
$reflection = new ReflectionAnnotatedClass('Example');
$methods = $reflection->getMethods();
$this->assertEqual(count($methods), 3);
}
public function testReflectionClassShouldReturnAllPropertiesWithNoFilter() {
$reflection = new ReflectionAnnotatedClass('Example');
$properties = $reflection->getProperties();
$this->assertEqual(count($properties), 2);
}
public function testMultipleAnnotationsOnClass() {
$reflection = new ReflectionAnnotatedClass('MultiExample');
$annotations = $reflection->getAllAnnotations();
$this->assertEqual(count($annotations), 3);
$this->assertEqual($annotations[0]->value, 1);
$this->assertEqual($annotations[1]->value, 2);
$this->assertEqual($annotations[2]->value, 3);
$this->assertIsA($annotations[0], 'FirstAnnotation');
$this->assertIsA($annotations[1], 'FirstAnnotation');
$this->assertIsA($annotations[2], 'SecondAnnotation');
}
public function testMultipleAnnotationsOnClassWithRestriction() {
$reflection = new ReflectionAnnotatedClass('MultiExample');
$annotations = $reflection->getAllAnnotations('FirstAnnotation');
$this->assertEqual(count($annotations), 2);
$this->assertEqual($annotations[0]->value, 1);
$this->assertEqual($annotations[1]->value, 2);
$this->assertIsA($annotations[0], 'FirstAnnotation');
$this->assertIsA($annotations[1], 'FirstAnnotation');
}
public function testMultipleAnnotationsOnProperty() {
$reflection = new ReflectionAnnotatedClass('MultiExample');
$reflection = $reflection->getProperty('property');
$annotations = $reflection->getAllAnnotations();
$this->assertEqual(count($annotations), 3);
$this->assertEqual($annotations[0]->value, 1);
$this->assertEqual($annotations[1]->value, 2);
$this->assertEqual($annotations[2]->value, 3);
$this->assertIsA($annotations[0], 'FirstAnnotation');
$this->assertIsA($annotations[1], 'FirstAnnotation');
$this->assertIsA($annotations[2], 'SecondAnnotation');
}
public function testMultipleAnnotationsOnPropertyWithRestriction() {
$reflection = new ReflectionAnnotatedClass('MultiExample');
$reflection = $reflection->getProperty('property');
$annotations = $reflection->getAllAnnotations('FirstAnnotation');
$this->assertEqual(count($annotations), 2);
$this->assertEqual($annotations[0]->value, 1);
$this->assertEqual($annotations[1]->value, 2);
$this->assertIsA($annotations[0], 'FirstAnnotation');
$this->assertIsA($annotations[1], 'FirstAnnotation');
}
public function testMultipleAnnotationsOnMethod() {
$reflection = new ReflectionAnnotatedClass('MultiExample');
$reflection = $reflection->getMethod('aMethod');
$annotations = $reflection->getAllAnnotations();
$this->assertEqual(count($annotations), 3);
$this->assertEqual($annotations[0]->value, 1);
$this->assertEqual($annotations[1]->value, 2);
$this->assertEqual($annotations[2]->value, 3);
$this->assertIsA($annotations[0], 'FirstAnnotation');
$this->assertIsA($annotations[1], 'FirstAnnotation');
$this->assertIsA($annotations[2], 'SecondAnnotation');
}
public function testMultipleAnnotationsOnMethodWithRestriction() {
$reflection = new ReflectionAnnotatedClass('MultiExample');
$reflection = $reflection->getMethod('aMethod');
$annotations = $reflection->getAllAnnotations('FirstAnnotation');
$this->assertEqual(count($annotations), 2);
$this->assertEqual($annotations[0]->value, 1);
$this->assertEqual($annotations[1]->value, 2);
$this->assertIsA($annotations[0], 'FirstAnnotation');
$this->assertIsA($annotations[1], 'FirstAnnotation');
}
}
Mock::generatePartial('AnnotationsBuilder', 'MockedAnnotationsBuilder', array('getDocComment'));
class TestOfPerformanceFeatures extends UnitTestCase {
public function setUp() {
AnnotationsBuilder::clearCache();
}
public function tearDown() {
AnnotationsBuilder::clearCache();
}
public function testBuilderShouldCacheResults() {
$builder = new MockedAnnotationsBuilder;
$reflection = new ReflectionClass('Example');
$builder->build($reflection);
$builder->build($reflection);
$builder->expectOnce('getDocComment');
}
}
class TestOfSupportingFeatures extends UnitTestCase {
public function setUp() {
Addendum::resetIgnoredAnnotations();
}
public function tearDown() {
Addendum::resetIgnoredAnnotations();
}
public function testIgnoredAnnotationsAreNotUsed() {
Addendum::ignore('FirstAnnotation', 'SecondAnnotation');
$reflection = new ReflectionAnnotatedClass('Example');
$this->assertFalse($reflection->hasAnnotation('FirstAnnotation'));
$this->assertFalse($reflection->hasAnnotation('SecondAnnotation'));
}
}
?>

View File

@ -1,33 +1,33 @@
<?php
require_once('simpletest/unit_tester.php');
require_once('simpletest/reporter.php');
require_once(dirname(__FILE__).'/acceptance_test.php');
require_once(dirname(__FILE__).'/annotation_test.php');
require_once(dirname(__FILE__).'/constrained_annotation_test.php');
require_once(dirname(__FILE__).'/annotation_parser_test.php');
require_once(dirname(__FILE__).'/doc_comment_test.php');
class AllTests extends GroupTest {
function __construct($title = false) {
parent::__construct($title);
$this->addTestClass('TestOfAnnotations');
$this->addTestClass('TestOfPerformanceFeatures');
$this->addTestClass('TestOfSupportingFeatures');
$this->addTestClass('TestOfAnnotation');
$this->addTestClass('TestOfConstrainedAnnotation');
$this->addTestClass('TestOfMatchers');
$this->addTestClass('TestOfAnnotationMatchers');
$this->addTestClass('TestOfDocComment');
}
}
Addendum::setRawMode(false);
$test = new AllTests('All tests in reflection mode');
$test->run(new HtmlReporter());
Addendum::setRawMode(true);
$test = new AllTests('All tests in raw mode');
$test->run(new HtmlReporter());
?>
<?php
require_once('simpletest/unit_tester.php');
require_once('simpletest/reporter.php');
require_once(dirname(__FILE__).'/acceptance_test.php');
require_once(dirname(__FILE__).'/annotation_test.php');
require_once(dirname(__FILE__).'/constrained_annotation_test.php');
require_once(dirname(__FILE__).'/annotation_parser_test.php');
require_once(dirname(__FILE__).'/doc_comment_test.php');
class AllTests extends GroupTest {
function __construct($title = false) {
parent::__construct($title);
$this->addTestClass('TestOfAnnotations');
$this->addTestClass('TestOfPerformanceFeatures');
$this->addTestClass('TestOfSupportingFeatures');
$this->addTestClass('TestOfAnnotation');
$this->addTestClass('TestOfConstrainedAnnotation');
$this->addTestClass('TestOfMatchers');
$this->addTestClass('TestOfAnnotationMatchers');
$this->addTestClass('TestOfDocComment');
}
}
Addendum::setRawMode(false);
$test = new AllTests('All tests in reflection mode');
$test->run(new HtmlReporter());
Addendum::setRawMode(true);
$test = new AllTests('All tests in raw mode');
$test->run(new HtmlReporter());
?>

View File

@ -1,312 +1,312 @@
<?php
require_once('simpletest/autorun.php');
require_once(dirname(__FILE__).'/../annotation_parser.php');
class TestOfMatchers extends UnitTestCase {
public function testRegexMatcherShouldMatchPatternAndReturnLengthOfMatch() {
$matcher = new RegexMatcher('[0-9]+');
$this->assertIdentical($matcher->matches('1234a', $value), 4);
$this->assertIdentical($value, '1234');
}
public function testRegexMatcherShouldReturnFalseOnNoMatch() {
$matcher = new RegexMatcher('[0-9]+');
$this->assertFalse($matcher->matches('abc123', $value));
}
public function testParallelMatcherShouldMatchLongerStringOnColision() {
$matcher = new ParallelMatcher;
$matcher->add(new RegexMatcher('true'));
$matcher->add(new RegexMatcher('.+'));
$this->assertEqual($matcher->matches('truestring', $value), 10);
$this->assertEqual($value, 'truestring');
}
public function testSerialMatcherShouldMatchAllParts() {
$matcher = new SerialMatcher;
$matcher->add(new RegexMatcher('[a-zA-Z0-9_]+'));
$matcher->add(new RegexMatcher('='));
$matcher->add(new RegexMatcher('[0-9]+'));
$this->assertEqual($matcher->matches('key=20', $value), 6);
$this->assertEqual($value, 'key=20');
}
public function testSerialMatcherShouldFailIfAnyPartDoesNotMatch() {
$matcher = new SerialMatcher;
$matcher->add(new RegexMatcher('[a-zA-Z0-9_]+'));
$matcher->add(new RegexMatcher('='));
$matcher->add(new RegexMatcher('[0-9]+'));
$this->assertFalse($matcher->matches('key=a20', $value));
}
public function testSimpleSerialMatcherShouldReturnRequestedPartOnMatch() {
$matcher = new SimpleSerialMatcher(1);
$matcher->add(new RegexMatcher('\('));
$matcher->add(new RegexMatcher('[0-9]+'));
$matcher->add(new RegexMatcher('\)'));
$this->assertEqual($matcher->matches('(1234)', $value), 6);
$this->assertEqual($value, '1234');
}
}
class TestOfAnnotationMatchers extends UnitTestCase {
public function testAnnotationsMatcherShouldMatchAnnotationWithGarbage() {
$expected = array('Annotation' => array(
array('value' => true),
));
$matcher = new AnnotationsMatcher;
$this->assertMatcherResult($matcher, '/** asd bla bla @Annotation(true) */@', $expected);
}
public function testAnnotationsMatcherShouldNotMatchEmail() {
$matcher = new AnnotationsMatcher;
$this->assertMatcherResult($matcher, 'johno@example.com', array());
}
public function testAnnotationsMatcherShouldMatchMultipleAnnotations() {
$expected = array('Annotation' => array(
array('value' => true),
array('value' => false)
));
$matcher = new AnnotationsMatcher;
$this->assertMatcherResult($matcher, ' ss @Annotation(true) @Annotation(false)', $expected);
}
public function testAnnotationsMatcherShouldMatchMultipleAnnotationsOnManyLines() {
$expected = array('Annotation' => array(
array('value' => true),
array('value' => false)
));
$block = "/**
@Annotation(true)
@Annotation(false)
**/";
$matcher = new AnnotationsMatcher;
$this->assertMatcherResult($matcher, $block, $expected);
}
public function testAnnotationMatcherShouldMatchMultilineAnnotations() {
$block= '/**
* @Annotation(
paramOne="value1",
paramTwo={
"value2" ,
{"one", "two"}
},
paramThree="three"
)
*/';
$expected = array('Annotation' => array(
array(
'paramOne' => 'value1',
'paramTwo' => array('value2', array('one', 'two')),
'paramThree' => 'three',
)
));
$matcher = new AnnotationsMatcher;
$this->assertMatcherResult($matcher, $block, $expected);
}
public function testAnnotationMatcherShouldMatchSimpleAnnotation() {
$matcher = new AnnotationMatcher;
$this->assertNotFalse($matcher->matches('@Namespace_Annotation', $value));
$this->assertEqual($value, array('Namespace_Annotation', array()));
}
public function testAnnotationMatcherShouldNotMatchAnnotationWithSmallStartingLetter() {
$matcher = new AnnotationMatcher;
$this->assertFalse($matcher->matches('@annotation', $value));
}
public function testAnnotationMatcherShouldMatchAlsoBrackets() {
$matcher = new AnnotationMatcher;
$this->assertEqual($matcher->matches('@Annotation()', $value), 13);
$this->assertEqual($value, array('Annotation', array()));
}
public function testAnnotationMatcherShouldMatchValuedAnnotation() {
$matcher = new AnnotationMatcher;
$this->assertMatcherResult($matcher, '@Annotation(true)', array('Annotation', array('value' => true)));
}
public function testAnnotationMatcherShouldMatchMultiValuedAnnotation() {
$matcher = new AnnotationMatcher;
$this->assertMatcherResult($matcher, '@Annotation(key=true, key2=3.14)', array('Annotation', array('key' => true, 'key2' => 3.14)));
}
public function testParametersMatcherShouldMatchEmptyStringAndReturnEmptyArray() {
$matcher = new AnnotationParametersMatcher;
$this->assertIdentical($matcher->matches('', $value), 0);
$this->assertEqual($value, array());
}
public function testParametersMatcherShouldMatchEmptyBracketsAndReturnEmptyArray() {
$matcher = new AnnotationParametersMatcher;
$this->assertIdentical($matcher->matches('()', $value), 2);
$this->assertEqual($value, array());
}
public function testParametersMatcherShouldMatchMultilinedParameters() {
$matcher = new AnnotationParametersMatcher;
$block = "(
key = true,
key2 = false
)";
$this->assertMatcherResult($matcher, $block, array('key' => true, 'key2' => false));
}
public function testValuesMatcherShouldMatchSimpleValueOrHash() {
$matcher = new AnnotationValuesMatcher;
$this->assertNotFalse($matcher->matches('true', $value));
$this->assertNotFalse($matcher->matches('key=true', $value));
}
public function testValueMatcherShouldMatchConstants() {
$matcher = new AnnotationValueMatcher;
$this->assertMatcherResult($matcher, 'true', true);
$this->assertMatcherResult($matcher, 'false', false);
$this->assertMatcherResult($matcher, 'TRUE', true);
$this->assertMatcherResult($matcher, 'FALSE', false);
}
public function testValueMatcherShouldMatchStrings() {
$matcher = new AnnotationValueMatcher;
$this->assertMatcherResult($matcher, '"string"', 'string');
$this->assertMatcherResult($matcher, "'string'", 'string');
}
public function testValueMatcherShouldMatchNumbers() {
$matcher = new AnnotationValueMatcher;
$this->assertMatcherResult($matcher, '-3.14', -3.14);
$this->assertMatcherResult($matcher, '100', 100);
}
public function testValueMatcherShouldMatchArray() {
$matcher = new AnnotationValueMatcher;
$this->assertMatcherResult($matcher, '{1}', array(1));
}
public function testArrayMatcherShouldMatchEmptyArray() {
$matcher = new AnnotationArrayMatcher;
$this->assertMatcherResult($matcher, '{}', array());
}
public function testValueInArrayMatcherReturnsAValueInArray() {
$matcher = new AnnotationValueInArrayMatcher;
$this->assertMatcherResult($matcher, '1', array(1));
}
public function testArrayMatcherShouldMatchSimpleValueInArray() {
$matcher = new AnnotationArrayMatcher;
$this->assertMatcherResult($matcher, '{1}', array(1));
}
public function testArrayMatcherShouldMatchSimplePair() {
$matcher = new AnnotationArrayMatcher;
$this->assertMatcherResult($matcher, '{key=5}', array('key' => 5));
}
public function TODO_testArrayMatcherShouldMatchPairWithNumericKeys() {
$matcher = new AnnotationArrayMatcher;
$this->assertMatcherResult($matcher, '{1="one", 2="two"}', array(1 => 'one', 2 => 'two'));
}
public function testArrayMatcherShouldMatchMultiplePairs() {
$matcher = new AnnotationArrayMatcher;
$this->assertMatcherResult($matcher, '{key=5, "bla"=false}', array('key' => 5, 'bla' => false));
}
public function testArrayMatcherShouldMatchValuesMixedWithPairs() {
$matcher = new AnnotationArrayMatcher;
$this->assertMatcherResult($matcher, '{key=5, 1, 2, key2="ff"}', array('key' => 5, 1, 2, 'key2' => "ff"));
}
public function testArrayMatcherShouldMatchMoreValuesInArrayWithWhiteSpace() {
$matcher = new AnnotationArrayMatcher;
$this->assertMatcherResult($matcher, "{1 , 2}", array(1, 2));
}
public function testArrayMatcherShouldMatchNestedArray() {
$matcher = new AnnotationArrayMatcher;
$this->assertMatcherResult($matcher, "{1 , {2, 3}, 4}", array(1, array(2, 3), 4));
}
public function testArrayMatcherShouldMatchWithMoreWhiteSpace() {
$matcher = new AnnotationArrayMatcher;
$this->assertMatcherResult($matcher, "{ 1 , 2 , 3 }", array(1, 2, 3));
}
public function testArrayMatcherShouldMatchWithMultilineWhiteSpace() {
$matcher = new AnnotationArrayMatcher;
$this->assertMatcherResult($matcher, "\n{1, 2, 3\n}", array(1, 2, 3));
}
public function testNumberMatcherShouldMatchInteger() {
$matcher = new AnnotationNumberMatcher;
$this->assertMatcherResult($matcher, '-314', -314);
}
public function testNumberMatcherShouldMatchFloat() {
$matcher = new AnnotationNumberMatcher;
$this->assertMatcherResult($matcher, '-3.14', -3.14);
}
public function testHashMatcherShouldMatchSimpleHash() {
$matcher = new AnnotationHashMatcher;
$this->assertMatcherResult($matcher, 'key=true', array('key' => true));
}
public function testHashMatcherShouldMatchAlsoMultipleKeys() {
$matcher = new AnnotationHashMatcher;
$this->assertMatcherResult($matcher, 'key=true,key2=false', array('key' => true, 'key2' => false));
}
public function testHashMatcherShouldMatchAlsoMultipleKeysWithWhiteSpace() {
$matcher = new AnnotationHashMatcher;
$this->assertMatcherResult($matcher, "key=true\n\t\r ,\n\t\r key2=false", array('key' => true, 'key2' => false));
}
public function testPairMatcherShouldMatchNumericKey() {
$matcher = new AnnotationPairMatcher;
$this->assertMatcherResult($matcher, '2 = true', array(2 => true));
}
public function testPairMatcherShouldMatchAlsoWhitespace() {
$matcher = new AnnotationPairMatcher;
$this->assertMatcherResult($matcher, 'key = true', array('key' => true));
}
public function testKeyMatcherShouldMatchSimpleKeysOrStrings() {
$matcher = new AnnotationKeyMatcher;
$this->assertNotFalse($matcher->matches('key', $value));
$this->assertNotFalse($matcher->matches('"key"', $value));
$this->assertNotFalse($matcher->matches("'key'", $value));
}
public function testKeyMatcherShouldMatchIntegerKeys() {
$matcher = new AnnotationKeyMatcher;
$this->assertMatcherResult($matcher, '123', 123);
}
public function testStringMatcherShouldMatchDoubleAndSingleQuotedStringsAndHandleEscapes() {
$matcher = new AnnotationStringMatcher;
$this->assertMatcherResult($matcher, '"string string"', 'string string');
$this->assertMatcherResult($matcher, "'string string'", "string string");
}
public function TODO_testStringMatcherShouldMatchEscapedStringsCorrectly() {
$matcher = new AnnotationStringMatcher;
$this->assertMatcherResult($matcher, '"string\"string"', 'string"string');
$this->assertMatcherResult($matcher, "'string\'string'", "string'string");
}
private function assertNotFalse($value) {
$this->assertNotIdentical($value, false);
}
private function assertMatcherResult($matcher, $string, $expected) {
$this->assertNotIdentical($matcher->matches($string, $value), false);
$this->assertIdentical($value, $expected);
}
}
<?php
require_once('simpletest/autorun.php');
require_once(dirname(__FILE__).'/../annotation_parser.php');
class TestOfMatchers extends UnitTestCase {
public function testRegexMatcherShouldMatchPatternAndReturnLengthOfMatch() {
$matcher = new RegexMatcher('[0-9]+');
$this->assertIdentical($matcher->matches('1234a', $value), 4);
$this->assertIdentical($value, '1234');
}
public function testRegexMatcherShouldReturnFalseOnNoMatch() {
$matcher = new RegexMatcher('[0-9]+');
$this->assertFalse($matcher->matches('abc123', $value));
}
public function testParallelMatcherShouldMatchLongerStringOnColision() {
$matcher = new ParallelMatcher;
$matcher->add(new RegexMatcher('true'));
$matcher->add(new RegexMatcher('.+'));
$this->assertEqual($matcher->matches('truestring', $value), 10);
$this->assertEqual($value, 'truestring');
}
public function testSerialMatcherShouldMatchAllParts() {
$matcher = new SerialMatcher;
$matcher->add(new RegexMatcher('[a-zA-Z0-9_]+'));
$matcher->add(new RegexMatcher('='));
$matcher->add(new RegexMatcher('[0-9]+'));
$this->assertEqual($matcher->matches('key=20', $value), 6);
$this->assertEqual($value, 'key=20');
}
public function testSerialMatcherShouldFailIfAnyPartDoesNotMatch() {
$matcher = new SerialMatcher;
$matcher->add(new RegexMatcher('[a-zA-Z0-9_]+'));
$matcher->add(new RegexMatcher('='));
$matcher->add(new RegexMatcher('[0-9]+'));
$this->assertFalse($matcher->matches('key=a20', $value));
}
public function testSimpleSerialMatcherShouldReturnRequestedPartOnMatch() {
$matcher = new SimpleSerialMatcher(1);
$matcher->add(new RegexMatcher('\('));
$matcher->add(new RegexMatcher('[0-9]+'));
$matcher->add(new RegexMatcher('\)'));
$this->assertEqual($matcher->matches('(1234)', $value), 6);
$this->assertEqual($value, '1234');
}
}
class TestOfAnnotationMatchers extends UnitTestCase {
public function testAnnotationsMatcherShouldMatchAnnotationWithGarbage() {
$expected = array('Annotation' => array(
array('value' => true),
));
$matcher = new AnnotationsMatcher;
$this->assertMatcherResult($matcher, '/** asd bla bla @Annotation(true) */@', $expected);
}
public function testAnnotationsMatcherShouldNotMatchEmail() {
$matcher = new AnnotationsMatcher;
$this->assertMatcherResult($matcher, 'johno@example.com', array());
}
public function testAnnotationsMatcherShouldMatchMultipleAnnotations() {
$expected = array('Annotation' => array(
array('value' => true),
array('value' => false)
));
$matcher = new AnnotationsMatcher;
$this->assertMatcherResult($matcher, ' ss @Annotation(true) @Annotation(false)', $expected);
}
public function testAnnotationsMatcherShouldMatchMultipleAnnotationsOnManyLines() {
$expected = array('Annotation' => array(
array('value' => true),
array('value' => false)
));
$block = "/**
@Annotation(true)
@Annotation(false)
**/";
$matcher = new AnnotationsMatcher;
$this->assertMatcherResult($matcher, $block, $expected);
}
public function testAnnotationMatcherShouldMatchMultilineAnnotations() {
$block= '/**
* @Annotation(
paramOne="value1",
paramTwo={
"value2" ,
{"one", "two"}
},
paramThree="three"
)
*/';
$expected = array('Annotation' => array(
array(
'paramOne' => 'value1',
'paramTwo' => array('value2', array('one', 'two')),
'paramThree' => 'three',
)
));
$matcher = new AnnotationsMatcher;
$this->assertMatcherResult($matcher, $block, $expected);
}
public function testAnnotationMatcherShouldMatchSimpleAnnotation() {
$matcher = new AnnotationMatcher;
$this->assertNotFalse($matcher->matches('@Namespace_Annotation', $value));
$this->assertEqual($value, array('Namespace_Annotation', array()));
}
public function testAnnotationMatcherShouldNotMatchAnnotationWithSmallStartingLetter() {
$matcher = new AnnotationMatcher;
$this->assertFalse($matcher->matches('@annotation', $value));
}
public function testAnnotationMatcherShouldMatchAlsoBrackets() {
$matcher = new AnnotationMatcher;
$this->assertEqual($matcher->matches('@Annotation()', $value), 13);
$this->assertEqual($value, array('Annotation', array()));
}
public function testAnnotationMatcherShouldMatchValuedAnnotation() {
$matcher = new AnnotationMatcher;
$this->assertMatcherResult($matcher, '@Annotation(true)', array('Annotation', array('value' => true)));
}
public function testAnnotationMatcherShouldMatchMultiValuedAnnotation() {
$matcher = new AnnotationMatcher;
$this->assertMatcherResult($matcher, '@Annotation(key=true, key2=3.14)', array('Annotation', array('key' => true, 'key2' => 3.14)));
}
public function testParametersMatcherShouldMatchEmptyStringAndReturnEmptyArray() {
$matcher = new AnnotationParametersMatcher;
$this->assertIdentical($matcher->matches('', $value), 0);
$this->assertEqual($value, array());
}
public function testParametersMatcherShouldMatchEmptyBracketsAndReturnEmptyArray() {
$matcher = new AnnotationParametersMatcher;
$this->assertIdentical($matcher->matches('()', $value), 2);
$this->assertEqual($value, array());
}
public function testParametersMatcherShouldMatchMultilinedParameters() {
$matcher = new AnnotationParametersMatcher;
$block = "(
key = true,
key2 = false
)";
$this->assertMatcherResult($matcher, $block, array('key' => true, 'key2' => false));
}
public function testValuesMatcherShouldMatchSimpleValueOrHash() {
$matcher = new AnnotationValuesMatcher;
$this->assertNotFalse($matcher->matches('true', $value));
$this->assertNotFalse($matcher->matches('key=true', $value));
}
public function testValueMatcherShouldMatchConstants() {
$matcher = new AnnotationValueMatcher;
$this->assertMatcherResult($matcher, 'true', true);
$this->assertMatcherResult($matcher, 'false', false);
$this->assertMatcherResult($matcher, 'TRUE', true);
$this->assertMatcherResult($matcher, 'FALSE', false);
}
public function testValueMatcherShouldMatchStrings() {
$matcher = new AnnotationValueMatcher;
$this->assertMatcherResult($matcher, '"string"', 'string');
$this->assertMatcherResult($matcher, "'string'", 'string');
}
public function testValueMatcherShouldMatchNumbers() {
$matcher = new AnnotationValueMatcher;
$this->assertMatcherResult($matcher, '-3.14', -3.14);
$this->assertMatcherResult($matcher, '100', 100);
}
public function testValueMatcherShouldMatchArray() {
$matcher = new AnnotationValueMatcher;
$this->assertMatcherResult($matcher, '{1}', array(1));
}
public function testArrayMatcherShouldMatchEmptyArray() {
$matcher = new AnnotationArrayMatcher;
$this->assertMatcherResult($matcher, '{}', array());
}
public function testValueInArrayMatcherReturnsAValueInArray() {
$matcher = new AnnotationValueInArrayMatcher;
$this->assertMatcherResult($matcher, '1', array(1));
}
public function testArrayMatcherShouldMatchSimpleValueInArray() {
$matcher = new AnnotationArrayMatcher;
$this->assertMatcherResult($matcher, '{1}', array(1));
}
public function testArrayMatcherShouldMatchSimplePair() {
$matcher = new AnnotationArrayMatcher;
$this->assertMatcherResult($matcher, '{key=5}', array('key' => 5));
}
public function TODO_testArrayMatcherShouldMatchPairWithNumericKeys() {
$matcher = new AnnotationArrayMatcher;
$this->assertMatcherResult($matcher, '{1="one", 2="two"}', array(1 => 'one', 2 => 'two'));
}
public function testArrayMatcherShouldMatchMultiplePairs() {
$matcher = new AnnotationArrayMatcher;
$this->assertMatcherResult($matcher, '{key=5, "bla"=false}', array('key' => 5, 'bla' => false));
}
public function testArrayMatcherShouldMatchValuesMixedWithPairs() {
$matcher = new AnnotationArrayMatcher;
$this->assertMatcherResult($matcher, '{key=5, 1, 2, key2="ff"}', array('key' => 5, 1, 2, 'key2' => "ff"));
}
public function testArrayMatcherShouldMatchMoreValuesInArrayWithWhiteSpace() {
$matcher = new AnnotationArrayMatcher;
$this->assertMatcherResult($matcher, "{1 , 2}", array(1, 2));
}
public function testArrayMatcherShouldMatchNestedArray() {
$matcher = new AnnotationArrayMatcher;
$this->assertMatcherResult($matcher, "{1 , {2, 3}, 4}", array(1, array(2, 3), 4));
}
public function testArrayMatcherShouldMatchWithMoreWhiteSpace() {
$matcher = new AnnotationArrayMatcher;
$this->assertMatcherResult($matcher, "{ 1 , 2 , 3 }", array(1, 2, 3));
}
public function testArrayMatcherShouldMatchWithMultilineWhiteSpace() {
$matcher = new AnnotationArrayMatcher;
$this->assertMatcherResult($matcher, "\n{1, 2, 3\n}", array(1, 2, 3));
}
public function testNumberMatcherShouldMatchInteger() {
$matcher = new AnnotationNumberMatcher;
$this->assertMatcherResult($matcher, '-314', -314);
}
public function testNumberMatcherShouldMatchFloat() {
$matcher = new AnnotationNumberMatcher;
$this->assertMatcherResult($matcher, '-3.14', -3.14);
}
public function testHashMatcherShouldMatchSimpleHash() {
$matcher = new AnnotationHashMatcher;
$this->assertMatcherResult($matcher, 'key=true', array('key' => true));
}
public function testHashMatcherShouldMatchAlsoMultipleKeys() {
$matcher = new AnnotationHashMatcher;
$this->assertMatcherResult($matcher, 'key=true,key2=false', array('key' => true, 'key2' => false));
}
public function testHashMatcherShouldMatchAlsoMultipleKeysWithWhiteSpace() {
$matcher = new AnnotationHashMatcher;
$this->assertMatcherResult($matcher, "key=true\n\t\r ,\n\t\r key2=false", array('key' => true, 'key2' => false));
}
public function testPairMatcherShouldMatchNumericKey() {
$matcher = new AnnotationPairMatcher;
$this->assertMatcherResult($matcher, '2 = true', array(2 => true));
}
public function testPairMatcherShouldMatchAlsoWhitespace() {
$matcher = new AnnotationPairMatcher;
$this->assertMatcherResult($matcher, 'key = true', array('key' => true));
}
public function testKeyMatcherShouldMatchSimpleKeysOrStrings() {
$matcher = new AnnotationKeyMatcher;
$this->assertNotFalse($matcher->matches('key', $value));
$this->assertNotFalse($matcher->matches('"key"', $value));
$this->assertNotFalse($matcher->matches("'key'", $value));
}
public function testKeyMatcherShouldMatchIntegerKeys() {
$matcher = new AnnotationKeyMatcher;
$this->assertMatcherResult($matcher, '123', 123);
}
public function testStringMatcherShouldMatchDoubleAndSingleQuotedStringsAndHandleEscapes() {
$matcher = new AnnotationStringMatcher;
$this->assertMatcherResult($matcher, '"string string"', 'string string');
$this->assertMatcherResult($matcher, "'string string'", "string string");
}
public function TODO_testStringMatcherShouldMatchEscapedStringsCorrectly() {
$matcher = new AnnotationStringMatcher;
$this->assertMatcherResult($matcher, '"string\"string"', 'string"string');
$this->assertMatcherResult($matcher, "'string\'string'", "string'string");
}
private function assertNotFalse($value) {
$this->assertNotIdentical($value, false);
}
private function assertMatcherResult($matcher, $string, $expected) {
$this->assertNotIdentical($matcher->matches($string, $value), false);
$this->assertIdentical($value, $expected);
}
}
?>

View File

@ -1,27 +1,27 @@
<?php
require_once('simpletest/autorun.php');
require_once(dirname(__FILE__).'/../../annotations.php');
class TestingAnnotation extends Annotation {
public $optional = 'default';
public $required;
}
class TestOfAnnotation extends UnitTestCase {
public function testConstructorsFillsParameters() {
$annotation = new TestingAnnotation(array('optional' => 1, 'required' => 2), $this);
$this->assertEqual($annotation->optional, 1);
$this->assertEqual($annotation->required, 2);
}
public function testConstructorThrowsErrorOnInvalidParameter() {
$annotation = new TestingAnnotation(array('unknown' => 1), $this);
$this->assertError("Property 'unknown' not defined for annotation 'TestingAnnotation'");
}
public function TODO_testConstructorThrowsErrorWithoutSpecifingRequiredParameters() {
$annotation = new TestingAnnotation();
$this->assertError("Property 'required' in annotation 'TestingAnnotation' is required");
}
}
?>
<?php
require_once('simpletest/autorun.php');
require_once(dirname(__FILE__).'/../../annotations.php');
class TestingAnnotation extends Annotation {
public $optional = 'default';
public $required;
}
class TestOfAnnotation extends UnitTestCase {
public function testConstructorsFillsParameters() {
$annotation = new TestingAnnotation(array('optional' => 1, 'required' => 2), $this);
$this->assertEqual($annotation->optional, 1);
$this->assertEqual($annotation->required, 2);
}
public function testConstructorThrowsErrorOnInvalidParameter() {
$annotation = new TestingAnnotation(array('unknown' => 1), $this);
$this->assertError("Property 'unknown' not defined for annotation 'TestingAnnotation'");
}
public function TODO_testConstructorThrowsErrorWithoutSpecifingRequiredParameters() {
$annotation = new TestingAnnotation();
$this->assertError("Property 'required' in annotation 'TestingAnnotation' is required");
}
}
?>

View File

@ -1,73 +1,73 @@
<?php
require_once('simpletest/autorun.php');
require_once(dirname(__FILE__).'/../../annotations.php');
/** @Target("class") */
class ClassRestrictedAnnotation extends Annotation {}
/** @Target("method") */
class MethodRestrictedAnnotation extends Annotation {}
/** @Target("property") */
class PropertyRestrictedAnnotation extends Annotation {}
/** @Target({"class", "property"}) */
class ClassOrPropertyRestrictedAnnotation extends Annotation {}
class BadlyAnnotatedClass {
/** @ClassRestrictedAnnotation */
private $property;
/** @ClassRestrictedAnnotation */
public function method() {}
/** @ClassOrPropertyRestrictedAnnotation */
public function method2() {}
}
/** @ClassRestrictedAnnotation */
class SuccesfullyAnnotatedClass {
/** @PropertyRestrictedAnnotation */
private $property;
/** @ClassOrPropertyRestrictedAnnotation */
private $property2;
/** @MethodRestrictedAnnotation */
public function method() {}
}
class TestOfConstrainedAnnotation extends UnitTestCase {
public function testClassAnnotationThrowsErrorWhenOnMethod() {
$this->expectError("Annotation 'ClassRestrictedAnnotation' not allowed on BadlyAnnotatedClass::method");
$reflection = new ReflectionAnnotatedClass('BadlyAnnotatedClass');
$method = $reflection->getMethod('method');
}
public function testClassAnnotationThrowsErrorWhenOnProperty() {
$this->expectError("Annotation 'ClassRestrictedAnnotation' not allowed on BadlyAnnotatedClass::\$property");
$reflection = new ReflectionAnnotatedClass('BadlyAnnotatedClass');
$method = $reflection->getProperty('property');
}
public function testSingleTargetAnnotationThrowsNoErrorWhenOnRightPlace() {
$reflection = new ReflectionAnnotatedClass('SuccesfullyAnnotatedClass');
$method = $reflection->getMethod('method');
$property = $reflection->getProperty('property');
$this->assertNoErrors();
}
public function testMultiTargetAnnotationThrowsErrorWhenOnWrongPlace() {
$this->expectError("Annotation 'ClassOrPropertyRestrictedAnnotation' not allowed on BadlyAnnotatedClass::method2");
$reflection = new ReflectionAnnotatedClass('BadlyAnnotatedClass');
$method = $reflection->getMethod('method2');
}
public function testMultiTargetAnnotationThrowsNoErrorWhenOnRightPlace() {
$reflection = new ReflectionAnnotatedClass('SuccesfullyAnnotatedClass');
$method = $reflection->getProperty('property2');
$this->assertNoErrors();
}
}
<?php
require_once('simpletest/autorun.php');
require_once(dirname(__FILE__).'/../../annotations.php');
/** @Target("class") */
class ClassRestrictedAnnotation extends Annotation {}
/** @Target("method") */
class MethodRestrictedAnnotation extends Annotation {}
/** @Target("property") */
class PropertyRestrictedAnnotation extends Annotation {}
/** @Target({"class", "property"}) */
class ClassOrPropertyRestrictedAnnotation extends Annotation {}
class BadlyAnnotatedClass {
/** @ClassRestrictedAnnotation */
private $property;
/** @ClassRestrictedAnnotation */
public function method() {}
/** @ClassOrPropertyRestrictedAnnotation */
public function method2() {}
}
/** @ClassRestrictedAnnotation */
class SuccesfullyAnnotatedClass {
/** @PropertyRestrictedAnnotation */
private $property;
/** @ClassOrPropertyRestrictedAnnotation */
private $property2;
/** @MethodRestrictedAnnotation */
public function method() {}
}
class TestOfConstrainedAnnotation extends UnitTestCase {
public function testClassAnnotationThrowsErrorWhenOnMethod() {
$this->expectError("Annotation 'ClassRestrictedAnnotation' not allowed on BadlyAnnotatedClass::method");
$reflection = new ReflectionAnnotatedClass('BadlyAnnotatedClass');
$method = $reflection->getMethod('method');
}
public function testClassAnnotationThrowsErrorWhenOnProperty() {
$this->expectError("Annotation 'ClassRestrictedAnnotation' not allowed on BadlyAnnotatedClass::\$property");
$reflection = new ReflectionAnnotatedClass('BadlyAnnotatedClass');
$method = $reflection->getProperty('property');
}
public function testSingleTargetAnnotationThrowsNoErrorWhenOnRightPlace() {
$reflection = new ReflectionAnnotatedClass('SuccesfullyAnnotatedClass');
$method = $reflection->getMethod('method');
$property = $reflection->getProperty('property');
$this->assertNoErrors();
}
public function testMultiTargetAnnotationThrowsErrorWhenOnWrongPlace() {
$this->expectError("Annotation 'ClassOrPropertyRestrictedAnnotation' not allowed on BadlyAnnotatedClass::method2");
$reflection = new ReflectionAnnotatedClass('BadlyAnnotatedClass');
$method = $reflection->getMethod('method2');
}
public function testMultiTargetAnnotationThrowsNoErrorWhenOnRightPlace() {
$reflection = new ReflectionAnnotatedClass('SuccesfullyAnnotatedClass');
$method = $reflection->getProperty('property2');
$this->assertNoErrors();
}
}
?>

View File

@ -1,87 +1,87 @@
<?php
require_once('simpletest/autorun.php');
require_once('simpletest/mock_objects.php');
require_once(dirname(__FILE__).'/../doc_comment.php');
Mock::generatePartial('DocComment', 'MockDocComment', array('parse'));
/** class doccomment */
class SomeClass {
/** field doccomment */
private $field1;
private $field2;
/** method1 doccomment */
public function method1() {
}
public function method2() {}
/** bad one */
}
class SomeOtherClass {
/** field doccomment */
private $field1;
}
class TestOfDocComment extends UnitTestCase {
public function setUp() {
DocComment::clearCache();
}
public function testFinderFindsClassDocBlock() {
$reflection = new ReflectionClass('SomeClass');
$finder = new DocComment();
$this->assertEqual($finder->get($reflection), '/** class doccomment */');
}
public function testFinderFindsFieldDocBlock() {
$reflection = new ReflectionClass('SomeClass');
$property = $reflection->getProperty('field1');
$finder = new DocComment();
$this->assertEqual($finder->get($property), '/** field doccomment */');
$property = $reflection->getProperty('field2');
$finder = new DocComment();
$this->assertFalse($finder->get($property));
}
public function testFinderFindsMethodDocBlock() {
$reflection = new ReflectionClass('SomeClass');
$method = $reflection->getMethod('method1');
$finder = new DocComment();
$this->assertEqual($finder->get($method), '/** method1 doccomment */');
$method = $reflection->getMethod('method2');
$finder = new DocComment();
$this->assertFalse($finder->get($method));
}
public function testMisplacedDocCommentDoesNotCausesDisaster() {
$reflection = new ReflectionClass('SomeOtherClass');
$finder = new DocComment();
$this->assertEqual($finder->get($reflection), false);
}
public function testUnanotatedClassCanHaveAnotatedField() {
$reflection = new ReflectionClass('SomeOtherClass');
$property = $reflection->getProperty('field1');
$finder = new DocComment();
$this->assertEqual($finder->get($property), '/** field doccomment */');
}
public function testParserIsOnlyCalledOncePerFile() {
$reflection = new ReflectionClass('SomeClass');
$finder = new MockDocComment();
$finder->expectOnce('parse');
$this->assertEqual($finder->get($reflection), false);
$this->assertEqual($finder->get($reflection), false);
$reflection = new ReflectionClass('SomeClass');
$finder = new MockDocComment();
$finder->expectNever('parse');
$this->assertEqual($finder->get($reflection), false);
}
}
?>
<?php
require_once('simpletest/autorun.php');
require_once('simpletest/mock_objects.php');
require_once(dirname(__FILE__).'/../doc_comment.php');
Mock::generatePartial('DocComment', 'MockDocComment', array('parse'));
/** class doccomment */
class SomeClass {
/** field doccomment */
private $field1;
private $field2;
/** method1 doccomment */
public function method1() {
}
public function method2() {}
/** bad one */
}
class SomeOtherClass {
/** field doccomment */
private $field1;
}
class TestOfDocComment extends UnitTestCase {
public function setUp() {
DocComment::clearCache();
}
public function testFinderFindsClassDocBlock() {
$reflection = new ReflectionClass('SomeClass');
$finder = new DocComment();
$this->assertEqual($finder->get($reflection), '/** class doccomment */');
}
public function testFinderFindsFieldDocBlock() {
$reflection = new ReflectionClass('SomeClass');
$property = $reflection->getProperty('field1');
$finder = new DocComment();
$this->assertEqual($finder->get($property), '/** field doccomment */');
$property = $reflection->getProperty('field2');
$finder = new DocComment();
$this->assertFalse($finder->get($property));
}
public function testFinderFindsMethodDocBlock() {
$reflection = new ReflectionClass('SomeClass');
$method = $reflection->getMethod('method1');
$finder = new DocComment();
$this->assertEqual($finder->get($method), '/** method1 doccomment */');
$method = $reflection->getMethod('method2');
$finder = new DocComment();
$this->assertFalse($finder->get($method));
}
public function testMisplacedDocCommentDoesNotCausesDisaster() {
$reflection = new ReflectionClass('SomeOtherClass');
$finder = new DocComment();
$this->assertEqual($finder->get($reflection), false);
}
public function testUnanotatedClassCanHaveAnotatedField() {
$reflection = new ReflectionClass('SomeOtherClass');
$property = $reflection->getProperty('field1');
$finder = new DocComment();
$this->assertEqual($finder->get($property), '/** field doccomment */');
}
public function testParserIsOnlyCalledOncePerFile() {
$reflection = new ReflectionClass('SomeClass');
$finder = new MockDocComment();
$finder->expectOnce('parse');
$this->assertEqual($finder->get($reflection), false);
$this->assertEqual($finder->get($reflection), false);
$reflection = new ReflectionClass('SomeClass');
$finder = new MockDocComment();
$finder->expectNever('parse');
$this->assertEqual($finder->get($reflection), false);
}
}
?>

View File

@ -1,130 +1,130 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\Tests\ORM\Query;
require_once __DIR__ . '/../../TestInit.php';
/**
* Test case for testing the saving and referencing of query identifiers.
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 2.0
* @version $Revision$
*/
class IdentifierRecognitionTest extends \Doctrine\Tests\OrmTestCase
{
private $_em;
protected function setUp() {
parent::setUp();
$this->_em = $this->_getTestEntityManager();
}
public function testSingleAliasDeclarationIsSupported()
{
$entityManager = $this->_em;
$query = $entityManager->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u');
$parserResult = $query->parse();
$decl = $parserResult->getQueryComponent('u');
$this->assertTrue($decl['metadata'] instanceof \Doctrine\ORM\Mapping\ClassMetadata);
$this->assertEquals(null, $decl['relation']);
$this->assertEquals(null, $decl['parent']);
$this->assertEquals(null, $decl['scalar']);
$this->assertEquals(null, $decl['map']);
}
public function testSingleAliasDeclarationWithIndexByIsSupported()
{
$entityManager = $this->_em;
$query = $entityManager->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INDEX BY u.id');
$parserResult = $query->parse();
$decl = $parserResult->getQueryComponent('u');
$this->assertTrue($decl['metadata'] instanceof \Doctrine\ORM\Mapping\ClassMetadata);
$this->assertEquals(null, $decl['relation']);
$this->assertEquals(null, $decl['parent']);
$this->assertEquals(null, $decl['scalar']);
$this->assertEquals('id', $decl['map']);
}
public function testQueryParserSupportsMultipleAliasDeclarations()
{
$entityManager = $this->_em;
$query = $entityManager->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INDEX BY u.id LEFT JOIN u.phonenumbers p');
$parserResult = $query->parse();
$decl = $parserResult->getQueryComponent('u');
$this->assertTrue($decl['metadata'] instanceof \Doctrine\ORM\Mapping\ClassMetadata);
$this->assertEquals(null, $decl['relation']);
$this->assertEquals(null, $decl['parent']);
$this->assertEquals(null, $decl['scalar']);
$this->assertEquals('id', $decl['map']);
$decl = $parserResult->getQueryComponent('p');
$this->assertTrue($decl['metadata'] instanceof \Doctrine\ORM\Mapping\ClassMetadata);
$this->assertTrue($decl['relation'] instanceof \Doctrine\ORM\Mapping\AssociationMapping);
$this->assertEquals('u', $decl['parent']);
$this->assertEquals(null, $decl['scalar']);
$this->assertEquals(null, $decl['map']);
}
public function testQueryParserSupportsMultipleAliasDeclarationsWithIndexBy()
{
$entityManager = $this->_em;
$query = $entityManager->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INDEX BY u.id LEFT JOIN u.articles a INNER JOIN u.phonenumbers pn INDEX BY pn.phonenumber');
$parserResult = $query->parse();
$decl = $parserResult->getQueryComponent('u');
$this->assertTrue($decl['metadata'] instanceof \Doctrine\ORM\Mapping\ClassMetadata);
$this->assertEquals(null, $decl['relation']);
$this->assertEquals(null, $decl['parent']);
$this->assertEquals(null, $decl['scalar']);
$this->assertEquals('id', $decl['map']);
$decl = $parserResult->getQueryComponent('a');
$this->assertTrue($decl['metadata'] instanceof \Doctrine\ORM\Mapping\ClassMetadata);
$this->assertTrue($decl['relation'] instanceof \Doctrine\ORM\Mapping\AssociationMapping);
$this->assertEquals('u', $decl['parent']);
$this->assertEquals(null, $decl['scalar']);
$this->assertEquals(null, $decl['map']);
$decl = $parserResult->getQueryComponent('pn');
$this->assertTrue($decl['metadata'] instanceof \Doctrine\ORM\Mapping\ClassMetadata);
$this->assertTrue($decl['relation'] instanceof \Doctrine\ORM\Mapping\AssociationMapping);
$this->assertEquals('u', $decl['parent']);
$this->assertEquals(null, $decl['scalar']);
$this->assertEquals('phonenumber', $decl['map']);
}
}
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\Tests\ORM\Query;
require_once __DIR__ . '/../../TestInit.php';
/**
* Test case for testing the saving and referencing of query identifiers.
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 2.0
* @version $Revision$
*/
class IdentifierRecognitionTest extends \Doctrine\Tests\OrmTestCase
{
private $_em;
protected function setUp() {
parent::setUp();
$this->_em = $this->_getTestEntityManager();
}
public function testSingleAliasDeclarationIsSupported()
{
$entityManager = $this->_em;
$query = $entityManager->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u');
$parserResult = $query->parse();
$decl = $parserResult->getQueryComponent('u');
$this->assertTrue($decl['metadata'] instanceof \Doctrine\ORM\Mapping\ClassMetadata);
$this->assertEquals(null, $decl['relation']);
$this->assertEquals(null, $decl['parent']);
$this->assertEquals(null, $decl['scalar']);
$this->assertEquals(null, $decl['map']);
}
public function testSingleAliasDeclarationWithIndexByIsSupported()
{
$entityManager = $this->_em;
$query = $entityManager->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INDEX BY u.id');
$parserResult = $query->parse();
$decl = $parserResult->getQueryComponent('u');
$this->assertTrue($decl['metadata'] instanceof \Doctrine\ORM\Mapping\ClassMetadata);
$this->assertEquals(null, $decl['relation']);
$this->assertEquals(null, $decl['parent']);
$this->assertEquals(null, $decl['scalar']);
$this->assertEquals('id', $decl['map']);
}
public function testQueryParserSupportsMultipleAliasDeclarations()
{
$entityManager = $this->_em;
$query = $entityManager->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INDEX BY u.id LEFT JOIN u.phonenumbers p');
$parserResult = $query->parse();
$decl = $parserResult->getQueryComponent('u');
$this->assertTrue($decl['metadata'] instanceof \Doctrine\ORM\Mapping\ClassMetadata);
$this->assertEquals(null, $decl['relation']);
$this->assertEquals(null, $decl['parent']);
$this->assertEquals(null, $decl['scalar']);
$this->assertEquals('id', $decl['map']);
$decl = $parserResult->getQueryComponent('p');
$this->assertTrue($decl['metadata'] instanceof \Doctrine\ORM\Mapping\ClassMetadata);
$this->assertTrue($decl['relation'] instanceof \Doctrine\ORM\Mapping\AssociationMapping);
$this->assertEquals('u', $decl['parent']);
$this->assertEquals(null, $decl['scalar']);
$this->assertEquals(null, $decl['map']);
}
public function testQueryParserSupportsMultipleAliasDeclarationsWithIndexBy()
{
$entityManager = $this->_em;
$query = $entityManager->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INDEX BY u.id LEFT JOIN u.articles a INNER JOIN u.phonenumbers pn INDEX BY pn.phonenumber');
$parserResult = $query->parse();
$decl = $parserResult->getQueryComponent('u');
$this->assertTrue($decl['metadata'] instanceof \Doctrine\ORM\Mapping\ClassMetadata);
$this->assertEquals(null, $decl['relation']);
$this->assertEquals(null, $decl['parent']);
$this->assertEquals(null, $decl['scalar']);
$this->assertEquals('id', $decl['map']);
$decl = $parserResult->getQueryComponent('a');
$this->assertTrue($decl['metadata'] instanceof \Doctrine\ORM\Mapping\ClassMetadata);
$this->assertTrue($decl['relation'] instanceof \Doctrine\ORM\Mapping\AssociationMapping);
$this->assertEquals('u', $decl['parent']);
$this->assertEquals(null, $decl['scalar']);
$this->assertEquals(null, $decl['map']);
$decl = $parserResult->getQueryComponent('pn');
$this->assertTrue($decl['metadata'] instanceof \Doctrine\ORM\Mapping\ClassMetadata);
$this->assertTrue($decl['relation'] instanceof \Doctrine\ORM\Mapping\AssociationMapping);
$this->assertEquals('u', $decl['parent']);
$this->assertEquals(null, $decl['scalar']);
$this->assertEquals('phonenumber', $decl['map']);
}
}