Skip to content

Commit

Permalink
Merge branch 'hotfix/zf-11311' of https://github.com/Intiilapa/zf2 in…
Browse files Browse the repository at this point in the history
…to hotfix/zf-11311
  • Loading branch information
weierophinney committed May 20, 2011
2 parents 5b66173 + bf0ad21 commit fae0b45
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,28 @@
*
* @category Zend
* @package Zend_Server
* @subpackage Zend_Server_Reflection
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Server\Reflection;
namespace Zend\Server;

use Zend\Server\Reflection\ReflectionClass,
Zend\Server\Reflection\ReflectionFunction;

/**
* Reflection for determining method signatures to use with server classes
*
* @uses ReflectionClass
* @uses ReflectionObject
* @uses \Zend\Server\Reflection\ClassReflection
* @uses \Zend\Server\Reflection\ReflectionClass
* @uses \Zend\Server\Reflection\Exception
* @uses \Zend\Server\Reflection\FunctionReflection
* @uses \Zend\Server\Reflection\ReflectionFunction
* @category Zend
* @package Zend_Server
* @subpackage Zend_Server_Reflection
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
Expand Down Expand Up @@ -64,11 +65,11 @@ public static function reflectClass($class, $argv = false, $namespace = '')
} elseif (class_exists($class)) {
$reflection = new \ReflectionClass($class);
} else {
throw new Exception\InvalidArgumentException('Invalid class or object passed to attachClass()');
throw new Reflection\Exception\InvalidArgumentException('Invalid class or object passed to attachClass()');
}

if ($argv && !is_array($argv)) {
throw new Exception\InvalidArgumentException('Invalid argv argument passed to reflectClass');
throw new Reflection\Exception\InvalidArgumentException('Invalid argv argument passed to reflectClass');
}

return new ReflectionClass($reflection, $namespace, $argv);
Expand All @@ -94,12 +95,11 @@ public static function reflectClass($class, $argv = false, $namespace = '')
public static function reflectFunction($function, $argv = false, $namespace = '')
{
if (!is_string($function) || !function_exists($function)) {
throw new Exception\InvalidArgumentException('Invalid function "' . $function . '" passed to reflectFunction');
throw new Reflection\Exception\InvalidArgumentException('Invalid function "' . $function . '" passed to reflectFunction');
}


if ($argv && !is_array($argv)) {
throw new Exception\InvalidArgumentException('Invalid argv argument passed to reflectClass');
throw new Reflection\Exception\InvalidArgumentException('Invalid argv argument passed to reflectClass');
}

return new ReflectionFunction(new \ReflectionFunction($function), $namespace, $argv);
Expand Down
7 changes: 4 additions & 3 deletions tests/Zend/Server/Reflection/PrototypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* @namespace
*/
namespace ZendTest\Server\Reflection;

use Zend\Server\Reflection;

/**
Expand Down Expand Up @@ -60,7 +61,7 @@ class PrototypeTest extends \PHPUnit_Framework_TestCase
*/
public function setUp()
{
$class = new \ReflectionClass('\Zend\Server\Reflection\Reflection');
$class = new \ReflectionClass('\Zend\Server\Reflection');
$method = $class->getMethod('reflectClass');
$parameters = $method->getParameters();
$this->_parametersRaw = $parameters;
Expand Down Expand Up @@ -99,7 +100,7 @@ public function testConstructWorks()
{
$this->assertTrue($this->_r instanceof Reflection\Prototype);
}

public function testConstructionThrowsExceptionOnInvalidParam()
{
$this->setExpectedException('Zend\Server\Reflection\Exception\InvalidArgumentException', 'One or more params are invalid');
Expand All @@ -111,7 +112,7 @@ public function testConstructionThrowsExceptionOnInvalidParamType()
$this->setExpectedException('Zend\Server\Reflection\Exception\InvalidArgumentException', 'Invalid parameters');
$r1 = new Reflection\Prototype($this->_r->getReturnValue(), 'string');
}

/**
* getReturnType() test
*
Expand Down
17 changes: 9 additions & 8 deletions tests/Zend/Server/Reflection/ReflectionClassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* @namespace
*/
namespace ZendTest\Server\Reflection;

use Zend\Server\Reflection;

/**
Expand Down Expand Up @@ -51,7 +52,7 @@ class ReflectionClassTest extends \PHPUnit_Framework_TestCase
*/
public function test__construct()
{
$r = new Reflection\ReflectionClass(new \ReflectionClass('\Zend\Server\Reflection\Reflection'));
$r = new Reflection\ReflectionClass(new \ReflectionClass('\Zend\Server\Reflection'));
$this->assertTrue($r instanceof Reflection\ReflectionClass);
$this->assertEquals('', $r->getNamespace());

Expand All @@ -61,7 +62,7 @@ public function test__construct()
$this->assertTrue($m instanceof Reflection\ReflectionMethod);
}

$r = new Reflection\ReflectionClass(new \ReflectionClass('\Zend\Server\Reflection\Reflection'), 'namespace');
$r = new Reflection\ReflectionClass(new \ReflectionClass('\Zend\Server\Reflection'), 'namespace');
$this->assertEquals('namespace', $r->getNamespace());
}

Expand All @@ -78,17 +79,17 @@ public function test__construct()
*/
public function test__call()
{
$r = new Reflection\ReflectionClass(new \ReflectionClass('\Zend\Server\Reflection\Reflection'));
$r = new Reflection\ReflectionClass(new \ReflectionClass('\Zend\Server\Reflection'));
$this->assertTrue(is_string($r->getName()));
$this->assertEquals('Zend\Server\Reflection\Reflection', $r->getName());
$this->assertEquals('Zend\Server\Reflection', $r->getName());
}

