Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' into ValidatorMessages
Browse files Browse the repository at this point in the history
  • Loading branch information
Matej Szendi committed Nov 4, 2013
200 parents c9418a6 + fdeb27b + c382628 + ee15e76 + 5f29760 + 714d1a8 + 84b0297 + cbc5f03 + 76361f8 + e7209df + 87630e0 + df43daf + f7d6cbb + 7e2b798 + 3ed1ead + 87505b6 + c229265 + eb61c8f + efcb00e + 0a0842f + b6d0c88 + 7edee62 + 60ea64c + a08bcca + b40ec3e + 63172ed + 448f428 + 92a516a + 5ecbc99 + a2df21b + 4de87f2 + 7c259ec + a22bdcb + 084ad9f + 9414e5a + 489be93 + cb39e7e + 54a28dc + c9c769e + dda791d + 70d382a + 8bbad0e + 9321185 + 7ab35a6 + b93694e + 3ea7087 + 0fe3d3a + bd5e189 + d1cba17 + 8d75392 + 3fb5b55 + 6cb0ccb + 30aa565 + 8409977 + 8074ba0 + 8f92486 + 94860d1 + 05d33c4 + 425826b + f0e91f0 + e31468f + 7d2af87 + 2e4dc80 + 19d128f + 1b9e4b2 + 1c46483 + fdda3f2 + 595fcd1 + 213395c + 8e514a8 + 2f30186 + bb4ed65 + 132d5b6 + 030ff33 + f2f20f3 + a50e133 + 4c554ee + dbfb1b8 + ccab83f + 00b350f + 78945d0 + f0e5f4b + ceb7d8c + 9e124d1 + 3de5912 + b6a974a + 10a6438 + cb6c1e7 + 18afd6c + 3baf1bd + c800904 + f52dcb8 + 126ccb2 + e7d6206 + e2d24ab + ec1abfc + 290ea90 + 9f4ca1b + edaa760 + c4c0c95 + d21f055 + 5b18029 + e6b97af + 010fb36 + 64c7b8d + 636523e + 4cc2cd6 + e34098a + 16367cd + 943c77f + 8226e5b + 0b47726 + 3cd8a03 + cc4782c + 9c653a6 + 656dbe5 + 9bce1ba + 7dc18ca + 861130d + 2d2ffbd + 4f413a5 + 2e1067a + 1d082e4 + e8aeb79 + b562091 + ff2fdc3 + 4aa72c0 + 1bb67ac + cd015c8 + 5e89910 + 0c21258 + dd54faf + 57f9063 + b88ce2e + af68643 + 06cd3b4 + 2c71b71 + ee02c35 + 9456314 + 5a77a7b + e98a077 + 738f2e6 + cb1e63c + 736df07 + d0a0154 + 990523c + 78687de + a5b6e79 + 6e9dfe9 + e201a1c + d9b45ef + 76222ad + 16d67da + 1ab2258 + b81d711 + ed2e9bc + 61efe82 + f353ea5 + 1f02519 + 58c1fe8 + ed502d9 + 2defba6 + 4885013 + 06a8384 + 17d9eed + 3b21b5d + c62101c + 909ef34 + 13d376a + 8a75367 + 98a3cf5 + 270f2c4 + 3038cfa + 1112202 + c8fb359 + 8d37cd0 + 4d868a7 + 555cb91 + 7ac5858 + 8103f1f + 9fe9c96 + a3ecac6 + 10e77c1 + e0d3e13 + 19ad608 + e0d665c + 1a5b402 + 56ae12a + 9073fc1 + 2d5b32f + a8e6198 + 83e8f34 + 30eb247 + 6204c2f + c3855a9 + 543aa17 + 3750c0c + 29ea285 + d0aa8c2 + ce5f388 commit fab8999
Show file tree
Hide file tree
Showing 61 changed files with 127 additions and 153 deletions.
9 changes: 3 additions & 6 deletions src/DispatchableInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@

namespace Zend\Stdlib;

use Zend\Stdlib\RequestInterface as Request;
use Zend\Stdlib\ResponseInterface as Response;

