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

Commit

Permalink
Merge branch 'master' of git://github.com/zendframework/zf2
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 41 deletions.
3 changes: 2 additions & 1 deletion src/Reader/Entry/AbstractEntry.php
Expand Up @@ -23,6 +23,7 @@
*/
namespace Zend\Feed\Reader\Entry;
use Zend\Feed\Reader;
use Zend\Feed\Reader\Exception;

/**
* @uses \Zend\Feed\Reader\Exception
Expand Down Expand Up @@ -219,7 +220,7 @@ public function __call($method, $args)
}
}
throw new Exception('Method: ' . $method
. 'does not exist and could not be located on a registered Extension');
. ' does not exist and could not be located on a registered Extension');
}

/**
Expand Down
34 changes: 17 additions & 17 deletions src/Reader/Reader.php
Expand Up @@ -211,8 +211,8 @@ public static function import($uri, $etag = null, $lastModified = null)
$responseXml = '';
$client = self::getHttpClient();
$client->resetParameters();
$client->setHeaders('If-None-Match', null);
$client->setHeaders('If-Modified-Since', null);
$headers = new Http\Headers();
$client->setHeaders($headers);
$client->setUri($uri);
$cacheId = 'Zend_Feed_Reader_' . md5($uri);

Expand All @@ -226,17 +226,17 @@ public static function import($uri, $etag = null, $lastModified = null)
$lastModified = $cache->load($cacheId.'_lastmodified');;
}
if ($etag) {
$client->setHeaders('If-None-Match', $etag);
$headers->addHeaderLine('If-None-Match', $etag);
}
if ($lastModified) {
$client->setHeaders('If-Modified-Since', $lastModified);
$headers->addHeaderLine('If-Modified-Since', $lastModified);
}
}
$response = $client->request('GET');
if ($response->getStatus() !== 200 && $response->getStatus() !== 304) {
throw new Exception('Feed failed to load, got response code ' . $response->getStatus());
$response = $client->send();
if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 304) {
throw new Exception('Feed failed to load, got response code ' . $response->getStatusCode());
}
if ($response->getStatus() == 304) {
if ($response->getStatusCode() == 304) {
$responseXml = $data;
} else {
$responseXml = $response->getBody();
Expand All @@ -254,17 +254,17 @@ public static function import($uri, $etag = null, $lastModified = null)
if ($data !== false) {
return self::importString($data);
}
$response = $client->request('GET');
if ($response->getStatus() !== 200) {
throw new Exception('Feed failed to load, got response code ' . $response->getStatus());
$response = $client->send();
if ((int)$response->getStatusCode() !== 200) {
throw new Exception('Feed failed to load, got response code ' . $response->getStatusCode());
}
$responseXml = $response->getBody();
$cache->save($responseXml, $cacheId);
return self::importString($responseXml);
} else {
$response = $client->request('GET');
if ($response->getStatus() !== 200) {
throw new Exception('Feed failed to load, got response code ' . $response->getStatus());
$response = $client->send();
if ((int)$response->getStatusCode() !== 200) {
throw new Exception('Feed failed to load, got response code ' . $response->getStatusCode());
}
$reader = self::importString($response->getBody());
$reader->setOriginalSourceUri($uri);
Expand Down Expand Up @@ -335,9 +335,9 @@ public static function findFeedLinks($uri)
{
$client = self::getHttpClient();
$client->setUri($uri);
$response = $client->request();
if ($response->getStatus() !== 200) {
throw new Exception("Failed to access $uri, got response code " . $response->getStatus());
$response = $client->send();
if ($response->getStatusCode() !== 200) {
throw new Exception("Failed to access $uri, got response code " . $response->getStatusCode());
}
$responseHtml = $response->getBody();
$libxml_errflag = libxml_use_internal_errors(true);
Expand Down
44 changes: 22 additions & 22 deletions src/Writer/Entry.php
Expand Up @@ -41,22 +41,22 @@ class Entry
* @var array
*/
protected $_data = array();

/**
* Registered extensions
*
* @var array
*/
protected $_extensions = array();

/**
* Holds the value "atom" or "rss" depending on the feed type set when
* when last exported.
*
* @var string
*/
protected $_type = null;

