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 feature/db-story-35
Browse files Browse the repository at this point in the history
Conflicts:
	library/Zend/Db/Sql/Exception/RuntimeException.php
  • Loading branch information
Show file tree
Hide file tree
Showing 28 changed files with 305 additions and 59 deletions.
7 changes: 0 additions & 7 deletions src/Dispatchable.php

This file was deleted.

10 changes: 10 additions & 0 deletions src/DispatchableInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace Zend\Stdlib;

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

interface DispatchableInterface
{
public function dispatch(Request $request, Response $response = null);
}
7 changes: 0 additions & 7 deletions src/Exception.php

This file was deleted.

7 changes: 3 additions & 4 deletions src/Exception/BadMethodCallException.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

namespace Zend\Stdlib\Exception;

use Zend\Stdlib\Exception;

/**
* Bad method call exception
*
Expand All @@ -30,7 +28,8 @@
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class BadMethodCallException extends \BadMethodCallException
implements Exception
class BadMethodCallException
extends \BadMethodCallException
implements ExceptionInterface
{
}
6 changes: 3 additions & 3 deletions src/Exception/DomainException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Zend\Stdlib\Exception;

use Zend\Stdlib\Exception;

class DomainException extends \DomainException implements Exception
class DomainException
extends \DomainException
implements ExceptionInterface
{
}
7 changes: 7 additions & 0 deletions src/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Zend\Stdlib\Exception;

interface ExceptionInterface
{
}
8 changes: 3 additions & 5 deletions src/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

namespace Zend\Stdlib\Exception;

use Zend\Stdlib\Exception;

class InvalidArgumentException
extends \InvalidArgumentException
implements Exception
class InvalidArgumentException
extends \InvalidArgumentException
implements ExceptionInterface
{
}
8 changes: 2 additions & 6 deletions src/Exception/InvalidCallbackException.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,16 @@

namespace Zend\Stdlib\Exception;

use Zend\Stdlib\Exception;

/**
* Invalid callback exception
*
* @uses Exception
* @uses Zend\Stdlib\Exception
* @category Zend
* @package Zend_Stdlib
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class InvalidCallbackException
extends DomainException
implements Exception
extends \DomainException
implements ExceptionInterface
{
}
6 changes: 3 additions & 3 deletions src/Exception/LogicException.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

namespace Zend\Stdlib\Exception;

use Zend\Stdlib\Exception;

/**
* logic exception
*
Expand All @@ -30,6 +28,8 @@
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class LogicException extends \LogicException implements Exception
class LogicException
extends \LogicException
implements ExceptionInterface
{
}
209 changes: 209 additions & 0 deletions src/Glob.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Stdlib
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\Stdlib;

/**
* Wrapper for glob with fallback if GLOB_BRACE is not available.
*
* @category Zend
* @package Zend_Stdlib
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Glob
{
/**#@+
* Glob constants.
*/
const GLOB_MARK = 0x01;
const GLOB_NOSORT = 0x02;
const GLOB_NOCHECK = 0x04;
const GLOB_NOESCAPE = 0x08;
const GLOB_BRACE = 0x10;
const GLOB_ONLYDIR = 0x20;
const GLOB_ERR = 0x30;
/**#@-*/

/**
* Find pathnames matching a pattern.
*
* @see http://docs.php.net/glob
* @param string $pattern
* @param integer $flags
* @param boolean $forceFallback
* @return array|false
*/
public static function glob($pattern, $flags, $forceFallback = false)
{
if (!defined('GLOB_BRACE') || $forceFallback) {
return self::fallbackGlob($pattern, $flags);
} else {
return self::systemGlob($pattern, $flags);
}
}

/**
* Use the glob function provided by the system.
*
* @param string $pattern
* @param integer $flags
* @return array|false
*/
protected static function systemGlob($pattern, $flags)
{
if ($flags) {
$flagMap = array(
self::GLOB_MARK => GLOB_MARK,
self::GLOB_NOSORT => GLOB_NOSORT,
self::GLOB_NOCHECK => GLOB_NOCHECK,
self::GLOB_NOESCAPE => GLOB_NOESCAPE,
self::GLOB_BRACE => GLOB_BRACE,
self::GLOB_ONLYDIR => GLOB_ONLYDIR,
self::GLOB_ERR => GLOB_ERR,
);

$globFlags = 0;

foreach ($flagMap as $internalFlag => $globFlag) {
if ($flags & $internalFlag) {
$globFlags |= $globFlag;
}
}
} else {
$globFlags = 0;
}

return glob($pattern, $globFlags);
}

