Skip to content
This repository has been archived by the owner on Jun 27, 2022. It is now read-only.

Commit

Permalink
Breaking / Potentially breaking changes:
Browse files Browse the repository at this point in the history
    1. Adopting a marker interface for Guzzle exceptions.
        A. All exceptions emitted from Guzzle are now wrapped with a Guzzle namespaced exception.
        B. Guzzle\Common\GuzzleExceptionInterface was renamed to Guzzle\Common\GuzzleException
        C. Guzzle\Common\ExceptionCollection was renamed to Guzzle\Common\Exception\ExceptionCollection
    2. Using Header objects for Request and Response objects
        A. When you call $request->getHeader('X'), you will get back a Guzzle\Http\Message\Header object that contains all of the headers that case insensitively match.  This object can be cast to a string or iterated like an array.  You can pass true in the second argument to retrieve the header as a string.
        B. Removing the old Guzzle\Common\Collection based searching arguments from most of the request and response header methods.  All retrievals are case-insensitive and return Header objects.
    3. Changing the two headers added by the cache plugin to just one header with key and ttl.
    4. Changing Guzzle\Http\Message\Response::factory() to fromMessage().
    5. Removing the NullObject return value from ServiceDescriptions and instead simply returning null

New Features / enhancements:

    1. Adding Guzzle\Http\Message\AbstractMessage::addHeaders()
    2. Making it simpler to create service descriptions using a unified factory method that delegates to other factories.
    3. Better handling of ports and hosts in Guzzle\Http\Url

Note: This is a noisy diff because I'm removing trailing whitespace and adding a new line at the end of each source file.
  • Loading branch information
mtdowling committed Apr 22, 2012
1 parent cbf125f commit c0dc85d
Show file tree
Hide file tree
Showing 188 changed files with 1,528 additions and 916 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ try {
$client->head('messages/123'),
$client->delete('orders/123')
));
} catch (Guzzle\Common\ExceptionCollection $e) {
} catch (Guzzle\Common\Exception\ExceptionCollection $e) {
echo "The following requests encountered an exception: \n";
foreach ($e as $exception) {
echo $exception->getRequest() . "\n" . $exception->getMessage() . "\n";
Expand Down
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@
</else>
</if>
</target>
</project>
</project>
2 changes: 1 addition & 1 deletion phar-stub-min.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?php
__HALT_COMPILER();
__HALT_COMPILER();
2 changes: 1 addition & 1 deletion phar-stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
));
$classLoader->register();

__HALT_COMPILER();
__HALT_COMPILER();
11 changes: 11 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,18 @@
<directory suffix=".php">./src/Guzzle</directory>
<exclude>
<directory suffix="Interface.php">./src/Guzzle</directory>
<file>./src/Guzzle/Common/GuzzleException.php</file>
<file>./src/Guzzle/Http/HttpException.php</file>
<file>./src/Guzzle/Common/Exception/BadMethodCallException.php</file>
<file>./src/Guzzle/Common/Exception/InvalidArgumentException.php</file>
<file>./src/Guzzle/Common/Exception/RuntimeException.php</file>
<file>./src/Guzzle/Common/Exception/UnexpectedValueException.php</file>
<file>./src/Guzzle/Service/Exception/ClientNotFoundException.php</file>
<file>./src/Guzzle/Service/Exception/CommandException.php</file>
<file>./src/Guzzle/Service/Exception/DescriptionBuilderException.php</file>
<file>./src/Guzzle/Service/Exception/ServiceBuilderException.php</file>
<file>./src/Guzzle/Service/Exception/ServiceNotFoundException.php</file>
<file>./src/Guzzle/Service/Exception/ValidationException.php</file>
</exclude>
</whitelist>
</filter>
Expand Down
2 changes: 1 addition & 1 deletion src/Guzzle/Common/AbstractHasDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ public function dispatch($eventName, array $context = array())
{
$this->getEventDispatcher()->dispatch($eventName, new Event($context));
}
}
}
2 changes: 1 addition & 1 deletion src/Guzzle/Common/Cache/AbstractCacheAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ public function getCacheObject()
{
return $this->cache;
}
}
}
23 changes: 15 additions & 8 deletions src/Guzzle/Common/Cache/CacheAdapterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Guzzle\Common\Cache;

use Guzzle\Common\Exception\InvalidArgumentException;
use Guzzle\Common\Exception\RuntimeException;

