diff --git a/src/Reader/Entry/AbstractEntry.php b/src/Reader/Entry/AbstractEntry.php index a450e715..f308a9da 100644 --- a/src/Reader/Entry/AbstractEntry.php +++ b/src/Reader/Entry/AbstractEntry.php @@ -23,6 +23,7 @@ */ namespace Zend\Feed\Reader\Entry; use Zend\Feed\Reader; +use Zend\Feed\Reader\Exception; /** * @uses \Zend\Feed\Reader\Exception @@ -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'); } /** diff --git a/src/Reader/Reader.php b/src/Reader/Reader.php index fffff0e0..7e67b3ea 100644 --- a/src/Reader/Reader.php +++ b/src/Reader/Reader.php @@ -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); @@ -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(); @@ -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); @@ -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); diff --git a/src/Writer/Entry.php b/src/Writer/Entry.php index 8cfc483f..95d13d24 100644 --- a/src/Writer/Entry.php +++ b/src/Writer/Entry.php @@ -41,14 +41,14 @@ 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. @@ -56,7 +56,7 @@ class Entry * @var string */ protected $_type = null; - + /** * Constructor: Primarily triggers the registration of core extensions and * loads those appropriate to this data container. @@ -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'); @@ -134,7 +134,7 @@ public function addAuthors(array $authors) $this->addAuthor($author); } } - + /** * Set the feed character encoding * @@ -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: @@ -429,7 +429,7 @@ public function getId() } return $this->_data['id']; } - + /** * Get a link to the HTML source * @@ -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'])) { @@ -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() ) { @@ -536,7 +536,7 @@ public function addCategory(array $category) } $this->_data['categories'][] = $category; } - + /** * Set an array of entry categories * @@ -548,7 +548,7 @@ public function addCategories(array $categories) $this->addCategory($category); } } - + /** * Get the entry categories * @@ -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) { @@ -580,7 +580,7 @@ public function setEnclosure(array $enclosure) } $this->_data['enclosure'] = $enclosure; } - + /** * Retrieve an array of all enclosures to be added to entry. * @@ -593,7 +593,7 @@ public function getEnclosure() } return $this->_data['enclosure']; } - + /** * Unset a specific data point * @@ -605,7 +605,7 @@ public function remove($name) unset($this->_data[$name]); } } - + /** * Get registered extensions * @@ -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 @@ -641,7 +641,7 @@ public function setType($type) { $this->_type = $type; } - + /** * Retrieve the current or last feed type exported. * @@ -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 @@ -699,7 +699,7 @@ public function setSource(Source $source) { $this->_data['source'] = $source; } - + /** * @return Zend_Feed_Writer_Source */ diff --git a/test/PubSubHubbub/Model/SubscriptionTest.php b/test/PubSubHubbub/Model/SubscriptionTest.php index 9240ed4c..727158fa 100644 --- a/test/PubSubHubbub/Model/SubscriptionTest.php +++ b/test/PubSubHubbub/Model/SubscriptionTest.php @@ -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',