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

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
Prepping for 2.2.0RC1.
  • Loading branch information
weierophinney committed May 1, 2013
201 parents c9c40bb + 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 + 8248c0b + 58d95bc + c9f0cd0 + 30eb247 + 6204c2f + c3855a9 + 4baf625 + dc26d92 + c989091 + bc6d8c5 + ec25337 + 6934141 commit 18f8ecc
Show file tree
Hide file tree
Showing 28 changed files with 421 additions and 63 deletions.
7 changes: 3 additions & 4 deletions src/ArrayObject/PhpLegacyCompatibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ abstract class PhpLegacyCompatibility extends PhpArrayObject
/**
* Constructor
*
* @param array $input
* @param int $flags
* @param string $iteratorClass
* @return ArrayObject
* @param array $input
* @param int $flags
* @param string $iteratorClass
*/
public function __construct($input = array(), $flags = self::STD_PROP_LIST, $iteratorClass = 'ArrayIterator')
{
Expand Down
11 changes: 5 additions & 6 deletions src/ArrayObject/PhpReferenceCompatibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,9 @@ abstract class PhpReferenceCompatibility implements IteratorAggregate, ArrayAcce
/**
* Constructor
*
* @param array $input
* @param int $flags
* @param string $iteratorClass
* @return ArrayObject
* @param array $input
* @param int $flags
* @param string $iteratorClass
*/
public function __construct($input = array(), $flags = self::STD_PROP_LIST, $iteratorClass = 'ArrayIterator')
{
Expand All @@ -76,7 +75,7 @@ public function __construct($input = array(), $flags = self::STD_PROP_LIST, $ite
* Returns whether the requested key exists
*
* @param mixed $key
* @return boolean
* @return bool
*/
public function __isset($key)
{
Expand Down Expand Up @@ -279,7 +278,7 @@ public function natsort()
* Returns whether the requested key exists
*
* @param mixed $key
* @return boolean
* @return bool
*/
public function offsetExists($key)
{
Expand Down
4 changes: 2 additions & 2 deletions src/ArrayUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ public static function hasNumericKeys($value, $allowEmpty = false)
*
* For example:
* <code>
* $list = array( 'a','b','c','d' );
* $list = array('a', 'b', 'c', 'd');
* $list = array(
* 0 => 'foo',
* 1 => 'bar',
* 2 => array( 'foo' => 'baz' ),
* 2 => array('foo' => 'baz'),
* );
* </code>
*
Expand Down
4 changes: 4 additions & 0 deletions src/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@

use DateTimeZone;

trigger_error('DateTime extension deprecated as of ZF 2.1.4; use the \DateTime constructor to parse extended ISO8601 dates instead', E_USER_DEPRECATED);

/**
* DateTime
*
* An extension of the \DateTime object.
*
* @deprecated
*/
class DateTime extends \DateTime
{
Expand Down
4 changes: 2 additions & 2 deletions src/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ abstract class ErrorHandler
/**
* Check if this error handler is active
*
* @return boolean
* @return bool
*/
public static function started()
{
Expand Down Expand Up @@ -109,7 +109,7 @@ public static function clean()
*/
public static function addError($errno, $errstr = '', $errfile = '', $errline = 0)
{
$stack = & static::$stack[ count(static::$stack) - 1 ];
$stack = & static::$stack[count(static::$stack) - 1];
$stack = new ErrorException($errstr, 0, $errno, $errfile, $errline, $stack);
}
}
34 changes: 23 additions & 11 deletions src/Glob.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

namespace Zend\Stdlib;

use Zend\Stdlib\Exception;
use Zend\Stdlib\ErrorHandler;

/**
* Wrapper for glob with fallback if GLOB_BRACE is not available.
*/
Expand All @@ -31,11 +34,12 @@ abstract class Glob
*
* @see http://docs.php.net/glob
* @param string $pattern
* @param integer $flags
* @param int $flags
* @param bool $forceFallback
* @return array|false
* @return array
* @throws Exception\RuntimeException
*/
public static function glob($pattern, $flags, $forceFallback = false)
public static function glob($pattern, $flags = 0, $forceFallback = false)
{
if (!defined('GLOB_BRACE') || $forceFallback) {
return static::fallbackGlob($pattern, $flags);
Expand All @@ -48,8 +52,9 @@ public static function glob($pattern, $flags, $forceFallback = false)
* Use the glob function provided by the system.
*
* @param string $pattern
* @param integer $flags
* @return array|false
* @param int $flags
* @return array
* @throws Exception\RuntimeException
*/
protected static function systemGlob($pattern, $flags)
{
Expand All @@ -75,15 +80,22 @@ protected static function systemGlob($pattern, $flags)
$globFlags = 0;
}

return glob($pattern, $globFlags);
ErrorHandler::start();
$res = glob($pattern, $globFlags);
$err = ErrorHandler::stop();
if ($res === false) {
throw new Exception\RuntimeException("glob('{$pattern}', {$globFlags}) failed", 0, $err);
}
return $res;
}

/**
* Expand braces manually, then use the system glob.
*
* @param string $pattern
* @param integer $flags
* @return array|false
* @param int $flags
* @return array
* @throws Exception\RuntimeException
*/
protected static function fallbackGlob($pattern, $flags)
{
Expand Down Expand Up @@ -162,9 +174,9 @@ protected static function fallbackGlob($pattern, $flags)
* Find the end of the sub-pattern in a brace expression.
*
* @param string $pattern
* @param integer $begin
* @param integer $flags
* @return integer|null
* @param int $begin
* @param int $flags
* @return int|null
*/
protected static function nextBraceSub($pattern, $begin, $flags)
{
Expand Down
14 changes: 8 additions & 6 deletions src/Hydrator/AbstractHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,16 @@ public function removeStrategy($name)
/**
* Converts a value for extraction. If no strategy exists the plain value is returned.
*
* @param string $name The name of the strategy to use.
* @param mixed $value The value that should be converted.
* @param string $name The name of the strategy to use.
* @param mixed $value The value that should be converted.
* @param array $object The object is optionally provided as context.
* @return mixed
*/
public function extractValue($name, $value)
public function extractValue($name, $value, $object = null)
{
if ($this->hasStrategy($name)) {
$strategy = $this->getStrategy($name);
$value = $strategy->extract($value);
$value = $strategy->extract($value, $object);
}
return $value;
}
Expand All @@ -120,13 +121,14 @@ public function extractValue($name, $value)
*
* @param string $name The name of the strategy to use.
* @param mixed $value The value that should be converted.
* @param array $data The whole data is optionally provided as context.
* @return mixed
*/
public function hydrateValue($name, $value)
public function hydrateValue($name, $value, $data = null)
{
if ($this->hasStrategy($name)) {
$strategy = $this->getStrategy($name);
$value = $strategy->hydrate($value);
$value = $strategy->hydrate($value, $data);
}
return $value;
}
Expand Down
16 changes: 8 additions & 8 deletions src/Hydrator/ClassMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
use Zend\Stdlib\ArrayUtils;
use Zend\Stdlib\Hydrator\Filter\FilterComposite;
use Zend\Stdlib\Hydrator\Filter\FilterProviderInterface;
use Zend\Stdlib\Hydrator\Filter\MethodMatchFilter;
use Zend\Stdlib\Hydrator\Filter\GetFilter;
use Zend\Stdlib\Hydrator\Filter\HasFilter;
use Zend\Stdlib\Hydrator\Filter\IsFilter;
use Zend\Stdlib\Hydrator\Filter\MethodMatchFilter;
use Zend\Stdlib\Hydrator\Filter\NumberOfParameterFilter;

class ClassMethods extends AbstractHydrator implements HydratorOptionsInterface
Expand Down Expand Up @@ -66,7 +66,7 @@ public function setOptions($options)
}

/**
* @param boolean $underscoreSeparatedKeys
* @param bool $underscoreSeparatedKeys
* @return ClassMethods
*/
public function setUnderscoreSeparatedKeys($underscoreSeparatedKeys)
Expand All @@ -77,7 +77,7 @@ public function setUnderscoreSeparatedKeys($underscoreSeparatedKeys)
}

/**
* @return boolean
* @return bool
*/
public function getUnderscoreSeparatedKeys()
{
Expand Down Expand Up @@ -136,13 +136,15 @@ public function extract($object)
$attribute = $method;
if (preg_match('/^get/', $method)) {
$attribute = substr($method, 3);
$attribute = lcfirst($attribute);
if (!property_exists($object, $attribute)) {
$attribute = lcfirst($attribute);
}
}

if ($this->underscoreSeparatedKeys) {
$attribute = preg_replace_callback('/([A-Z])/', $transform, $attribute);
}
$attributes[$attribute] = $this->extractValue($attribute, $object->$method());
$attributes[$attribute] = $this->extractValue($attribute, $object->$method(), $object);
}

return $attributes;
Expand Down Expand Up @@ -178,13 +180,11 @@ public function hydrate(array $data, $object)
$method = preg_replace_callback('/(_[a-z])/', $transform, $method);
}
if (is_callable(array($object, $method))) {
$value = $this->hydrateValue($property, $value);

$value = $this->hydrateValue($property, $value, $data);
$object->$method($value);
}
}

return $object;
}

}
6 changes: 3 additions & 3 deletions src/Hydrator/Filter/FilterComposite.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function($value, $key) {
*/
public function addFilter($name, $filter, $condition = self::CONDITION_OR)
{
if ( !is_callable($filter) && !($filter instanceof FilterInterface) ) {
if (!is_callable($filter) && !($filter instanceof FilterInterface)) {
throw new InvalidArgumentException(
'The value of ' . $name . ' should be either a callable or ' .
'an instance of Zend\Stdlib\Hydrator\Filter\FilterInterface'
Expand Down Expand Up @@ -166,13 +166,13 @@ public function filter($property)
// Check if 1 from the or filters return true
foreach ($this->orFilter as $filter) {
if (is_callable($filter)) {
if ( $filter($property) === true) {
if ($filter($property) === true) {
$returnValue = true;
break;
}
continue;
} else {
if ( $filter->filter($property) === true) {
if ($filter->filter($property) === true) {
$returnValue = true;
break;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Hydrator/Filter/NumberOfParameterFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

namespace Zend\Stdlib\Hydrator\Filter;

use ReflectionMethod;
use ReflectionException;
use ReflectionMethod;
use Zend\Stdlib\Exception\InvalidArgumentException;
use Zend\Stdlib\Hydrator\Filter\FilterInterface;

Expand Down Expand Up @@ -39,7 +39,7 @@ public function filter($property)
{
try {
$reflectionMethod = new ReflectionMethod($property);
} catch( ReflectionException $exception) {
} catch (ReflectionException $exception) {
throw new InvalidArgumentException(
"Method $property doesn't exist"
);
Expand Down
28 changes: 28 additions & 0 deletions src/Hydrator/HydratorAwareInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?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 Zend\Stdlib\Hydrator;

interface HydratorAwareInterface
{
/**
* Set hydrator
*
* @param HydratorInterface $hydrator
* @return HydratorAwareInterface
*/
public function setHydrator(HydratorInterface $hydrator);

/**
* Retrieve hydrator
*
* @return HydratorInterface
*/
public function getHydrator();
}
Loading

0 comments on commit 18f8ecc

Please sign in to comment.