/**
* Generates cache adapters and cache providers objects using an array of
* configuration data. This can be useful for creating cache adapters
Expand All @@ -21,12 +24,12 @@ public static function factory(array $config)
foreach (array('cache.adapter', 'cache.provider') as $required) {
// Validate that the required parameters were set
if (!isset($config[$required])) {
throw new \InvalidArgumentException("{$required} is a required CacheAdapterFactory option");
throw new InvalidArgumentException("{$required} is a required CacheAdapterFactory option");
}

// Ensure that the cache adapter and provider are actual classes
if (is_string($config[$required]) && !class_exists($config[$required])) {
throw new \InvalidArgumentException("{$config[$required]} is not a valid class for {$required}");
throw new InvalidArgumentException("{$config[$required]} is not a valid class for {$required}");
}
}

Expand Down Expand Up @@ -56,11 +59,15 @@ public static function factory(array $config)
*/
protected static function createObject($className, array $args = null)
{
if (!$args) {
return new $className;
} else {
$c = new \ReflectionClass($className);
return $c->newInstanceArgs($args);
try {
if (!$args) {
return new $className;
} else {
$c = new \ReflectionClass($className);
return $c->newInstanceArgs($args);
}
} catch (\Exception $e) {
throw new RuntimeException($e->getMessage(), $e->getCode(), $e);
}
}
}
}
2 changes: 1 addition & 1 deletion src/Guzzle/Common/Cache/CacheAdapterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ function fetch($id, array $options = null);
* FALSE otherwise.
*/
function save($id, $data, $lifeTime = false, array $options = null);
}
}
6 changes: 4 additions & 2 deletions src/Guzzle/Common/Cache/ClosureCacheAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Guzzle\Common\Cache;

use Guzzle\Common\Exception\InvalidArgumentException;

/**
* Cache adapter that defers to closures for implementation
*/
Expand All @@ -28,7 +30,7 @@ public function __construct(array $callables)
// Validate each key to ensure it exists and is callable
foreach (array('contains', 'delete', 'fetch', 'save') as $key) {
if (!array_key_exists($key, $callables) || !is_callable($callables[$key])) {
throw new \InvalidArgumentException(
throw new InvalidArgumentException(
"callables must contain a callable $key key");
}
}
Expand Down Expand Up @@ -67,4 +69,4 @@ public function save($id, $data, $lifeTime = false, array $options = null)
{
return call_user_func($this->callables['save'], $id, $data, $lifeTime, $options);
}
}
}
2 changes: 1 addition & 1 deletion src/Guzzle/Common/Cache/DoctrineCacheAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ public function save($id, $data, $lifeTime = false, array $options = null)
{
return $this->cache->save($id, $data, $lifeTime);
}
}
}
2 changes: 1 addition & 1 deletion src/Guzzle/Common/Cache/Zf1CacheAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ public function save($id, $data, $lifeTime = false, array $options = null)
{
return $this->cache->save($data, $id, array(), $lifeTime);
}
}
}
2 changes: 1 addition & 1 deletion src/Guzzle/Common/Cache/Zf2CacheAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ public function save($id, $data, $lifeTime = false, array $options = null)
'ttl' => $lifeTime
)));
}
}
}
2 changes: 1 addition & 1 deletion src/Guzzle/Common/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,4 +417,4 @@ public function set($key, $value)

return $this;
}
}
}
2 changes: 1 addition & 1 deletion src/Guzzle/Common/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ public function offsetUnset($offset)
{
unset($this->context[$offset]);
}
}
}
7 changes: 7 additions & 0 deletions src/Guzzle/Common/Exception/BadMethodCallException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Guzzle\Common\Exception;

use Guzzle\Common\GuzzleException;

class BadMethodCallException extends \BadMethodCallException implements GuzzleException {}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php

namespace Guzzle\Common;
namespace Guzzle\Common\Exception;

use Guzzle\Common\GuzzleException;