interface DispatchableInterface
{
/**
* Dispatch a request
*
* @param Request $request
* @param null|Response $response
* @param RequestInterface $request
* @param null|ResponseInterface $response
* @return Response|mixed
*/
public function dispatch(Request $request, Response $response = null);
public function dispatch(RequestInterface $request, ResponseInterface $response = null);
}
2 changes: 1 addition & 1 deletion src/Hydrator/AbstractHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function getFilter()
*
* <code>
* $composite->addFilter("servicelocator",
* function($property) {
* function ($property) {
* list($class, $method) = explode('::', $property);
* if ($method === 'getServiceLocator') {
* return false;
Expand Down
2 changes: 1 addition & 1 deletion src/Hydrator/ClassMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public function hydrate(array $data, $object)
foreach ($data as $property => $value) {
$method = 'set' . ucfirst($property);
if ($this->underscoreSeparatedKeys) {
$method = preg_replace_callback('/(_[a-z])/', $transform, $method);
$method = preg_replace_callback('/(_[a-z])/i', $transform, $method);
}
if (is_callable(array($object, $method))) {
$value = $this->hydrateValue($property, $value, $data);
Expand Down
6 changes: 3 additions & 3 deletions src/Hydrator/Filter/FilterComposite.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class FilterComposite implements FilterInterface
public function __construct($orFilter = array(), $andFilter = array())
{
array_walk($orFilter,
function($value, $key) {
function ($value, $key) {
if (
!is_callable($value)
&& !$value instanceof FilterInterface
Expand All @@ -55,7 +55,7 @@ function($value, $key) {
);

array_walk($andFilter,
function($value, $key) {
function ($value, $key) {
if (
!is_callable($value)
&& !$value instanceof FilterInterface
Expand All @@ -79,7 +79,7 @@ function($value, $key) {
* This example will exclude all methods from the hydration, that starts with 'getService'
* <code>
* $composite->addFilter('exclude',
* function($method) {
* function ($method) {
* if (preg_match('/^getService/', $method) {
* return false;
* }
Expand Down
6 changes: 3 additions & 3 deletions src/Hydrator/Filter/OptionalParametersFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class OptionalParametersFilter implements FilterInterface
*/
public function filter($property)
{
if (isset(self::$propertiesCache[$property])) {
return self::$propertiesCache[$property];
if (isset(static::$propertiesCache[$property])) {
return static::$propertiesCache[$property];
}

try {
Expand All @@ -49,6 +49,6 @@ function (ReflectionParameter $parameter) {
}
);

return self::$propertiesCache[$property] = empty($mandatoryParameters);
return static::$propertiesCache[$property] = empty($mandatoryParameters);
}
}
20 changes: 11 additions & 9 deletions src/Hydrator/Reflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ public function hydrate(array $data, $object)
* Get a reflection properties from in-memory cache and lazy-load if
* class has not been loaded.
*
* @static
* @param string|object $input
* @param string|object $input
* @throws Exception\InvalidArgumentException
* @return array
*/
Expand All @@ -77,14 +76,17 @@ protected static function getReflProperties($input)
throw new Exception\InvalidArgumentException('Input must be a string or an object.');
}

if (!isset(static::$reflProperties[$input])) {
$reflClass = new ReflectionClass($input);
$reflProperties = $reflClass->getProperties();
if (isset(static::$reflProperties[$input])) {
return static::$reflProperties[$input];
}

foreach ($reflProperties as $property) {
$property->setAccessible(true);
static::$reflProperties[$input][$property->getName()] = $property;
}
static::$reflProperties[$input] = array();
$reflClass = new ReflectionClass($input);
$reflProperties = $reflClass->getProperties();

foreach ($reflProperties as $property) {
$property->setAccessible(true);
static::$reflProperties[$input][$property->getName()] = $property;
}

return static::$reflProperties[$input];
Expand Down
16 changes: 8 additions & 8 deletions src/Hydrator/Strategy/ClosureStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ClosureStrategy implements StrategyInterface
{
/**
* Function, used in extract method, default:
* function($value) {
* function ($value) {
* return $value;
* };
* @var callable
Expand All @@ -22,7 +22,7 @@ class ClosureStrategy implements StrategyInterface

/**
* Function, used in hydrate method, default:
* function($value) {
* function ($value) {
* return $value;
* };
* @var callable
Expand All @@ -32,11 +32,11 @@ class ClosureStrategy implements StrategyInterface
/**
* You can describe how your values will extract and hydrate, like this:
* $hydrator->addStrategy('category', new ClosureStrategy(
* function(Category $value) {
* return (int)$value->id;
* function (Category $value) {
* return (int) $value->id;
* },
* function($value) {
* return new Category((int)$value);
* function ($value) {
* return new Category((int) $value);
* }
* ));
*
Expand All @@ -54,7 +54,7 @@ public function __construct($extractFunc = null, $hydrateFunc = null)

$this->extractFunc = $extractFunc;
} else {
$this->extractFunc = function($value) {
$this->extractFunc = function ($value) {
return $value;
};
}
Expand All @@ -66,7 +66,7 @@ public function __construct($extractFunc = null, $hydrateFunc = null)

$this->hydrateFunc = $hydrateFunc;
} else {
$this->hydrateFunc = function($value) {
$this->hydrateFunc = function ($value) {
return $value;
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/PriorityQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,15 +271,15 @@ public function hasPriority($priority)
/**
* Get the inner priority queue instance
*
* @throws \DomainException
* @throws Exception\DomainException
* @return SplPriorityQueue
*/
protected function getQueue()
{
if (null === $this->queue) {
$this->queue = new $this->queueClass();
if (!$this->queue instanceof \SplPriorityQueue) {
throw new \DomainException(sprintf(
throw new Exception\DomainException(sprintf(
'PriorityQueue expects an internal queue of type SplPriorityQueue; received "%s"',
get_class($this->queue)
));
Expand Down
1 change: 0 additions & 1 deletion test/ArrayObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Stdlib
*/

namespace ZendTest\Stdlib;
Expand Down
1 change: 0 additions & 1 deletion test/ArrayUtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Stdlib
*/

namespace ZendTest\Stdlib;
Expand Down
4 changes: 0 additions & 4 deletions test/CallbackHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Stdlib
*/

namespace ZendTest\Stdlib;

use Zend\Stdlib\CallbackHandler;

/**
* @category Zend
* @package Zend_Stdlib
* @subpackage UnitTests
* @group Zend_Stdlib
*/
class CallbackHandlerTest extends \PHPUnit_Framework_TestCase
Expand Down
4 changes: 0 additions & 4 deletions test/DateTimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Stdlib
*/

namespace ZendTest\Stdlib;

use Zend\Stdlib\DateTime;

/**
* @category Zend
* @package Zend_Stdlib
* @subpackage UnitTests
* @group Zend_Stdlib
*/
class DateTimeTest extends \PHPUnit_Framework_TestCase
Expand Down
1 change: 0 additions & 1 deletion test/ErrorHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Stdlib
*/

namespace ZendTest\Stdlib;
Expand Down
1 change: 0 additions & 1 deletion test/FilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Service
*/

namespace ZendTest\Stdlib;
Expand Down
1 change: 0 additions & 1 deletion test/GlobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Stdlib
*/

namespace ZendTest\Stdlib;
Expand Down
47 changes: 47 additions & 0 deletions test/Hydrator/ReflectionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace ZendTest\Stdlib\Hydrator;

use stdClass;
use Zend\Stdlib\Hydrator\Reflection;

/**
* Unit tests for {@see \Zend\Stdlib\Hydrator\Reflection}
*
* @covers \Zend\Stdlib\Hydrator\Reflection
* @group Zend_Stdlib
*/
class ReflectionTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Reflection
*/
protected $hydrator;

/**
* {@inheritDoc}
*/
public function setUp()
{
$this->hydrator = new Reflection();
}

public function testCanExtract()
{
$this->assertSame(array(), $this->hydrator->extract(new stdClass()));
}

public function testCanHydrate()
{
$object = new stdClass();

$this->assertSame($object, $this->hydrator->hydrate(array('foo' => 'bar'), $object));
}
}
16 changes: 6 additions & 10 deletions test/HydratorClosureStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Stdlib
*/

namespace ZendTest\Stdlib;
Expand All @@ -14,9 +13,6 @@
use Zend\Stdlib\Hydrator\Strategy\ClosureStrategy;

/**
* @category Zend
* @package Zend_Stdlib
* @subpackage UnitTests
* @group Zend_Stdlib
*/
class HydratorClosureStrategyTest extends \PHPUnit_Framework_TestCase
Expand Down Expand Up @@ -77,13 +73,13 @@ public function testRetrieveStrategy()
public function testExtractingObjects()
{
$this->hydrator->addStrategy('field1', new ClosureStrategy(
function($value) {
function ($value) {
return sprintf('%s', $value);
},
null
));
$this->hydrator->addStrategy('field2', new ClosureStrategy(
function($value) {
function ($value) {
return sprintf('hello, %s!', $value);
},
null
Expand All @@ -100,13 +96,13 @@ public function testHydratingObjects()
{
$this->hydrator->addStrategy('field2', new ClosureStrategy(
null,
function($value) {
function ($value) {
return sprintf('hello, %s!', $value);
}
));
$this->hydrator->addStrategy('field3', new ClosureStrategy(
null,
function($value) {
function ($value) {
return new TestAsset\HydratorClosureStrategyEntity($value, sprintf('111%s', $value));
}
));
Expand All @@ -116,9 +112,9 @@ function($value) {
$values = $this->hydrator->extract($entity);
$values['field3'] = 333;

$this->assertCount(2, (array)$entity);
$this->assertCount(2, (array) $entity);
$this->hydrator->hydrate($values, $entity);
$this->assertCount(3, (array)$entity);
$this->assertCount(3, (array) $entity);

$this->assertInstanceOf('ZendTest\Stdlib\TestAsset\HydratorClosureStrategyEntity', $entity->field3);
}
Expand Down
1 change: 0 additions & 1 deletion test/HydratorObjectPropertyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Stdlib
*/

namespace ZendTest\Stdlib;
Expand Down
Loading

0 comments on commit fab8999

Please sign in to comment.