Skip to content

Commit

Permalink
Merge remote branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
jwage committed Apr 23, 2010
2 parents aa70e64 + 841008c commit 023f06a
Show file tree
Hide file tree
Showing 20 changed files with 403 additions and 155 deletions.
24 changes: 20 additions & 4 deletions lib/Doctrine/Common/Annotations/Annotation.php
Expand Up @@ -27,7 +27,8 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @version $Revision$
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
Expand All @@ -52,14 +53,29 @@ public final function __construct(array $data)
$this->$key = $value;
}
}


/**
* Error handler for unknown property accessor in Annotation class.
*
* @param string $name Unknown property name
*/
public function __get($name)
{
throw new \BadMethodCallException("Unknown annotation property '$name' on annotation '".get_class($this)."'.");
throw new \BadMethodCallException(
sprintf("Unknown property '%s' on annotation '%s'.", $name, get_class($this))
);
}

/**
* Error handler for unknown property mutator in Annotation class.
*
* @param string $name Unkown property name
* @param mixed $value Property value
*/
public function __set($name, $value)
{
throw new \BadMethodCallException("Unknown annotation property '$name' on annotation '".get_class($this)."'.");
throw new \BadMethodCallException(
sprintf("Unknown property '%s' on annotation '%s'.", $name, get_class($this))
);
}
}
20 changes: 16 additions & 4 deletions lib/Doctrine/Common/Annotations/AnnotationException.php
Expand Up @@ -27,20 +27,32 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @version $Revision$
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
class AnnotationException extends \Doctrine\Common\CommonException
class AnnotationException extends \Exception
{
/**
* Creates a new AnnotationException describing a Syntax error.
*
* @param string $message Exception message
* @return AnnotationException
*/
public static function syntaxError($message)
{
return new self('[Syntax Error] ' . $message);
}


public static function semanticalError($message)
/**
* Creates a new AnnotationException describing a Semantical error.
*
* @param string $message Exception message
* @return AnnotationException
*/
public static function semanticalError($message)
{
return new self('[Semantical Error] ' . $message);
}
Expand Down
18 changes: 10 additions & 8 deletions lib/Doctrine/Common/Annotations/AnnotationReader.php
Expand Up @@ -32,7 +32,7 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @version $Revision$
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
Expand All @@ -46,7 +46,7 @@ class AnnotationReader
* @var string
* @static
*/
private static $CACHE_SALT = "@<Annot>";
private static $CACHE_SALT = '@<Annot>';

/**
* Annotations Parser
Expand All @@ -56,15 +56,14 @@ class AnnotationReader
private $_parser;

/**
* Cache machanism to store processed Annotations
* Cache mechanism to store processed Annotations
*
* @var Doctrine\Common\Cache\Cache
*/
private $_cache;

/**
* Constructor. Initializes a new AnnotationReader that uses the given
* Cache provider.
* Constructor. Initializes a new AnnotationReader that uses the given Cache provider.
*
* @param Cache $cache The cache provider to use. If none is provided, ArrayCache is used.
*/
Expand Down Expand Up @@ -112,7 +111,7 @@ public function getClassAnnotations(ReflectionClass $class)
return $data;
}

$annotations = $this->_parser->parse($class->getDocComment(), "class ".$class->getName());
$annotations = $this->_parser->parse($class->getDocComment(), 'class ' . $class->getName());
$this->_cache->save($cacheKey, $annotations, null);

return $annotations;
Expand All @@ -128,6 +127,7 @@ public function getClassAnnotations(ReflectionClass $class)
public function getClassAnnotation(ReflectionClass $class, $annotation)
{
$annotations = $this->getClassAnnotations($class);

return isset($annotations[$annotation]) ? $annotations[$annotation] : null;
}

Expand All @@ -148,7 +148,7 @@ public function getPropertyAnnotations(ReflectionProperty $property)
return $data;
}

$context = "property ".$property->getDeclaringClass()->getName()."::\$".$property->getName();
$context = 'property ' . $property->getDeclaringClass()->getName() . "::\$" . $property->getName();
$annotations = $this->_parser->parse($property->getDocComment(), $context);
$this->_cache->save($cacheKey, $annotations, null);

Expand All @@ -165,6 +165,7 @@ public function getPropertyAnnotations(ReflectionProperty $property)
public function getPropertyAnnotation(ReflectionProperty $property, $annotation)
{
$annotations = $this->getPropertyAnnotations($property);

return isset($annotations[$annotation]) ? $annotations[$annotation] : null;
}

Expand All @@ -185,7 +186,7 @@ public function getMethodAnnotations(ReflectionMethod $method)
return $data;
}

$context = "method ".$method->getDeclaringClass()->getName()."::".$method->getName()."()";
$context = 'method ' . $method->getDeclaringClass()->getName() . '::' . $method->getName() . '()';
$annotations = $this->_parser->parse($method->getDocComment(), $context);
$this->_cache->save($cacheKey, $annotations, null);