/**
* Expand braces manually, then use the system glob.
*
* @param string $pattern
* @param integer $flags
* @return array|false
*/
protected static function fallbackGlob($pattern, $flags)
{
if (!$flags & self::GLOB_BRACE) {
return self::systemGlob($pattern, $flags);
}

$flags &= ~self::GLOB_BRACE;
$length = strlen($pattern);
$paths = array();

if ($flags & self::GLOB_NOESCAPE) {
$begin = strpos($pattern, '{');
} else {
$begin = 0;

while (true) {
if ($begin === $length) {
$begin = false;
break;
} else if ($pattern[$begin] === '\\' && ($begin + 1) < $length) {
$begin++;
} else if ($pattern[$begin] === '{') {
break;
}

$begin++;
}
}

if ($begin === false) {
return self::systemGlob($pattern, $flags);
}

$next = self::nextBraceSub($pattern, $begin + 1, $flags);

if ($next === null) {
return self::systemGlob($pattern, $flags);
}

$rest = $next;

while ($pattern[$rest] !== '}') {
$rest = self::nextBraceSub($pattern, $rest + 1, $flags);

if ($rest === null) {
return self::systemGlob($pattern, $flags);
}
}

$p = $begin + 1;

while (true) {
$subPattern = substr($pattern, 0, $begin)
. substr($pattern, $p, $next - $p)
. substr($pattern, $rest + 1);

$result = self::fallbackGlob($subPattern, $flags | self::GLOB_BRACE);

if ($result) {
$paths = array_merge($paths, $result);
}

if ($pattern[$next] === '}') {
break;
}

$p = $next + 1;
$next = self::nextBraceSub($pattern, $p, $flags);
}

return array_unique($paths);
}

/**
* Find the end of the sub-pattern in a brace expression.
*
* @param string $pattern
* @param integer $begin
* @param integer $flags
* @return integer|null
*/
protected static function nextBraceSub($pattern, $begin, $flags)
{
$length = strlen($pattern);
$depth = 0;
$current = $begin;

while ($current < $length) {
if (!$flags & self::GLOB_NOESCAPE && $pattern[$current] === '\\') {
if (++$current === $length) {
break;
}

$current++;
} else {
if (($pattern[$current] === '}' && $depth-- === 0) || ($pattern[$current] === ',' && $depth === 0)) {
break;
} else if ($pattern[$current++] === '{') {
$depth++;
}
}
}

return ($current < $length ? $current : null);
}
}
2 changes: 1 addition & 1 deletion src/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Traversable;

class Message implements MessageDescription
class Message implements MessageInterface
{
/**
* @var array
Expand Down
2 changes: 1 addition & 1 deletion src/MessageDescription.php → src/MessageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Zend\Stdlib;

interface MessageDescription
interface MessageInterface
{
public function setMetadata($spec, $value = null);
public function getMetadata($key = null);
Expand Down
2 changes: 1 addition & 1 deletion src/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Options implements ParameterObject
abstract class Options implements ParameterObjectInterface
{
/**
* @param array|Traversable|null $options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface ParameterObject
interface ParameterObjectInterface
{
/**
* @param string $key
Expand Down
2 changes: 1 addition & 1 deletion src/Parameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use ArrayObject;

class Parameters extends ArrayObject implements ParametersDescription
class Parameters extends ArrayObject implements ParametersInterface
{
/**
* Constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* class QueryParams extends ArrayObject implements Parameters {}
* and have 90% of the functionality
*/
interface ParametersDescription extends ArrayAccess, Countable, Serializable, Traversable
interface ParametersInterface extends ArrayAccess, Countable, Serializable, Traversable
{
public function __construct(array $values = null);

Expand Down
2 changes: 1 addition & 1 deletion src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Zend\Stdlib;

class Request extends Message implements RequestDescription
class Request extends Message implements RequestInterface
{
// generic request implementation
}
Loading

0 comments on commit 2c71b71

Please sign in to comment.