/**
* Collection of exceptions
*/
class ExceptionCollection extends \Exception implements GuzzleExceptionInterface, \IteratorAggregate, \Countable
class ExceptionCollection extends \Exception implements GuzzleException, \IteratorAggregate, \Countable
{
/**
* @var array Array of Exceptions
Expand Down Expand Up @@ -55,4 +57,4 @@ public function getIterator()
{
return new \ArrayIterator($this->exceptions);
}
}
}
7 changes: 7 additions & 0 deletions src/Guzzle/Common/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Guzzle\Common\Exception;

use Guzzle\Common\GuzzleException;

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

namespace Guzzle\Common\Exception;

use Guzzle\Common\GuzzleException;

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

namespace Guzzle\Common\Exception;

use Guzzle\Common\GuzzleException;

class UnexpectedValueException extends \UnexpectedValueException implements GuzzleException {}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@
/**
* Guzzle exception
*/
interface GuzzleExceptionInterface
{
}
interface GuzzleException {}
16 changes: 8 additions & 8 deletions src/Guzzle/Common/HasDispatcherInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

/**
* Holds an event dispatcher
* Holds an event dispatcher
*/
interface HasDispatcherInterface
{
/**
* Get a list of all of the events emitted from the class
*
* @return array
*
* @return array
*/
static function getAllEvents();

/**
* Set the EventDispatcher of the request
*
* @param EventDispatcherInterface $eventDispatcher
*
*
* @return HasDispatcherInterface
*/
function setEventDispatcher(EventDispatcherInterface $eventDispatcher);
Expand All @@ -31,12 +31,12 @@ function setEventDispatcher(EventDispatcherInterface $eventDispatcher);
* @return EventDispatcherInterface
*/
function getEventDispatcher();

/**
* Helper to dispatch Guzzle events and set the event name on the event
*
*
* @param $eventName Name of the event to dispatch
* @param array $context Context of the event
*/
function dispatch($eventName, array $context = array());
}
}
2 changes: 1 addition & 1 deletion src/Guzzle/Common/Log/AbstractLogAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ public function getLogObject()
{
return $this->log;
}
}
}
6 changes: 4 additions & 2 deletions src/Guzzle/Common/Log/ClosureLogAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Guzzle\Common\Log;

use Guzzle\Common\Exception\InvalidArgumentException;

/**
* Allows Closures to be called when messages are logged. Closures combined
* with filtering can trigger application events based on log messages.
Expand All @@ -14,7 +16,7 @@ class ClosureLogAdapter extends AbstractLogAdapter
public function __construct($logObject)
{
if (!is_callable($logObject)) {
throw new \InvalidArgumentException('Object must be callable');
throw new InvalidArgumentException('Object must be callable');
}

$this->log = $logObject;
Expand All @@ -27,4 +29,4 @@ public function log($message, $priority = LOG_INFO, $extras = null)
{
call_user_func($this->log, $message, $priority, $extras);
}
}
}
2 changes: 1 addition & 1 deletion src/Guzzle/Common/Log/LogAdapterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ interface LogAdapterInterface
* @param mixed $extras (optional) Extra information to log in event
*/
function log($message, $priority = LOG_INFO, $extras = null);
}
}
2 changes: 1 addition & 1 deletion src/Guzzle/Common/Log/MonologLogAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ public function log($message, $priority = LOG_INFO, $extras = null)
{
$this->log->addRecord(self::$mapping[$priority], $message);
}
}
}
2 changes: 1 addition & 1 deletion src/Guzzle/Common/Log/Zf1LogAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ public function log($message, $priority = LOG_INFO, $extras = null)
{
$this->log->log($message, $priority, $extras);
}
}
}
2 changes: 1 addition & 1 deletion src/Guzzle/Common/Log/Zf2LogAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ public function log($message, $priority = LOG_INFO, $extras = null)
{
$this->log->log($message, $priority, $extras);
}
}
}
2 changes: 1 addition & 1 deletion src/Guzzle/Common/NullObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ public function key() {}
public function next() {}
public function rewind() {}
public function valid() {}
}
}
6 changes: 4 additions & 2 deletions src/Guzzle/Common/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Guzzle\Common;

use Guzzle\Common\Exception\InvalidArgumentException;

/**
* OO interface to PHP streams
*/
Expand Down Expand Up @@ -34,7 +36,7 @@ class Stream
public function __construct($stream, $size = null)
{
if (!is_resource($stream)) {
throw new \InvalidArgumentException('Stream must be a resource');
throw new InvalidArgumentException('Stream must be a resource');
}

$this->size = $size;
Expand Down Expand Up @@ -279,4 +281,4 @@ public function write($string)
{
return $this->isWritable() ? fwrite($this->stream, $string) : false;
}
}
}
2 changes: 1 addition & 1 deletion src/Guzzle/Common/XmlElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ public function asFormattedXml()

return $doc->saveXML();
}
}
}
2 changes: 1 addition & 1 deletion src/Guzzle/Guzzle.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,4 @@ public static function reset()
{
self::$cache = array();
}
}
}
Loading

0 comments on commit c0dc85d

Please sign in to comment.