From 0c48e73c2f0f2d575f72b57e53583585b3302655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20Bru=CC=88ckner?= Date: Sat, 2 Mar 2019 09:04:50 +0100 Subject: [PATCH 1/9] Marks old and unused reader classes as deprecated --- src/Reader/AbstractEntry.php | 3 +++ src/Reader/AbstractFeed.php | 3 +++ src/Reader/Collection.php | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/src/Reader/AbstractEntry.php b/src/Reader/AbstractEntry.php index f4f5249f..0e75da7b 100644 --- a/src/Reader/AbstractEntry.php +++ b/src/Reader/AbstractEntry.php @@ -13,6 +13,9 @@ use DOMElement; use DOMXPath; +/** + * @deprecated This (abstract) class is deprecated. Use Zend\Feed\Reader\Entry\AbstractEntry instead. + */ abstract class AbstractEntry { /** diff --git a/src/Reader/AbstractFeed.php b/src/Reader/AbstractFeed.php index 4ff19825..b2110d1c 100644 --- a/src/Reader/AbstractFeed.php +++ b/src/Reader/AbstractFeed.php @@ -13,6 +13,9 @@ use DOMElement; use DOMXPath; +/** + * @deprecated This (abstract) class is deprecated. Use \Zend\Feed\Reader\Feed\AbstractFeed instead. + */ abstract class AbstractFeed implements Feed\FeedInterface { /** diff --git a/src/Reader/Collection.php b/src/Reader/Collection.php index f50c1bc2..6e99571f 100644 --- a/src/Reader/Collection.php +++ b/src/Reader/Collection.php @@ -11,6 +11,11 @@ use ArrayObject; +/** + * @deprecated This class is deprecated. Use the concret collection classes + * \Zend\Feed\Reader\Collection\Author and \Zend\Feed\Reader\Collection\Category + * or the generic class \Zend\Feed\Reader\Collection\Collection instead + */ class Collection extends ArrayObject { } From 1046e5bf8e1801f97fd0cdb57d761bc136f96db6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20Bru=CC=88ckner?= Date: Mon, 4 Mar 2019 21:36:42 +0100 Subject: [PATCH 2/9] Marks Zend\Writer\Writer::lcfirst method as deprecated --- src/Writer/Writer.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Writer/Writer.php b/src/Writer/Writer.php index dc80d10b..f15adef4 100644 --- a/src/Writer/Writer.php +++ b/src/Writer/Writer.php @@ -205,6 +205,12 @@ public static function registerCoreExtensions() ); } + /** + * @deprecated This method is deprecated and will be removed with version 3.0 + * Use PHP's lcfirst function instead. @see https://php.net/manual/function.lcfirst.php + * @param string $str + * @return string + */ public static function lcfirst($str) { $str[0] = strtolower($str[0]); From 8c53672b6b6df64cf2a9b5c270ffc52d9e79931f Mon Sep 17 00:00:00 2001 From: Fabio Date: Fri, 1 Mar 2019 11:28:33 +0100 Subject: [PATCH 3/9] Added Reader/Writer methods and tests for on episode (entry) level --- src/Reader/Extension/Podcast/Entry.php | 22 ++++++++++++++++++ src/Writer/Extension/ITunes/Entry.php | 17 ++++++++++++++ .../Extension/ITunes/Renderer/Entry.php | 23 +++++++++++++++++++ .../_files/google-podcast-complete.xml | 3 +++ .../Integration/_files/google-podcast.xml | 3 +++ .../Integration/_files/podcast-complete.xml | 3 +++ .../Integration/_files/podcast-episode.xml | 3 +++ test/Reader/Integration/_files/podcast.xml | 3 +++ test/Writer/Extension/ITunes/EntryTest.php | 14 +++++++++++ 9 files changed, 91 insertions(+) diff --git a/src/Reader/Extension/Podcast/Entry.php b/src/Reader/Extension/Podcast/Entry.php index 7060fa3c..2a8c2aa6 100644 --- a/src/Reader/Extension/Podcast/Entry.php +++ b/src/Reader/Extension/Podcast/Entry.php @@ -129,6 +129,28 @@ public function getKeywords() return $this->data['keywords']; } + /** + * Get the entry title + * + * @return string + */ + public function getTitle() + { + if (isset($this->data['title'])) { + return $this->data['title']; + } + + $title = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:title)'); + + if (! $title) { + $title = null; + } + + $this->data['title'] = $title; + + return $this->data['title']; + } + /** * Get the entry subtitle * diff --git a/src/Writer/Extension/ITunes/Entry.php b/src/Writer/Extension/ITunes/Entry.php index cb49c0c7..eb219b54 100644 --- a/src/Writer/Extension/ITunes/Entry.php +++ b/src/Writer/Extension/ITunes/Entry.php @@ -191,6 +191,23 @@ public function setItunesKeywords(array $value) return $this; } + /** + * Set title + * + * @param string $value + * @return Entry + * @throws Writer\Exception\InvalidArgumentException + */ + public function setItunesTitle($value) + { + if ($this->stringWrapper->strlen($value) > 255) { + throw new Writer\Exception\InvalidArgumentException('invalid parameter: "title" may only' + . ' contain a maximum of 255 characters'); + } + $this->data['title'] = $value; + return $this; + } + /** * Set subtitle * diff --git a/src/Writer/Extension/ITunes/Renderer/Entry.php b/src/Writer/Extension/ITunes/Renderer/Entry.php index 81840846..699e6a52 100644 --- a/src/Writer/Extension/ITunes/Renderer/Entry.php +++ b/src/Writer/Extension/ITunes/Renderer/Entry.php @@ -39,6 +39,7 @@ public function render() $this->_setImage($this->dom, $this->base); $this->_setExplicit($this->dom, $this->base); $this->_setKeywords($this->dom, $this->base); + $this->_setTitle($this->dom, $this->base); $this->_setSubtitle($this->dom, $this->base); $this->_setSummary($this->dom, $this->base); $this->_setEpisode($this->dom, $this->base); @@ -198,6 +199,28 @@ protected function _setKeywords(DOMDocument $dom, DOMElement $root) $this->called = true; } + /** + * Set entry title + * + * @param DOMDocument $dom + * @param DOMElement $root + * @return void + */ + // @codingStandardsIgnoreStart + protected function _setTitle(DOMDocument $dom, DOMElement $root) + { + // @codingStandardsIgnoreEnd + $title = $this->getDataContainer()->getItunesTitle(); + if (! $title) { + return; + } + $el = $dom->createElement('itunes:title'); + $text = $dom->createTextNode($title); + $el->appendChild($text); + $root->appendChild($el); + $this->called = true; + } + /** * Set entry subtitle * diff --git a/test/Reader/Integration/_files/google-podcast-complete.xml b/test/Reader/Integration/_files/google-podcast-complete.xml index afccb390..cecf74ec 100644 --- a/test/Reader/Integration/_files/google-podcast-complete.xml +++ b/test/Reader/Integration/_files/google-podcast-complete.xml @@ -40,6 +40,7 @@ no John Doe yes + Shake Shake Shake Your Spices With A Shaker A short primer on table spices This week we talk about salt and pepper @@ -59,6 +60,7 @@ Socket Wrench Shootout Jane Doe + Socket Wrench Shootout With A Tool Comparing socket wrenches is fun! This week we talk about metric vs. old @@ -78,6 +80,7 @@ Red, Whine, & Blue Various + Red, Whine & Blue Red + Blue != Purple This week we talk about surviving in a Red state if you are a Blue person. Or vice versa. diff --git a/test/Reader/Integration/_files/google-podcast.xml b/test/Reader/Integration/_files/google-podcast.xml index 77f11299..d0573574 100644 --- a/test/Reader/Integration/_files/google-podcast.xml +++ b/test/Reader/Integration/_files/google-podcast.xml @@ -39,6 +39,7 @@ no John Doe yes + Shake Shake Shake Your Spices With A Shaker A short primer on table spices This week we talk about salt and pepper @@ -60,6 +61,7 @@ Socket Wrench Shootout Jane Doe + Socket Wrench Shootout With A Tool Comparing socket wrenches is fun! This week we talk about metric vs. old @@ -81,6 +83,7 @@ Red, Whine, & Blue Various + Red, Whine & Blue Red + Blue != Purple This week we talk about surviving in a Red state if you are a Blue person. Or vice versa. diff --git a/test/Reader/Integration/_files/podcast-complete.xml b/test/Reader/Integration/_files/podcast-complete.xml index d5de5c52..106a1500 100644 --- a/test/Reader/Integration/_files/podcast-complete.xml +++ b/test/Reader/Integration/_files/podcast-complete.xml @@ -38,6 +38,7 @@ no John Doe yes + Shake Shake Shake Your Spices With A Shaker A short primer on table spices This week we talk about salt and pepper @@ -57,6 +58,7 @@ Socket Wrench Shootout Jane Doe + Socket Wrench Shootout With A Tool Comparing socket wrenches is fun! This week we talk about metric vs. old @@ -76,6 +78,7 @@ Red, Whine, & Blue Various + Red, Whine & Blue Red + Blue != Purple This week we talk about surviving in a Red state if you are a Blue person. Or vice versa. diff --git a/test/Reader/Integration/_files/podcast-episode.xml b/test/Reader/Integration/_files/podcast-episode.xml index 2ef027ac..d442f510 100644 --- a/test/Reader/Integration/_files/podcast-episode.xml +++ b/test/Reader/Integration/_files/podcast-episode.xml @@ -39,6 +39,7 @@ no John Doe yes + Shake Shake Shake Your Spices With A Shaker A short primer on table spices This week we talk about salt and pepper @@ -58,6 +59,7 @@ Socket Wrench Shootout Jane Doe + Socket Wrench Shootout With A Tool Comparing socket wrenches is fun! This week we talk about metric vs. old @@ -77,6 +79,7 @@ Red, Whine, & Blue Various + Red, Whine & Blue Red + Blue != Purple This week we talk about surviving in a Red state if you are a Blue person. Or vice versa. diff --git a/test/Reader/Integration/_files/podcast.xml b/test/Reader/Integration/_files/podcast.xml index 9a81962b..a9656e47 100644 --- a/test/Reader/Integration/_files/podcast.xml +++ b/test/Reader/Integration/_files/podcast.xml @@ -37,6 +37,7 @@ no John Doe yes + Shake Shake Shake Your Spices With A Shaker A short primer on table spices This week we talk about salt and pepper @@ -58,6 +59,7 @@ Socket Wrench Shootout Jane Doe + Socket Wrench Shootout With A Tool Comparing socket wrenches is fun! This week we talk about metric vs. old @@ -79,6 +81,7 @@ Red, Whine, & Blue Various + Red, Whine & Blue Red + Blue != Purple This week we talk about surviving in a Red state if you are a Blue person. Or vice versa. diff --git a/test/Writer/Extension/ITunes/EntryTest.php b/test/Writer/Extension/ITunes/EntryTest.php index fcebcb48..9dafda46 100644 --- a/test/Writer/Extension/ITunes/EntryTest.php +++ b/test/Writer/Extension/ITunes/EntryTest.php @@ -185,6 +185,20 @@ public function testSetKeywordsThrowsExceptionIfFormattedKeywordsExceeds255CharL } } + public function testSetTitle() + { + $entry = new Writer\Entry; + $entry->setItunesTitle('abc'); + $this->assertEquals('abc', $entry->getItunesTitle()); + } + + public function testSetTitleThrowsExceptionWhenValueExceeds255Chars() + { + $this->expectException(ExceptionInterface::class); + $entry = new Writer\Entry; + $entry->setItunesTitle(str_repeat('a', 256)); + } + public function testSetSubtitle() { $entry = new Writer\Entry; From 5f427fe9f3019e09458241ebe5947cda4e6822ad Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 5 Mar 2019 13:54:23 -0600 Subject: [PATCH 4/9] Adds CHANGELOG entry for #96 --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0aeec830..6556f755 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,9 @@ All notable changes to this project will be documented in this file, in reverse ### Added -- Nothing. +- [#96](https://github.com/zendframework/zend-feed/pull/96) adds the methods `Zend\Feed\Reader\Extension\Podcast\Entry::getTitle() : string` + and `Zend\Feed\Writer\Extension\ITunes\Entry::setTitle(string $value)`; these + provide the ability to read and manipulate `` tags in feeds. ### Changed From 77a6e5db3cffa23a786a3a8ec1e71545f86be78a Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 5 Mar 2019 13:57:32 -0600 Subject: [PATCH 5/9] docs: single level of indentation in docblock --- src/Reader/Collection.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Reader/Collection.php b/src/Reader/Collection.php index 6e99571f..b6ee93a8 100644 --- a/src/Reader/Collection.php +++ b/src/Reader/Collection.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2019 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -12,9 +12,9 @@ use ArrayObject; /** - * @deprecated This class is deprecated. Use the concret collection classes - * \Zend\Feed\Reader\Collection\Author and \Zend\Feed\Reader\Collection\Category - * or the generic class \Zend\Feed\Reader\Collection\Collection instead + * @deprecated This class is deprecated. Use the concrete collection classes + * \Zend\Feed\Reader\Collection\Author and \Zend\Feed\Reader\Collection\Category + * or the generic class \Zend\Feed\Reader\Collection\Collection instead. */ class Collection extends ArrayObject { From a2d17f8358208bfe91ccd159fc207dd9db51a948 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 5 Mar 2019 13:59:53 -0600 Subject: [PATCH 6/9] Adds CHANGELOG entry for #97 --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6556f755..659bff99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,10 @@ All notable changes to this project will be documented in this file, in reverse ### Deprecated -- Nothing. +- [#97](https://github.com/zendframework/zend-feed/pull/97) deprecates the classes `Zend\Feed\Reader\AbstractEntry` (use + `Zend\Feed\Reader\Entry\AbstractEntry` instead), `Zend\Feed\Reader\AbstractFeed` (use `Zend\Feed\Reader\Feed\AbstractFeed` instead), and + `Zend\Feed\Reader\Collection` (use Zend\Feed\Reader\Collection\Author`, `Zend\Feed\Reader\Collection\Category`, or + `Zend\Feed\Reader\Collection\Collection` instead, based on context). ### Removed From c60c9101330349803129d57612ac043e957b7ee9 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 5 Mar 2019 14:02:14 -0600 Subject: [PATCH 7/9] qa: indentation, and use lcfirst Changes indentation of deprecation notice to be a single level of indentation, instead of aligned with the annotation. Modifies the function to simply proxy to the PHP `lcfirst` function, since it is available in all PHP versions we support. --- src/Writer/Writer.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Writer/Writer.php b/src/Writer/Writer.php index f15adef4..4f5c1697 100644 --- a/src/Writer/Writer.php +++ b/src/Writer/Writer.php @@ -207,14 +207,13 @@ public static function registerCoreExtensions() /** * @deprecated This method is deprecated and will be removed with version 3.0 - * Use PHP's lcfirst function instead. @see https://php.net/manual/function.lcfirst.php + * Use PHP's lcfirst function instead. @see https://php.net/manual/function.lcfirst.php * @param string $str * @return string */ public static function lcfirst($str) { - $str[0] = strtolower($str[0]); - return $str; + return lcfirst($str); } /** From 15c7a0f51bedd5cb5acb7691cbcfd78490317530 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 5 Mar 2019 14:04:19 -0600 Subject: [PATCH 8/9] Adds CHANGELOG entry for #101 --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 659bff99..de37b06d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,9 @@ All notable changes to this project will be documented in this file, in reverse ### Deprecated +- [#101](https://github.com/zendframework/zend-feed/pull/101) deprecates the method `Zend\Feed\Writer\Writer::lcfirst()`; use the PHP + built-in function instead. + - [#97](https://github.com/zendframework/zend-feed/pull/97) deprecates the classes `Zend\Feed\Reader\AbstractEntry` (use `Zend\Feed\Reader\Entry\AbstractEntry` instead), `Zend\Feed\Reader\AbstractFeed` (use `Zend\Feed\Reader\Feed\AbstractFeed` instead), and `Zend\Feed\Reader\Collection` (use Zend\Feed\Reader\Collection\Author`, `Zend\Feed\Reader\Collection\Category`, or From 27e9b750891b7a113afff4c645066b7726809ea6 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 5 Mar 2019 14:08:11 -0600 Subject: [PATCH 9/9] release: 2.12.0 readiness - Updates branch aliases: - dev-master => 2.12.x-dev - dev-develop => 2.13.x-dev - Updates CHANGELOG: - Sets date for 2.12.0 release --- CHANGELOG.md | 2 +- composer.json | 4 ++-- composer.lock | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de37b06d..ec89110b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to this project will be documented in this file, in reverse chronological order by release. -## 2.12.0 - TBD +## 2.12.0 - 2019-03-05 ### Added diff --git a/composer.json b/composer.json index 08b64f83..aa16a63f 100644 --- a/composer.json +++ b/composer.json @@ -55,8 +55,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.11.x-dev", - "dev-develop": "2.12.x-dev" + "dev-master": "2.12.x-dev", + "dev-develop": "2.13.x-dev" } }, "scripts": { diff --git a/composer.lock b/composer.lock index b6655e90..92988d86 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e8857d47defecc50f052b87ec248bbdf", + "content-hash": "1fdca955b6832b5c98c451b223a6a965", "packages": [ { "name": "zendframework/zend-escaper",