Expand All @@ -202,6 +203,7 @@ public function getMethodAnnotations(ReflectionMethod $method)
public function getMethodAnnotation(ReflectionMethod $method, $annotation)
{
$annotations = $this->getMethodAnnotations($method);

return isset($annotations[$annotation]) ? $annotations[$annotation] : null;
}
}
42 changes: 31 additions & 11 deletions lib/Doctrine/Common/Annotations/Lexer.php
Expand Up @@ -27,7 +27,8 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @version $Revision$
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
Expand Down Expand Up @@ -80,7 +81,7 @@ protected function _getType(&$value)
$newVal = $this->_getNumeric($value);

// Checking numeric value
if ($newVal !== false){
if ($newVal !== false) {
$value = $newVal;

return (strpos($value, '.') !== false || stripos($value, 'e') !== false)
Expand All @@ -93,16 +94,34 @@ protected function _getType(&$value)
return self::T_STRING;
} else {
switch (strtolower($value)) {
case '@': return self::T_AT;
case ',': return self::T_COMMA;
case '(': return self::T_OPEN_PARENTHESIS;
case ')': return self::T_CLOSE_PARENTHESIS;
case '{': return self::T_OPEN_CURLY_BRACES;
case '@':
return self::T_AT;

case ',':
return self::T_COMMA;

case '(':
return self::T_OPEN_PARENTHESIS;

case ')':
return self::T_CLOSE_PARENTHESIS;

case '{':
return self::T_OPEN_CURLY_BRACES;

case '}': return self::T_CLOSE_CURLY_BRACES;
case '=': return self::T_EQUALS;
case '\\': return self::T_NAMESPACE_SEPARATOR;
case 'true': return self::T_TRUE;
case 'false': return self::T_FALSE;
case '=':
return self::T_EQUALS;

case '\\':
return self::T_NAMESPACE_SEPARATOR;

case 'true':
return self::T_TRUE;

case 'false':
return self::T_FALSE;

default:
if (ctype_alpha($value[0]) || $value[0] === '_') {
return self::T_IDENTIFIER;
Expand All @@ -126,6 +145,7 @@ private function _getNumeric($value)
if ( ! is_scalar($value)) {
return false;
}

// Checking for valid numeric numbers: 1.234, -1.234e-2
if (is_numeric($value)) {
return $value;
Expand Down
10 changes: 6 additions & 4 deletions lib/Doctrine/Common/Annotations/Parser.php
Expand Up @@ -27,11 +27,11 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @version $Revision$
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
class Parser
{
Expand Down Expand Up @@ -173,9 +173,10 @@ private function syntaxError($expected, $token = null)
$message .= "'{$token['value']}' at position {$token['position']}";
}

if(strlen($this->_context)) {
$message .= ' in '.$this->_context;
if (strlen($this->_context)) {
$message .= ' in ' . $this->_context;
}

$message .= '.';

throw AnnotationException::syntaxError($message);
Expand Down Expand Up @@ -411,6 +412,7 @@ public function Arrayx()

foreach ($values as $value) {
list ($key, $val) = $value;

if ($key !== null) {
$array[$key] = $val;
} else {
Expand Down
22 changes: 4 additions & 18 deletions lib/Doctrine/DBAL/Configuration.php
@@ -1,7 +1,5 @@
<?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
Expand All @@ -21,15 +19,12 @@

namespace Doctrine\DBAL;

use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Logging\SQLLogger;

/**
* Configuration container for the Doctrine DBAL.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
Expand All @@ -46,22 +41,12 @@ class Configuration
*/
protected $_attributes = array();

/**
* Creates a new DBAL configuration instance.
*/
public function __construct()
{
$this->_attributes = array(
'sqlLogger' => null
);
}

/**
* Sets the SQL logger to use. Defaults to NULL which means SQL logging is disabled.
*
* @param SQLLogger $logger
*/
public function setSQLLogger($logger)
public function setSQLLogger(SQLLogger $logger)
{
$this->_attributes['sqlLogger'] = $logger;
}
Expand All @@ -73,6 +58,7 @@ public function setSQLLogger($logger)
*/
public function getSQLLogger()
{
return $this->_attributes['sqlLogger'];
return isset($this->_attributes['sqlLogger']) ?
$this->_attributes['sqlLogger'] : null;
}
}
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php
Expand Up @@ -78,7 +78,7 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
if (preg_match('/^select/i', $sql)) {
$resultSet = $conn->fetchAll($sql);
} else {
$resultSet = $em->getConnection()->executeUpdate($sql);
$resultSet = $conn->executeUpdate($sql);
}

\Doctrine\Common\Util\Debug::dump($resultSet, (int) $depth);
Expand Down

0 comments on commit 023f06a

Please sign in to comment.