/**
* Constructor: Primarily triggers the registration of core extensions and
* loads those appropriate to this data container.
Expand All @@ -79,8 +79,8 @@ public function addAuthor($name, $email = null, $uri = null)
{
$author = array();
if (is_array($name)) {
if (!array_key_exists('name', $name)
|| empty($name['name'])
if (!array_key_exists('name', $name)
|| empty($name['name'])
|| !is_string($name['name'])
) {
throw new Exception('Invalid parameter: author array must include a "name" key with a non-empty string value');
Expand Down Expand Up @@ -134,7 +134,7 @@ public function addAuthors(array $authors)
$this->addAuthor($author);
}
}

/**
* Set the feed character encoding
*
Expand Down Expand Up @@ -311,7 +311,7 @@ public function setCommentFeedLink(array $link)
}
$this->_data['commentFeedLinks'][] = $link;
}

/**
* Set a links to an XML feed for any comments associated with this entry.
* Each link is an array with keys "uri" and "type", where type is one of:
Expand Down Expand Up @@ -429,7 +429,7 @@ public function getId()
}
return $this->_data['id'];
}

/**
* Get a link to the HTML source
*
Expand Down Expand Up @@ -509,12 +509,12 @@ public function getCommentFeedLinks()
}
return $this->_data['commentFeedLinks'];
}

/**
* Add a entry category
*
* @param string $category
*/
*/
public function addCategory(array $category)
{
if (!isset($category['term'])) {
Expand All @@ -523,7 +523,7 @@ public function addCategory(array $category)
. ' readable category name');
}
if (isset($category['scheme'])) {
if (empty($category['scheme'])
if (empty($category['scheme'])
|| !is_string($category['scheme'])
|| !Uri\UriFactory::factory($category['scheme'])->isValid()
) {
Expand All @@ -536,7 +536,7 @@ public function addCategory(array $category)
}
$this->_data['categories'][] = $category;
}

/**
* Set an array of entry categories
*
Expand All @@ -548,7 +548,7 @@ public function addCategories(array $categories)
$this->addCategory($category);
}
}

/**
* Get the entry categories
*
Expand All @@ -561,14 +561,14 @@ public function getCategories()
}
return $this->_data['categories'];
}

/**
* Adds an enclosure to the entry. The array parameter may contain the
* keys 'uri', 'type' and 'length'. Only 'uri' is required for Atom, though the
* others must also be provided or RSS rendering (where they are required)
* will throw an Exception.
*
* @param array $enclosures
* @param array $enclosure
*/
public function setEnclosure(array $enclosure)
{
Expand All @@ -580,7 +580,7 @@ public function setEnclosure(array $enclosure)
}
$this->_data['enclosure'] = $enclosure;
}

/**
* Retrieve an array of all enclosures to be added to entry.
*
Expand All @@ -593,7 +593,7 @@ public function getEnclosure()
}
return $this->_data['enclosure'];
}

/**
* Unset a specific data point
*
Expand All @@ -605,7 +605,7 @@ public function remove($name)
unset($this->_data[$name]);
}
}

/**
* Get registered extensions
*
Expand All @@ -629,7 +629,7 @@ public function getExtension($name)
}
return null;
}

/**
* Set the current feed type being exported to "rss" or "atom". This allows
* other objects to gracefully choose whether to execute or not, depending
Expand All @@ -641,7 +641,7 @@ public function setType($type)
{
$this->_type = $type;
}

/**
* Retrieve the current or last feed type exported.
*
Expand Down Expand Up @@ -671,7 +671,7 @@ public function __call($method, $args)
throw new Exception('Method: ' . $method
. ' does not exist and could not be located on a registered Extension');
}

/**
* Creates a new Zend_Feed_Writer_Source data container for use. This is NOT
* added to the current feed automatically, but is necessary to create a
Expand Down Expand Up @@ -699,7 +699,7 @@ public function setSource(Source $source)
{
$this->_data['source'] = $source;
}

/**
* @return Zend_Feed_Writer_Source
*/
Expand Down
2 changes: 1 addition & 1 deletion test/PubSubHubbub/Model/SubscriptionTest.php
Expand Up @@ -48,7 +48,7 @@ public function testAllOperations()

$this->assertTrue($subscription->hasSubscription($id));
$dataSubscription = $subscription->getSubscription($id);
$this->assertType('array', $dataSubscription);
$this->assertInternalType('array', $dataSubscription);
$keys = array('id', 'topic_url', 'hub_url',
'created_time', 'lease_seconds',
'verify_token', 'secret',
Expand Down

0 comments on commit 21d3bef

Please sign in to comment.