/**
* test __get/set
*/
public function testGetSet()
{
$r = new Reflection\ReflectionClass(new \ReflectionClass('\Zend\Server\Reflection\Reflection'));
$r = new Reflection\ReflectionClass(new \ReflectionClass('\Zend\Server\Reflection'));
$r->system = true;
$this->assertTrue($r->system);
}
Expand All @@ -102,7 +103,7 @@ public function testGetSet()
*/
public function testGetMethods()
{
$r = new Reflection\ReflectionClass(new \ReflectionClass('\Zend\Server\Reflection\Reflection'));
$r = new Reflection\ReflectionClass(new \ReflectionClass('\Zend\Server\Reflection'));

$methods = $r->getMethods();
$this->assertTrue(is_array($methods));
Expand All @@ -116,7 +117,7 @@ public function testGetMethods()
*/
public function testGetNamespace()
{
$r = new Reflection\ReflectionClass(new \ReflectionClass('\Zend\Server\Reflection\Reflection'));
$r = new Reflection\ReflectionClass(new \ReflectionClass('\Zend\Server\Reflection'));
$this->assertEquals('', $r->getNamespace());
$r->setNamespace('namespace');
$this->assertEquals('namespace', $r->getNamespace());
Expand All @@ -131,7 +132,7 @@ public function testGetNamespace()
*/
public function test__wakeup()
{
$r = new Reflection\ReflectionClass(new \ReflectionClass('\Zend\Server\Reflection\Reflection'));
$r = new Reflection\ReflectionClass(new \ReflectionClass('\Zend\Server\Reflection'));
$s = serialize($r);
$u = unserialize($s);

Expand Down
5 changes: 2 additions & 3 deletions tests/Zend/Server/Reflection/ReflectionMethodTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* @namespace
*/
namespace ZendTest\Server\Reflection;

use Zend\Server\Reflection;

/**
Expand All @@ -43,7 +44,7 @@ class ReflectionMethodTest extends \PHPUnit_Framework_TestCase

protected function setUp()
{
$this->_classRaw = new \ReflectionClass('\Zend\Server\Reflection\Reflection');
$this->_classRaw = new \ReflectionClass('\Zend\Server\Reflection');
$this->_method = $this->_classRaw->getMethod('reflectClass');
$this->_class = new Reflection\ReflectionClass($this->_classRaw);
}
Expand Down Expand Up @@ -106,6 +107,4 @@ public function test__wakeup()
$this->assertEquals($r->getName(), $u->getName());
$this->assertEquals($r->getDeclaringClass()->getName(), $u->getDeclaringClass()->getName());
}


}
23 changes: 12 additions & 11 deletions tests/Zend/Server/ReflectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* @namespace
*/
namespace ZendTest\Server;

use Zend\Server\Reflection;

/**
Expand All @@ -42,25 +43,25 @@ class ReflectionTest extends \PHPUnit_Framework_TestCase
*/
public function testReflectClass()
{
$reflection = Reflection\Reflection::reflectClass('ZendTest\Server\ReflectionTestClass');
$reflection = Reflection::reflectClass('ZendTest\Server\ReflectionTestClass');
$this->assertTrue($reflection instanceof Reflection\ReflectionClass);

$reflection = Reflection\Reflection::reflectClass(new ReflectionTestClass());
$reflection = Reflection::reflectClass(new ReflectionTestClass());
$this->assertTrue($reflection instanceof Reflection\ReflectionClass);
}

public function testReflectClassThrowsExceptionOnInvalidClass()
{
$this->setExpectedException('Zend\Server\Reflection\Exception\InvalidArgumentException', 'Invalid argv argument passed to reflectClass');
$reflection = Reflection\Reflection::reflectClass('ZendTest\Server\ReflectionTestClass', 'string');
$reflection = Reflection::reflectClass('ZendTest\Server\ReflectionTestClass', 'string');
}

public function testReflectClassThrowsExceptionOnInvalidParameter()
{
$this->setExpectedException('Zend\Server\Reflection\Exception\InvalidArgumentException', 'Invalid class or object passed to attachClass');
$reflection = Reflection\Reflection::reflectClass(false);
$reflection = Reflection::reflectClass(false);
}

/**
* reflectClass() test; test namespaces
*/
Expand All @@ -75,22 +76,22 @@ public function testReflectClass2()
*/
public function testReflectFunction()
{
$reflection = Reflection\Reflection::reflectFunction('ZendTest\Server\reflectionTestFunction');
$reflection = Reflection::reflectFunction('ZendTest\Server\reflectionTestFunction');
$this->assertTrue($reflection instanceof Reflection\ReflectionFunction);
}

public function testReflectFunctionThrowsExceptionOnInvalidFunction()
{
$this->setExpectedException('Zend\Server\Reflection\Exception\InvalidArgumentException', 'Invalid function');
$reflection = Reflection\Reflection::reflectFunction('ZendTest\Server\reflectionTestClass', 'string');
$reflection = Reflection::reflectFunction('ZendTest\Server\ReflectionTestClass', 'string');
}

public function testReflectFunctionThrowsExceptionOnInvalidParam()
{
$this->setExpectedException('Zend\Server\Reflection\Exception\InvalidArgumentException', 'Invalid function');
$reflection = Reflection\Reflection::reflectFunction(false);
$reflection = Reflection::reflectFunction(false);
}

/**
* reflectFunction() test; test namespaces
*/
Expand Down

0 comments on commit fae0b45

Please sign in to comment.