From c10358a0f69789306d65daf23f79a07c271268e2 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Sun, 25 Oct 2015 13:37:34 +0100 Subject: update picofeed & version bump --- .../picofeed/lib/PicoFeed/Client/Client.php | 298 +++++++++---------- .../lib/PicoFeed/Client/ClientException.php | 4 +- .../fguillot/picofeed/lib/PicoFeed/Client/Curl.php | 136 ++++----- .../picofeed/lib/PicoFeed/Client/HttpHeaders.php | 23 +- .../Client/InvalidCertificateException.php | 3 +- .../lib/PicoFeed/Client/InvalidUrlException.php | 3 +- .../lib/PicoFeed/Client/MaxRedirectException.php | 3 +- .../lib/PicoFeed/Client/MaxSizeException.php | 3 +- .../picofeed/lib/PicoFeed/Client/Stream.php | 56 ++-- .../lib/PicoFeed/Client/TimeoutException.php | 3 +- .../fguillot/picofeed/lib/PicoFeed/Client/Url.php | 136 ++++----- .../picofeed/lib/PicoFeed/Config/Config.php | 22 +- .../picofeed/lib/PicoFeed/Encoding/Encoding.php | 6 +- .../picofeed/lib/PicoFeed/Filter/Attribute.php | 310 ++++++++++---------- .../picofeed/lib/PicoFeed/Filter/Filter.php | 63 ++-- .../fguillot/picofeed/lib/PicoFeed/Filter/Html.php | 93 +++--- .../fguillot/picofeed/lib/PicoFeed/Filter/Tag.php | 93 +++--- .../picofeed/lib/PicoFeed/Logging/Logger.php | 44 ++- .../fguillot/picofeed/lib/PicoFeed/Parser/Atom.php | 187 ++++++------ .../picofeed/lib/PicoFeed/Parser/DateParser.php | 30 +- .../fguillot/picofeed/lib/PicoFeed/Parser/Feed.php | 91 ++---- .../fguillot/picofeed/lib/PicoFeed/Parser/Item.php | 104 ++----- .../lib/PicoFeed/Parser/MalformedXmlException.php | 5 +- .../picofeed/lib/PicoFeed/Parser/Parser.php | 324 +++++++++------------ .../lib/PicoFeed/Parser/ParserException.php | 6 +- .../picofeed/lib/PicoFeed/Parser/Rss10.php | 140 ++++----- .../picofeed/lib/PicoFeed/Parser/Rss20.php | 161 +++++----- .../picofeed/lib/PicoFeed/Parser/Rss91.php | 3 +- .../picofeed/lib/PicoFeed/Parser/Rss92.php | 3 +- .../picofeed/lib/PicoFeed/Parser/XmlParser.php | 112 +++---- .../picofeed/lib/PicoFeed/PicoFeedException.php | 3 +- .../picofeed/lib/PicoFeed/Reader/Favicon.php | 66 ++--- .../picofeed/lib/PicoFeed/Reader/Reader.php | 86 +++--- .../lib/PicoFeed/Reader/ReaderException.php | 4 +- .../Reader/SubscriptionNotFoundException.php | 3 +- .../Reader/UnsupportedFeedFormatException.php | 5 +- .../lib/PicoFeed/Rules/.blog.lemonde.fr.php | 2 +- .../picofeed/lib/PicoFeed/Rules/.igen.fr.php | 2 +- .../picofeed/lib/PicoFeed/Rules/.slate.com.php | 2 +- .../lib/PicoFeed/Rules/.theguardian.com.php | 2 +- .../picofeed/lib/PicoFeed/Rules/.wired.com.php | 4 +- .../picofeed/lib/PicoFeed/Rules/.wsj.com.php | 2 +- .../picofeed/lib/PicoFeed/Rules/01net.com.php | 11 +- .../lib/PicoFeed/Rules/abstrusegoose.com.php | 7 +- .../lib/PicoFeed/Rules/alainonline.net.php | 7 +- .../picofeed/lib/PicoFeed/Rules/aljazeera.com.php | 7 +- .../picofeed/lib/PicoFeed/Rules/allafrica.com.php | 5 +- .../lib/PicoFeed/Rules/allgemeine-zeitung.de.php | 9 +- .../lib/PicoFeed/Rules/amazingsuperpowers.com.php | 7 +- .../lib/PicoFeed/Rules/anythingcomic.com.php | 5 +- .../picofeed/lib/PicoFeed/Rules/ap.org.php | 5 +- .../picofeed/lib/PicoFeed/Rules/areadvd.de.php | 7 +- .../lib/PicoFeed/Rules/arstechnica.com.php | 5 +- .../lib/PicoFeed/Rules/awkwardzombie.com.php | 7 +- .../lib/PicoFeed/Rules/bangkokpost.com.php | 5 +- .../picofeed/lib/PicoFeed/Rules/bgr.com.php | 5 +- .../lib/PicoFeed/Rules/bigfootjustice.com.php | 5 +- .../lib/PicoFeed/Rules/bizjournals.com.php | 5 +- .../picofeed/lib/PicoFeed/Rules/blog.fefe.de.php | 9 +- .../lib/PicoFeed/Rules/blog.mapillary.com.php | 9 +- .../lib/PicoFeed/Rules/buenosairesherald.com.php | 5 +- .../picofeed/lib/PicoFeed/Rules/bunicomic.com.php | 5 +- .../picofeed/lib/PicoFeed/Rules/buttersafe.com.php | 7 +- .../picofeed/lib/PicoFeed/Rules/cad-comic.com.php | 9 +- .../picofeed/lib/PicoFeed/Rules/channelate.com.php | 7 +- .../lib/PicoFeed/Rules/chaoslife.findchaos.com.php | 7 +- .../lib/PicoFeed/Rules/cliquerefresh.com.php | 7 +- .../picofeed/lib/PicoFeed/Rules/cnet.com.php | 5 +- .../picofeed/lib/PicoFeed/Rules/consomac.fr.php | 7 +- .../lib/PicoFeed/Rules/cowbirdsinlove.com.php | 7 +- .../picofeed/lib/PicoFeed/Rules/csmonitor.com.php | 5 +- .../picofeed/lib/PicoFeed/Rules/dailyjs.com.php | 7 +- .../picofeed/lib/PicoFeed/Rules/dailytech.com.php | 5 +- .../lib/PicoFeed/Rules/degroupnews.com.php | 9 +- .../picofeed/lib/PicoFeed/Rules/derstandard.at.php | 5 +- .../lib/PicoFeed/Rules/discovermagazine.com.php | 5 +- .../lib/PicoFeed/Rules/distrowatch.com.php | 9 +- .../picofeed/lib/PicoFeed/Rules/dozodomo.com.php | 9 +- .../lib/PicoFeed/Rules/drawingboardcomic.com.php | 9 +- .../lib/PicoFeed/Rules/endlessorigami.com.php | 5 +- .../picofeed/lib/PicoFeed/Rules/engadget.com.php | 7 +- .../lib/PicoFeed/Rules/escapistmagazine.com.php | 21 +- .../picofeed/lib/PicoFeed/Rules/espn.go.com.php | 5 +- .../picofeed/lib/PicoFeed/Rules/exocomics.com.php | 9 +- .../picofeed/lib/PicoFeed/Rules/explosm.net.php | 5 +- .../lib/PicoFeed/Rules/extrafabulouscomics.com.php | 5 +- .../lib/PicoFeed/Rules/fastcodesign.com.php | 7 +- .../lib/PicoFeed/Rules/fastcoexist.com.php | 7 +- .../lib/PicoFeed/Rules/fastcompany.com.php | 7 +- .../picofeed/lib/PicoFeed/Rules/ffworld.com.php | 7 +- .../lib/PicoFeed/Rules/fowllanguagecomics.com.php | 7 +- .../picofeed/lib/PicoFeed/Rules/geek.com.php | 5 +- .../picofeed/lib/PicoFeed/Rules/giantitp.com.php | 15 +- .../picofeed/lib/PicoFeed/Rules/github.com.php | 9 +- .../picofeed/lib/PicoFeed/Rules/gocomics.com.php | 5 +- .../picofeed/lib/PicoFeed/Rules/golem.de.php | 11 +- .../picofeed/lib/PicoFeed/Rules/happletea.com.php | 11 +- .../picofeed/lib/PicoFeed/Rules/heise.de.php | 9 +- .../lib/PicoFeed/Rules/huffingtonpost.com.php | 7 +- .../lib/PicoFeed/Rules/imogenquest.net.php | 7 +- .../picofeed/lib/PicoFeed/Rules/ing.dk.php | 9 +- .../lib/PicoFeed/Rules/invisiblebread.com.php | 7 +- .../picofeed/lib/PicoFeed/Rules/ir.amd.com.php | 3 +- .../lib/PicoFeed/Rules/japantimes.co.jp.php | 5 +- .../picofeed/lib/PicoFeed/Rules/japantoday.com.php | 5 +- .../lib/PicoFeed/Rules/journaldugeek.com.php | 9 +- .../picofeed/lib/PicoFeed/Rules/jsonline.com.php | 5 +- .../picofeed/lib/PicoFeed/Rules/kanpai.fr.php | 9 +- .../lib/PicoFeed/Rules/karriere.jobfinder.dk.php | 9 +- .../lib/PicoFeed/Rules/koreaherald.com.php | 5 +- .../lib/PicoFeed/Rules/lastplacecomics.com.php | 5 +- .../picofeed/lib/PicoFeed/Rules/lejapon.fr.php | 9 +- .../lib/PicoFeed/Rules/lesjoiesducode.fr.php | 7 +- .../picofeed/lib/PicoFeed/Rules/lfg.co.php | 8 +- .../picofeed/lib/PicoFeed/Rules/lifehacker.com.php | 9 +- .../picofeed/lib/PicoFeed/Rules/linux.org.php | 5 +- .../lib/PicoFeed/Rules/linuxinsider.com.php | 5 +- .../fguillot/picofeed/lib/PicoFeed/Rules/lists.php | 7 +- .../lib/PicoFeed/Rules/loadingartist.com.php | 5 +- .../picofeed/lib/PicoFeed/Rules/loldwell.com.php | 7 +- .../picofeed/lib/PicoFeed/Rules/lukesurl.com.php | 9 +- .../picofeed/lib/PicoFeed/Rules/macg.co.php | 9 +- .../picofeed/lib/PicoFeed/Rules/marc.info.php | 5 +- .../lib/PicoFeed/Rules/marriedtothesea.com.php | 5 +- .../picofeed/lib/PicoFeed/Rules/marycagle.com.php | 5 +- .../Rules/maximumble.thebookofbiff.com.php | 7 +- .../picofeed/lib/PicoFeed/Rules/medium.com.php | 7 +- .../picofeed/lib/PicoFeed/Rules/mercworks.net.php | 9 +- .../picofeed/lib/PicoFeed/Rules/metronieuws.nl.php | 7 +- .../lib/PicoFeed/Rules/mokepon.smackjeeves.com.php | 7 +- .../lib/PicoFeed/Rules/monwindowsphone.com.php | 7 +- .../lib/PicoFeed/Rules/mrlovenstein.com.php | 9 +- .../picofeed/lib/PicoFeed/Rules/nba.com.php | 5 +- .../picofeed/lib/PicoFeed/Rules/nedroid.com.php | 7 +- .../lib/PicoFeed/Rules/networkworld.com.php | 7 +- .../lib/PicoFeed/Rules/neustadt-ticker.de.php | 7 +- .../lib/PicoFeed/Rules/niceteethcomic.com.php | 7 +- .../picofeed/lib/PicoFeed/Rules/nichtlustig.de.php | 9 +- .../picofeed/lib/PicoFeed/Rules/oglaf.com.php | 13 +- .../lib/PicoFeed/Rules/openrightsgroup.org.php | 7 +- .../picofeed/lib/PicoFeed/Rules/opensource.com.php | 12 + .../picofeed/lib/PicoFeed/Rules/optipess.com.php | 7 +- .../picofeed/lib/PicoFeed/Rules/osnews.com.php | 5 +- .../picofeed/lib/PicoFeed/Rules/pastebin.com.php | 7 +- .../picofeed/lib/PicoFeed/Rules/peebleslab.com.php | 7 +- .../lib/PicoFeed/Rules/penny-arcade.com.php | 11 +- .../picofeed/lib/PicoFeed/Rules/pixelbeat.org.php | 5 +- .../lib/PicoFeed/Rules/plus.google.com.php | 5 +- .../picofeed/lib/PicoFeed/Rules/popstrip.com.php | 7 +- .../lib/PicoFeed/Rules/putaindecode.fr.php | 9 +- .../picofeed/lib/PicoFeed/Rules/recode.net.php | 6 +- .../lib/PicoFeed/Rules/rue89.nouvelobs.com.php | 9 +- .../picofeed/lib/PicoFeed/Rules/satwcomic.com.php | 9 +- .../lib/PicoFeed/Rules/scrumalliance.org.php | 7 +- .../lib/PicoFeed/Rules/securityfocus.com.php | 5 +- .../lib/PicoFeed/Rules/sentfromthemoon.com.php | 13 +- .../picofeed/lib/PicoFeed/Rules/sitepoint.com.php | 7 +- .../picofeed/lib/PicoFeed/Rules/slashdot.org.php | 9 +- .../lib/PicoFeed/Rules/smallhousebliss.com.php | 7 +- .../lib/PicoFeed/Rules/smarthomewelt.de.php | 7 +- .../lib/PicoFeed/Rules/smashingmagazine.com.php | 7 +- .../lib/PicoFeed/Rules/smbc-comics.com.php | 7 +- .../lib/PicoFeed/Rules/soundandvision.com.php | 5 +- .../picofeed/lib/PicoFeed/Rules/spiegel.de.php | 11 +- .../lib/PicoFeed/Rules/stereophile.com.php | 5 +- .../picofeed/lib/PicoFeed/Rules/stupidfox.net.php | 9 +- .../lib/PicoFeed/Rules/subtraction.com.php | 9 +- .../fguillot/picofeed/lib/PicoFeed/Rules/sz.de.php | 7 +- .../picofeed/lib/PicoFeed/Rules/techcrunch.com.php | 9 +- .../lib/PicoFeed/Rules/the-ebook-reader.com.php | 5 +- .../lib/PicoFeed/Rules/theatlantic.com.php | 5 +- .../lib/PicoFeed/Rules/theawkwardyeti.com.php | 5 +- .../lib/PicoFeed/Rules/thecodinglove.com.php | 7 +- .../lib/PicoFeed/Rules/thedoghousediaries.com.php | 13 +- .../lib/PicoFeed/Rules/thegamercat.com.php | 7 +- .../picofeed/lib/PicoFeed/Rules/thehindu.com.php | 7 +- .../lib/PicoFeed/Rules/themerepublic.net.php | 7 +- .../lib/PicoFeed/Rules/themoscowtimes.com.php | 5 +- .../picofeed/lib/PicoFeed/Rules/theonion.com.php | 5 +- .../lib/PicoFeed/Rules/thestandard.com.hk.php | 7 +- .../lib/PicoFeed/Rules/threepanelsoul.com.php | 3 +- .../lib/PicoFeed/Rules/travel-dealz.de.php | 7 +- .../picofeed/lib/PicoFeed/Rules/treehugger.com.php | 7 +- .../lib/PicoFeed/Rules/treelobsters.com.php | 7 +- .../picofeed/lib/PicoFeed/Rules/twogag.com.php | 8 +- .../lib/PicoFeed/Rules/twokinds.keenspot.com.php | 7 +- .../picofeed/lib/PicoFeed/Rules/undeadly.org.php | 9 +- .../picofeed/lib/PicoFeed/Rules/upi.com.php | 5 +- .../picofeed/lib/PicoFeed/Rules/version2.dk.php | 9 +- .../picofeed/lib/PicoFeed/Rules/vgcats.com.php | 6 +- .../picofeed/lib/PicoFeed/Rules/vuxml.org.php | 13 +- .../picofeed/lib/PicoFeed/Rules/www.bbc.co.uk.php | 13 +- .../picofeed/lib/PicoFeed/Rules/www.bdgest.com.php | 7 +- .../lib/PicoFeed/Rules/www.businessweek.com.php | 5 +- .../picofeed/lib/PicoFeed/Rules/www.cnn.com.php | 7 +- .../lib/PicoFeed/Rules/www.developpez.com.php | 9 +- .../lib/PicoFeed/Rules/www.egscomics.com.php | 9 +- .../picofeed/lib/PicoFeed/Rules/www.forbes.com.php | 9 +- .../lib/PicoFeed/Rules/www.futura-sciences.com.php | 7 +- .../picofeed/lib/PicoFeed/Rules/www.lepoint.fr.php | 9 +- .../lib/PicoFeed/Rules/www.lesnumeriques.com.php | 9 +- .../lib/PicoFeed/Rules/www.mac4ever.com.php | 7 +- .../picofeed/lib/PicoFeed/Rules/www.npr.org.php | 5 +- .../lib/PicoFeed/Rules/www.numerama.com.php | 7 +- .../lib/PicoFeed/Rules/www.pcinpact.com.php | 7 +- .../lib/PicoFeed/Rules/www.pseudo-sciences.org.php | 5 +- .../picofeed/lib/PicoFeed/Rules/www.slate.fr.php | 9 +- .../lib/PicoFeed/Rules/www.universfreebox.com.php | 9 +- .../picofeed/lib/PicoFeed/Rules/www.zeit.de.php | 18 +- .../picofeed/lib/PicoFeed/Rules/xkcd.com.php | 7 +- .../picofeed/lib/PicoFeed/Rules/zdnet.com.php | 5 +- .../lib/PicoFeed/Scraper/CandidateParser.php | 67 ++--- .../lib/PicoFeed/Scraper/ParserInterface.php | 2 +- .../picofeed/lib/PicoFeed/Scraper/RuleLoader.php | 39 ++- .../picofeed/lib/PicoFeed/Scraper/RuleParser.php | 26 +- .../picofeed/lib/PicoFeed/Scraper/Scraper.php | 138 ++++----- .../picofeed/lib/PicoFeed/Serialization/Export.php | 46 ++- .../picofeed/lib/PicoFeed/Serialization/Import.php | 75 +++-- .../picofeed/lib/PicoFeed/Syndication/Atom.php | 53 ++-- .../picofeed/lib/PicoFeed/Syndication/Rss20.php | 55 ++-- .../picofeed/lib/PicoFeed/Syndication/Writer.php | 45 ++- 221 files changed, 2107 insertions(+), 2326 deletions(-) create mode 100644 vendor/fguillot/picofeed/lib/PicoFeed/Rules/opensource.com.php (limited to 'vendor/fguillot/picofeed/lib') diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Client.php b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Client.php index ae93f3e83..3c64ce5fb 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Client.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Client.php @@ -4,218 +4,197 @@ namespace PicoFeed\Client; use LogicException; use PicoFeed\Logging\Logger; +use PicoFeed\Config\Config; /** - * Client class + * Client class. * * @author Frederic Guillot - * @package client */ abstract class Client { /** - * Flag that say if the resource have been modified + * Flag that say if the resource have been modified. * - * @access private * @var bool */ private $is_modified = true; /** - * HTTP Content-Type + * HTTP Content-Type. * - * @access private * @var string */ private $content_type = ''; /** - * HTTP encoding + * HTTP encoding. * - * @access private * @var string */ private $encoding = ''; /** - * HTTP request headers + * HTTP request headers. * - * @access protected * @var array */ protected $request_headers = array(); /** - * HTTP Etag header + * HTTP Etag header. * - * @access protected * @var string */ protected $etag = ''; /** - * HTTP Last-Modified header + * HTTP Last-Modified header. * - * @access protected * @var string */ protected $last_modified = ''; /** - * Proxy hostname + * Proxy hostname. * - * @access protected * @var string */ protected $proxy_hostname = ''; /** - * Proxy port + * Proxy port. * - * @access protected - * @var integer + * @var int */ protected $proxy_port = 3128; /** - * Proxy username + * Proxy username. * - * @access protected * @var string */ protected $proxy_username = ''; /** - * Proxy password + * Proxy password. * - * @access protected * @var string */ protected $proxy_password = ''; /** - * Basic auth username + * Basic auth username. * - * @access protected * @var string */ protected $username = ''; /** - * Basic auth password + * Basic auth password. * - * @access protected * @var string */ protected $password = ''; /** - * Client connection timeout + * Client connection timeout. * - * @access protected - * @var integer + * @var int */ protected $timeout = 10; /** - * User-agent + * User-agent. * - * @access protected * @var string */ protected $user_agent = 'PicoFeed (https://github.com/fguillot/picoFeed)'; /** - * Real URL used (can be changed after a HTTP redirect) + * Real URL used (can be changed after a HTTP redirect). * - * @access protected * @var string */ protected $url = ''; /** - * Page/Feed content + * Page/Feed content. * - * @access protected * @var string */ protected $content = ''; /** - * Number maximum of HTTP redirections to avoid infinite loops + * Number maximum of HTTP redirections to avoid infinite loops. * - * @access protected - * @var integer + * @var int */ protected $max_redirects = 5; /** - * Maximum size of the HTTP body response + * Maximum size of the HTTP body response. * - * @access protected - * @var integer + * @var int */ protected $max_body_size = 2097152; // 2MB /** - * HTTP response status code + * HTTP response status code. * - * @access protected - * @var integer + * @var int */ protected $status_code = 0; /** - * Enables direct passthrough to requesting client + * Enables direct passthrough to requesting client. * - * @access protected * @var bool */ protected $passthrough = false; /** - * Do the HTTP request + * Do the HTTP request. * * @abstract - * @access public + * * @return array */ abstract public function doRequest(); /** - * Get client instance: curl or stream driver + * Get client instance: curl or stream driver. * * @static - * @access public + * * @return \PicoFeed\Client\Client */ public static function getInstance() { if (function_exists('curl_init')) { - return new Curl; - } - else if (ini_get('allow_url_fopen')) { - return new Stream; + return new Curl(); + } elseif (ini_get('allow_url_fopen')) { + return new Stream(); } throw new LogicException('You must have "allow_url_fopen=1" or curl extension installed'); } /** - * Add HTTP Header to the request + * Add HTTP Header to the request. * - * @access public * @param array $headers */ - public function setHeaders($headers) { + public function setHeaders($headers) + { $this->request_headers = $headers; } /** - * Perform the HTTP request + * Perform the HTTP request. + * + * @param string $url URL * - * @access public - * @param string $url URL * @return Client */ public function execute($url = '') @@ -239,17 +218,15 @@ abstract class Client } /** - * Handle not modified response + * Handle not modified response. * - * @access public - * @param array $response Client response + * @param array $response Client response */ public function handleNotModifiedResponse(array $response) { if ($response['status'] == 304) { $this->is_modified = false; - } - else if ($response['status'] == 200) { + } elseif ($response['status'] == 200) { $this->is_modified = $this->hasBeenModified($response, $this->etag, $this->last_modified); $this->etag = $this->getHeader($response, 'ETag'); $this->last_modified = $this->getHeader($response, 'Last-Modified'); @@ -261,10 +238,9 @@ abstract class Client } /** - * Handle not found response + * Handle not found response. * - * @access public - * @param array $response Client response + * @param array $response Client response */ public function handleNotFoundResponse(array $response) { @@ -274,10 +250,9 @@ abstract class Client } /** - * Handle normal response + * Handle normal response. * - * @access public - * @param array $response Client response + * @param array $response Client response */ public function handleNormalResponse(array $response) { @@ -289,19 +264,19 @@ abstract class Client } /** - * Check if a request has been modified according to the parameters + * Check if a request has been modified according to the parameters. * - * @access public - * @param array $response - * @param string $etag - * @param string $lastModified - * @return boolean + * @param array $response + * @param string $etag + * @param string $lastModified + * + * @return bool */ private function hasBeenModified($response, $etag, $lastModified) { $headers = array( 'Etag' => $etag, - 'Last-Modified' => $lastModified + 'Last-Modified' => $lastModified, ); // Compare the values for each header that is present @@ -311,7 +286,7 @@ abstract class Client if ($response['headers'][$key] !== $value) { return true; } - $presentCacheHeaderCount++; + ++$presentCacheHeaderCount; } } @@ -325,10 +300,10 @@ abstract class Client } /** - * Find content type from response headers + * Find content type from response headers. + * + * @param array $response Client response * - * @access public - * @param array $response Client response * @return string */ public function findContentType(array $response) @@ -337,23 +312,23 @@ abstract class Client } /** - * Find charset from response headers + * Find charset from response headers. * - * @access public * @return string */ public function findCharset() { $result = explode('charset=', $this->content_type); + return isset($result[1]) ? $result[1] : ''; } /** - * Get header value from a client response + * Get header value from a client response. + * + * @param array $response Client response + * @param string $header Header name * - * @access public - * @param array $response Client response - * @param string $header Header name * @return string */ public function getHeader(array $response, $header) @@ -362,22 +337,22 @@ abstract class Client } /** - * Set the Last-Modified HTTP header + * Set the Last-Modified HTTP header. + * + * @param string $last_modified Header value * - * @access public - * @param string $last_modified Header value * @return \PicoFeed\Client\Client */ public function setLastModified($last_modified) { $this->last_modified = $last_modified; + return $this; } /** - * Get the value of the Last-Modified HTTP header + * Get the value of the Last-Modified HTTP header. * - * @access public * @return string */ public function getLastModified() @@ -386,22 +361,22 @@ abstract class Client } /** - * Set the value of the Etag HTTP header + * Set the value of the Etag HTTP header. + * + * @param string $etag Etag HTTP header value * - * @access public - * @param string $etag Etag HTTP header value * @return \PicoFeed\Client\Client */ public function setEtag($etag) { $this->etag = $etag; + return $this; } /** - * Get the Etag HTTP header value + * Get the Etag HTTP header value. * - * @access public * @return string */ public function getEtag() @@ -410,9 +385,8 @@ abstract class Client } /** - * Get the final url value + * Get the final url value. * - * @access public * @return string */ public function getUrl() @@ -421,23 +395,22 @@ abstract class Client } /** - * Set the url + * Set the url. * - * @access public * @return string * @return \PicoFeed\Client\Client */ public function setUrl($url) { $this->url = $url; + return $this; } /** - * Get the HTTP response status code + * Get the HTTP response status code. * - * @access public - * @return integer + * @return int */ public function getStatusCode() { @@ -445,9 +418,8 @@ abstract class Client } /** - * Get the body of the HTTP response + * Get the body of the HTTP response. * - * @access public * @return string */ public function getContent() @@ -456,9 +428,8 @@ abstract class Client } /** - * Get the content type value from HTTP headers + * Get the content type value from HTTP headers. * - * @access public * @return string */ public function getContentType() @@ -467,9 +438,8 @@ abstract class Client } /** - * Get the encoding value from HTTP headers + * Get the encoding value from HTTP headers. * - * @access public * @return string */ public function getEncoding() @@ -478,9 +448,8 @@ abstract class Client } /** - * Return true if the remote resource has changed + * Return true if the remote resource has changed. * - * @access public * @return bool */ public function isModified() @@ -489,9 +458,8 @@ abstract class Client } /** - * return true if passthrough mode is enabled + * return true if passthrough mode is enabled. * - * @access public * @return bool */ public function isPassthroughEnabled() @@ -500,167 +468,177 @@ abstract class Client } /** - * Set connection timeout + * Set connection timeout. + * + * @param int $timeout Connection timeout * - * @access public - * @param integer $timeout Connection timeout * @return \PicoFeed\Client\Client */ public function setTimeout($timeout) { $this->timeout = $timeout ?: $this->timeout; + return $this; } /** - * Set a custom user agent + * Set a custom user agent. + * + * @param string $user_agent User Agent * - * @access public - * @param string $user_agent User Agent * @return \PicoFeed\Client\Client */ public function setUserAgent($user_agent) { $this->user_agent = $user_agent ?: $this->user_agent; + return $this; } /** - * Set the mximum number of HTTP redirections + * Set the mximum number of HTTP redirections. + * + * @param int $max Maximum * - * @access public - * @param integer $max Maximum * @return \PicoFeed\Client\Client */ public function setMaxRedirections($max) { $this->max_redirects = $max ?: $this->max_redirects; + return $this; } /** - * Set the maximum size of the HTTP body + * Set the maximum size of the HTTP body. + * + * @param int $max Maximum * - * @access public - * @param integer $max Maximum * @return \PicoFeed\Client\Client */ public function setMaxBodySize($max) { $this->max_body_size = $max ?: $this->max_body_size; + return $this; } /** - * Set the proxy hostname + * Set the proxy hostname. + * + * @param string $hostname Proxy hostname * - * @access public - * @param string $hostname Proxy hostname * @return \PicoFeed\Client\Client */ public function setProxyHostname($hostname) { $this->proxy_hostname = $hostname ?: $this->proxy_hostname; + return $this; } /** - * Set the proxy port + * Set the proxy port. + * + * @param int $port Proxy port * - * @access public - * @param integer $port Proxy port * @return \PicoFeed\Client\Client */ public function setProxyPort($port) { $this->proxy_port = $port ?: $this->proxy_port; + return $this; } /** - * Set the proxy username + * Set the proxy username. + * + * @param string $username Proxy username * - * @access public - * @param string $username Proxy username * @return \PicoFeed\Client\Client */ public function setProxyUsername($username) { $this->proxy_username = $username ?: $this->proxy_username; + return $this; } /** - * Set the proxy password + * Set the proxy password. + * + * @param string $password Password * - * @access public - * @param string $password Password * @return \PicoFeed\Client\Client */ public function setProxyPassword($password) { $this->proxy_password = $password ?: $this->proxy_password; + return $this; } /** - * Set the username + * Set the username. + * + * @param string $username Basic Auth username * - * @access public - * @param string $username Basic Auth username * @return \PicoFeed\Client\Client */ public function setUsername($username) { $this->username = $username ?: $this->username; + return $this; } /** - * Set the password + * Set the password. + * + * @param string $password Basic Auth Password * - * @access public - * @param string $password Basic Auth Password * @return \PicoFeed\Client\Client */ public function setPassword($password) { $this->password = $password ?: $this->password; + return $this; } /** - * Enable the passthrough mode + * Enable the passthrough mode. * - * @access public * @return \PicoFeed\Client\Client */ public function enablePassthroughMode() { $this->passthrough = true; + return $this; } /** - * Disable the passthrough mode + * Disable the passthrough mode. * - * @access public * @return \PicoFeed\Client\Client */ public function disablePassthroughMode() { $this->passthrough = false; + return $this; } /** - * Set config object + * Set config object. + * + * @param \PicoFeed\Config\Config $config Config instance * - * @access public - * @param \PicoFeed\Config\Config $config Config instance * @return \PicoFeed\Client\Client */ - public function setConfig($config) + public function setConfig(Config $config) { if ($config !== null) { $this->setTimeout($config->getClientTimeout()); @@ -675,4 +653,16 @@ abstract class Client return $this; } + + /** + * Return true if the HTTP status code is a redirection + * + * @access protected + * @param integer $code + * @return boolean + */ + public function isRedirection($code) + { + return $code == 301 || $code == 302 || $code == 303 || $code == 307; + } } diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Client/ClientException.php b/vendor/fguillot/picofeed/lib/PicoFeed/Client/ClientException.php index 0e27452ed..b3a95c9f7 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Client/ClientException.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Client/ClientException.php @@ -4,12 +4,10 @@ namespace PicoFeed\Client; use PicoFeed\PicoFeedException; - /** - * ClientException Exception + * ClientException Exception. * * @author Frederic Guillot - * @package Client */ abstract class ClientException extends PicoFeedException { diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Curl.php b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Curl.php index 3e408b6d8..b07685fcb 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Curl.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Curl.php @@ -5,54 +5,49 @@ namespace PicoFeed\Client; use PicoFeed\Logging\Logger; /** - * cURL HTTP client + * cURL HTTP client. * * @author Frederic Guillot - * @package Client */ class Curl extends Client { /** - * HTTP response body + * HTTP response body. * - * @access private * @var string */ private $body = ''; /** - * Body size + * Body size. * - * @access private - * @var integer + * @var int */ private $body_length = 0; /** - * HTTP response headers + * HTTP response headers. * - * @access private * @var array */ private $response_headers = array(); /** - * Counter on the number of header received + * Counter on the number of header received. * - * @access private - * @var integer + * @var int */ private $response_headers_count = 0; /** - * cURL callback to read the HTTP body + * cURL callback to read the HTTP body. * * If the function return -1, curl stop to read the HTTP response * - * @access public - * @param resource $ch cURL handler - * @param string $buffer Chunk of data - * @return integer Length of the buffer + * @param resource $ch cURL handler + * @param string $buffer Chunk of data + * + * @return int Length of the buffer */ public function readBody($ch, $buffer) { @@ -69,23 +64,21 @@ class Curl extends Client } /** - * cURL callback to read HTTP headers + * cURL callback to read HTTP headers. + * + * @param resource $ch cURL handler + * @param string $buffer Header line * - * @access public - * @param resource $ch cURL handler - * @param string $buffer Header line - * @return integer Length of the buffer + * @return int Length of the buffer */ public function readHeaders($ch, $buffer) { $length = strlen($buffer); if ($buffer === "\r\n" || $buffer === "\n") { - $this->response_headers_count++; - } - else { - - if (! isset($this->response_headers[$this->response_headers_count])) { + ++$this->response_headers_count; + } else { + if (!isset($this->response_headers[$this->response_headers_count])) { $this->response_headers[$this->response_headers_count] = ''; } @@ -96,12 +89,12 @@ class Curl extends Client } /** - * cURL callback to passthrough the HTTP status header to the client + * cURL callback to passthrough the HTTP status header to the client. + * + * @param resource $ch cURL handler + * @param string $buffer Header line * - * @access public - * @param resource $ch cURL handler - * @param string $buffer Header line - * @return integer Length of the buffer + * @return int Length of the buffer */ public function passthroughHeaders($ch, $buffer) { @@ -109,8 +102,7 @@ class Curl extends Client if ($status !== 0) { header(':', true, $status); - } - elseif (isset($headers['Content-Type'])) { + } elseif (isset($headers['Content-Type'])) { header($buffer); } @@ -118,25 +110,25 @@ class Curl extends Client } /** - * cURL callback to passthrough the HTTP body to the client + * cURL callback to passthrough the HTTP body to the client. * * If the function return -1, curl stop to read the HTTP response * - * @access public - * @param resource $ch cURL handler - * @param string $buffer Chunk of data - * @return integer Length of the buffer + * @param resource $ch cURL handler + * @param string $buffer Chunk of data + * + * @return int Length of the buffer */ public function passthroughBody($ch, $buffer) { echo $buffer; + return strlen($buffer); } /** - * Prepare HTTP headers + * Prepare HTTP headers. * - * @access private * @return string[] */ private function prepareHeaders() @@ -159,16 +151,15 @@ class Curl extends Client } /** - * Prepare curl proxy context + * Prepare curl proxy context. + * + * @param resource $ch * - * @access private - * @param resource $ch * @return resource $ch */ private function prepareProxyContext($ch) { if ($this->proxy_hostname) { - Logger::setMessage(get_called_class().' Proxy: '.$this->proxy_hostname.':'.$this->proxy_port); curl_setopt($ch, CURLOPT_PROXYPORT, $this->proxy_port); @@ -178,8 +169,7 @@ class Curl extends Client if ($this->proxy_username) { Logger::setMessage(get_called_class().' Proxy credentials: Yes'); curl_setopt($ch, CURLOPT_PROXYUSERPWD, $this->proxy_username.':'.$this->proxy_password); - } - else { + } else { Logger::setMessage(get_called_class().' Proxy credentials: No'); } } @@ -188,10 +178,10 @@ class Curl extends Client } /** - * Prepare curl auth context + * Prepare curl auth context. + * + * @param resource $ch * - * @access private - * @param resource $ch * @return resource $ch */ private function prepareAuthContext($ch) @@ -204,10 +194,10 @@ class Curl extends Client } /** - * Set write/header functions + * Set write/header functions. + * + * @param resource $ch * - * @access private - * @param resource $ch * @return resource $ch */ private function prepareDownloadMode($ch) @@ -218,7 +208,6 @@ class Curl extends Client if ($this->isPassthroughEnabled()) { $write_function = 'passthroughBody'; $header_function = 'passthroughHeaders'; - } curl_setopt($ch, CURLOPT_WRITEFUNCTION, array($this, $write_function)); @@ -228,9 +217,8 @@ class Curl extends Client } /** - * Prepare curl context + * Prepare curl context. * - * @access private * @return resource */ private function prepareContext() @@ -266,9 +254,7 @@ class Curl extends Client } /** - * Execute curl context - * - * @access private + * Execute curl context. */ private function executeContext() { @@ -297,11 +283,11 @@ class Curl extends Client } /** - * Do the HTTP request + * Do the HTTP request. * - * @access public - * @param bool $follow_location Flag used when there is an open_basedir restriction - * @return array HTTP response ['body' => ..., 'status' => ..., 'headers' => ...] + * @param bool $follow_location Flag used when there is an open_basedir restriction + * + * @return array HTTP response ['body' => ..., 'status' => ..., 'headers' => ...] */ public function doRequest($follow_location = true) { @@ -309,22 +295,22 @@ class Curl extends Client list($status, $headers) = HttpHeaders::parse(explode("\n", $this->response_headers[$this->response_headers_count - 1])); - if ($follow_location && ($status == 301 || $status == 302)) { + if ($follow_location && $this->isRedirection($status)) { return $this->handleRedirection($headers['Location']); } return array( 'status' => $status, 'body' => $this->body, - 'headers' => $headers + 'headers' => $headers, ); } /** - * Handle manually redirections when there is an open base dir restriction + * Handle manually redirections when there is an open base dir restriction. + * + * @param string $location Redirected URL * - * @access private - * @param string $location Redirected URL * @return array */ private function handleRedirection($location) @@ -338,8 +324,7 @@ class Curl extends Client $this->response_headers_count = 0; while (true) { - - $nb_redirects++; + ++$nb_redirects; if ($nb_redirects >= $this->max_redirects) { throw new MaxRedirectException('Maximum number of redirections reached'); @@ -347,14 +332,13 @@ class Curl extends Client $result = $this->doRequest(false); - if ($result['status'] == 301 || $result['status'] == 302) { + if ($this->isRedirection($result['status'])) { $this->url = Url::resolve($result['headers']['Location'], $this->url); $this->body = ''; $this->body_length = 0; $this->response_headers = array(); $this->response_headers_count = 0; - } - else { + } else { break; } } @@ -363,14 +347,14 @@ class Curl extends Client } /** - * Handle cURL errors (throw individual exceptions) + * Handle cURL errors (throw individual exceptions). * * We don't use constants because they are not necessary always available * (depends of the version of libcurl linked to php) * * @see http://curl.haxx.se/libcurl/c/libcurl-errors.html - * @access private - * @param integer $errno cURL error code + * + * @param int $errno cURL error code */ private function handleError($errno) { diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Client/HttpHeaders.php b/vendor/fguillot/picofeed/lib/PicoFeed/Client/HttpHeaders.php index ccced5f8e..5ddcafc93 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Client/HttpHeaders.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Client/HttpHeaders.php @@ -6,11 +6,10 @@ use ArrayAccess; use PicoFeed\Logging\Logger; /** - * Class to handle HTTP headers case insensitivity + * Class to handle HTTP headers case insensitivity. * * @author Bernhard Posselt * @author Frederic Guillot - * @package Client */ class HttpHeaders implements ArrayAccess { @@ -44,11 +43,12 @@ class HttpHeaders implements ArrayAccess } /** - * Parse HTTP headers + * Parse HTTP headers. * * @static - * @access public - * @param array $lines List of headers + * + * @param array $lines List of headers + * * @return array */ public static function parse(array $lines) @@ -57,15 +57,14 @@ class HttpHeaders implements ArrayAccess $headers = array(); foreach ($lines as $line) { - - if (strpos($line, 'HTTP') === 0) { + if (strpos($line, 'HTTP/1') === 0) { $headers = array(); $status = (int) substr($line, 9, 3); - } - else if (strpos($line, ':') !== false) { - - @list($name, $value) = explode(': ', $line); - if ($value) $headers[trim($name)] = trim($value); + } elseif (strpos($line, ': ') !== false) { + list($name, $value) = explode(': ', $line); + if ($value) { + $headers[trim($name)] = trim($value); + } } } diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Client/InvalidCertificateException.php b/vendor/fguillot/picofeed/lib/PicoFeed/Client/InvalidCertificateException.php index ece3f303f..8d25d7e40 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Client/InvalidCertificateException.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Client/InvalidCertificateException.php @@ -3,10 +3,9 @@ namespace PicoFeed\Client; /** - * InvalidCertificateException Exception + * InvalidCertificateException Exception. * * @author Frederic Guillot - * @package Client */ class InvalidCertificateException extends ClientException { diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Client/InvalidUrlException.php b/vendor/fguillot/picofeed/lib/PicoFeed/Client/InvalidUrlException.php index 0298f0dc8..15534d987 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Client/InvalidUrlException.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Client/InvalidUrlException.php @@ -3,10 +3,9 @@ namespace PicoFeed\Client; /** - * InvalidUrlException Exception + * InvalidUrlException Exception. * * @author Frederic Guillot - * @package Client */ class InvalidUrlException extends ClientException { diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Client/MaxRedirectException.php b/vendor/fguillot/picofeed/lib/PicoFeed/Client/MaxRedirectException.php index 1651d7f6b..0a221af65 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Client/MaxRedirectException.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Client/MaxRedirectException.php @@ -3,10 +3,9 @@ namespace PicoFeed\Client; /** - * MaxRedirectException Exception + * MaxRedirectException Exception. * * @author Frederic Guillot - * @package Client */ class MaxRedirectException extends ClientException { diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Client/MaxSizeException.php b/vendor/fguillot/picofeed/lib/PicoFeed/Client/MaxSizeException.php index 60bb9f132..201b22a60 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Client/MaxSizeException.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Client/MaxSizeException.php @@ -3,10 +3,9 @@ namespace PicoFeed\Client; /** - * MaxSizeException Exception + * MaxSizeException Exception. * * @author Frederic Guillot - * @package Client */ class MaxSizeException extends ClientException { diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Stream.php b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Stream.php index 36c5ca6f3..75a0122e2 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Stream.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Stream.php @@ -5,17 +5,15 @@ namespace PicoFeed\Client; use PicoFeed\Logging\Logger; /** - * Stream context HTTP client + * Stream context HTTP client. * * @author Frederic Guillot - * @package Client */ class Stream extends Client { /** - * Prepare HTTP headers + * Prepare HTTP headers. * - * @access private * @return string[] */ private function prepareHeaders() @@ -27,7 +25,7 @@ class Stream extends Client // disable compression in passthrough mode. It could result in double // compressed content which isn't decodeable by browsers - if (function_exists('gzdecode') && ! $this->isPassthroughEnabled()) { + if (function_exists('gzdecode') && !$this->isPassthroughEnabled()) { $headers[] = 'Accept-Encoding: gzip'; } @@ -53,14 +51,13 @@ class Stream extends Client } /** - * Construct the final URL from location headers + * Construct the final URL from location headers. * - * @access private - * @param array $headers List of HTTP response header + * @param array $headers List of HTTP response header */ private function setEffectiveUrl($headers) { - foreach($headers as $header) { + foreach ($headers as $header) { if (stripos($header, 'Location') === 0) { list(, $value) = explode(': ', $header); @@ -70,9 +67,8 @@ class Stream extends Client } /** - * Prepare stream context + * Prepare stream context. * - * @access private * @return array */ private function prepareContext() @@ -83,11 +79,10 @@ class Stream extends Client 'protocol_version' => 1.1, 'timeout' => $this->timeout, 'max_redirects' => $this->max_redirects, - ) + ), ); if ($this->proxy_hostname) { - Logger::setMessage(get_called_class().' Proxy: '.$this->proxy_hostname.':'.$this->proxy_port); $context['http']['proxy'] = 'tcp://'.$this->proxy_hostname.':'.$this->proxy_port; @@ -95,8 +90,7 @@ class Stream extends Client if ($this->proxy_username) { Logger::setMessage(get_called_class().' Proxy credentials: Yes'); - } - else { + } else { Logger::setMessage(get_called_class().' Proxy credentials: No'); } } @@ -107,10 +101,9 @@ class Stream extends Client } /** - * Do the HTTP request + * Do the HTTP request. * - * @access public - * @return array HTTP response ['body' => ..., 'status' => ..., 'headers' => ...] + * @return array HTTP response ['body' => ..., 'status' => ..., 'headers' => ...] */ public function doRequest() { @@ -121,7 +114,7 @@ class Stream extends Client // Make HTTP request $stream = @fopen($this->url, 'r', false, $context); - if (! is_resource($stream)) { + if (!is_resource($stream)) { throw new InvalidUrlException('Unable to establish a connection'); } @@ -137,8 +130,7 @@ class Stream extends Client } fpassthru($stream); - } - else { + } else { // Get the entire body until the max size $body = stream_get_contents($stream, $this->max_body_size + 1); @@ -159,16 +151,16 @@ class Stream extends Client return array( 'status' => $status, 'body' => $this->decodeBody($body, $headers), - 'headers' => $headers + 'headers' => $headers, ); } /** - * Decode body response according to the HTTP headers + * Decode body response according to the HTTP headers. + * + * @param string $body Raw body + * @param HttpHeaders $headers HTTP headers * - * @access public - * @param string $body Raw body - * @param HttpHeaders $headers HTTP headers * @return string */ public function decodeBody($body, HttpHeaders $headers) @@ -178,22 +170,22 @@ class Stream extends Client } if (isset($headers['Content-Encoding']) && $headers['Content-Encoding'] === 'gzip') { - $body = @gzdecode($body); + $body = gzdecode($body); } return $body; } /** - * Decode a chunked body + * Decode a chunked body. + * + * @param string $str Raw body * - * @access public - * @param string $str Raw body - * @return string Decoded body + * @return string Decoded body */ public function decodeChunked($str) { - for ($result = ''; ! empty($str); $str = trim($str)) { + for ($result = ''; !empty($str); $str = trim($str)) { // Get the chunk length $pos = strpos($str, "\r\n"); diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Client/TimeoutException.php b/vendor/fguillot/picofeed/lib/PicoFeed/Client/TimeoutException.php index 6ba5cbee2..da98da12e 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Client/TimeoutException.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Client/TimeoutException.php @@ -3,10 +3,9 @@ namespace PicoFeed\Client; /** - * TimeoutException Exception + * TimeoutException Exception. * * @author Frederic Guillot - * @package Client */ class TimeoutException extends ClientException { diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Url.php b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Url.php index 396a1085e..a9337988c 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Url.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Url.php @@ -3,34 +3,30 @@ namespace PicoFeed\Client; /** - * URL class + * URL class. * * @author Frederic Guillot - * @package Client */ class Url { /** - * URL + * URL. * - * @access private * @var string */ private $url = ''; /** - * URL components + * URL components. * - * @access private * @var array */ private $components = array(); /** - * Constructor + * Constructor. * - * @access public - * @param string $url URL + * @param string $url URL */ public function __construct($url) { @@ -51,28 +47,27 @@ class Url } /** - * Shortcut method to get an absolute url from relative url + * Shortcut method to get an absolute url from relative url. * * @static - * @access public - * @param mixed $item_url Unknown url (can be relative or not) - * @param mixed $website_url Website url + * + * @param mixed $item_url Unknown url (can be relative or not) + * @param mixed $website_url Website url + * * @return string */ public static function resolve($item_url, $website_url) { - $link = is_string($item_url) ? new Url($item_url) : $item_url; - $website = is_string($website_url) ? new Url($website_url) : $website_url; + $link = is_string($item_url) ? new self($item_url) : $item_url; + $website = is_string($website_url) ? new self($website_url) : $website_url; if ($link->isRelativeUrl()) { - if ($link->isRelativePath()) { return $link->getAbsoluteUrl($website->getBaseUrl($website->getBasePath())); } return $link->getAbsoluteUrl($website->getBaseUrl()); - } - else if ($link->isProtocolRelative()) { + } elseif ($link->isProtocolRelative()) { $link->setScheme($website->getScheme()); } @@ -80,24 +75,26 @@ class Url } /** - * Shortcut method to get a base url + * Shortcut method to get a base url. * * @static - * @access public - * @param string $url + * + * @param string $url + * * @return string */ public static function base($url) { - $link = new Url($url); + $link = new self($url); + return $link->getBaseUrl(); } /** - * Get the base URL + * Get the base URL. + * + * @param string $suffix Add a suffix to the url * - * @access public - * @param string $suffix Add a suffix to the url * @return string */ public function getBaseUrl($suffix = '') @@ -106,19 +103,18 @@ class Url } /** - * Get the absolute URL + * Get the absolute URL. + * + * @param string $base_url Use this url as base url * - * @access public - * @param string $base_url Use this url as base url * @return string */ public function getAbsoluteUrl($base_url = '') { if ($base_url) { - $base = new Url($base_url); + $base = new self($base_url); $url = $base->getAbsoluteUrl().substr($this->getFullPath(), 1); - } - else { + } else { $url = $this->hasHost() ? $this->getBaseUrl().$this->getFullPath() : ''; } @@ -126,50 +122,49 @@ class Url } /** - * Return true if the url is relative + * Return true if the url is relative. * - * @access public - * @return boolean + * @return bool */ public function isRelativeUrl() { - return ! $this->hasScheme() && ! $this->isProtocolRelative(); + return !$this->hasScheme() && !$this->isProtocolRelative(); } /** - * Return true if the path is relative + * Return true if the path is relative. * - * @access public - * @return boolean + * @return bool */ public function isRelativePath() { $path = $this->getPath(); - return empty($path) || $path{0} !== '/'; + + return empty($path) || $path{0} + !== '/'; } /** - * Filters the path of a URI + * Filters the path of a URI. * * Imported from Guzzle library: https://github.com/guzzle/psr7/blob/master/src/Uri.php#L568-L582 * - * @access public * @param $path + * * @return string */ public function filterPath($path, $charUnreserved = 'a-zA-Z0-9_\-\.~', $charSubDelims = '!\$&\'\(\)\*\+,;=') { return preg_replace_callback( - '/(?:[^' . $charUnreserved . $charSubDelims . ':@\/%]+|%(?![A-Fa-f0-9]{2}))/', + '/(?:[^'.$charUnreserved.$charSubDelims.':@\/%]+|%(?![A-Fa-f0-9]{2}))/', function (array $matches) { return rawurlencode($matches[0]); }, $path ); } /** - * Get the path + * Get the path. * - * @access public * @return string */ public function getPath() @@ -178,9 +173,8 @@ class Url } /** - * Get the base path + * Get the base path. * - * @access public * @return string */ public function getBasePath() @@ -194,9 +188,8 @@ class Url } /** - * Get the full path (path + querystring + fragment) + * Get the full path (path + querystring + fragment). * - * @access public * @return string */ public function getFullPath() @@ -210,9 +203,8 @@ class Url } /** - * Get the hostname + * Get the hostname. * - * @access public * @return string */ public function getHost() @@ -221,21 +213,20 @@ class Url } /** - * Return true if the url has a hostname + * Return true if the url has a hostname. * - * @access public - * @return boolean + * @return bool */ public function hasHost() { - return ! empty($this->components['host']); + return !empty($this->components['host']); } /** - * Get the scheme + * Get the scheme. + * + * @param string $suffix Suffix to add when there is a scheme * - * @access public - * @param string $suffix Suffix to add when there is a scheme * @return string */ public function getScheme($suffix = '') @@ -244,10 +235,10 @@ class Url } /** - * Set the scheme + * Set the scheme. + * + * @param string $scheme Set a scheme * - * @access public - * @param string $scheme Set a scheme * @return string */ public function setScheme($scheme) @@ -256,21 +247,20 @@ class Url } /** - * Return true if the url has a scheme + * Return true if the url has a scheme. * - * @access public - * @return boolean + * @return bool */ public function hasScheme() { - return ! empty($this->components['scheme']); + return !empty($this->components['scheme']); } /** - * Get the port + * Get the port. + * + * @param string $prefix Prefix to add when there is a port * - * @access public - * @param string $prefix Prefix to add when there is a port * @return string */ public function getPort($prefix = '') @@ -279,21 +269,19 @@ class Url } /** - * Return true if the url has a port + * Return true if the url has a port. * - * @access public - * @return boolean + * @return bool */ public function hasPort() { - return ! empty($this->components['port']); + return !empty($this->components['port']); } /** - * Return true if the url is protocol relative (start with //) + * Return true if the url is protocol relative (start with //). * - * @access public - * @return boolean + * @return bool */ public function isProtocolRelative() { diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Config/Config.php b/vendor/fguillot/picofeed/lib/PicoFeed/Config/Config.php index 1eaaeef9e..127968c04 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Config/Config.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Config/Config.php @@ -3,10 +3,9 @@ namespace PicoFeed\Config; /** - * Config class + * Config class. * * @author Frederic Guillot - * @package picofeed * * @method \PicoFeed\Config\Config setClientTimeout(integer $value) * @method \PicoFeed\Config\Config setClientUserAgent(string $value) @@ -34,7 +33,6 @@ namespace PicoFeed\Config; * @method \PicoFeed\Config\Config setFilterImageProxyUrl($value) * @method \PicoFeed\Config\Config setFilterImageProxyCallback($closure) * @method \PicoFeed\Config\Config setFilterImageProxyProtocol($value) - * * @method integer getClientTimeout() * @method string getClientUserAgent() * @method integer getMaxRedirections() @@ -65,22 +63,21 @@ namespace PicoFeed\Config; class Config { /** - * Contains all parameters + * Contains all parameters. * - * @access private * @var array */ private $container = array(); /** - * Magic method to have any kind of setters or getters + * Magic method to have any kind of setters or getters. + * + * @param string $name Getter/Setter name + * @param array $arguments Method arguments * - * @access public - * @param string $name Getter/Setter name - * @param array $arguments Method arguments * @return mixed */ - public function __call($name , array $arguments) + public function __call($name, array $arguments) { $name = strtolower($name); $prefix = substr($name, 0, 3); @@ -88,10 +85,11 @@ class Config if ($prefix === 'set' && isset($arguments[0])) { $this->container[$parameter] = $arguments[0]; + return $this; - } - else if ($prefix === 'get') { + } elseif ($prefix === 'get') { $default_value = isset($arguments[0]) ? $arguments[0] : null; + return isset($this->container[$parameter]) ? $this->container[$parameter] : $default_value; } } diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Encoding/Encoding.php b/vendor/fguillot/picofeed/lib/PicoFeed/Encoding/Encoding.php index 5821dd40c..fa0917e80 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Encoding/Encoding.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Encoding/Encoding.php @@ -3,9 +3,7 @@ namespace PicoFeed\Encoding; /** - * Encoding class - * - * @package Encoding + * Encoding class. */ class Encoding { @@ -17,7 +15,7 @@ class Encoding // suppress all notices since it isn't possible to silence only the // notice "Wrong charset, conversion from $in_encoding to $out_encoding is not allowed" - set_error_handler(function() {}, E_NOTICE); + set_error_handler(function () {}, E_NOTICE); // convert input to utf-8 and strip invalid characters $value = iconv($encoding, 'UTF-8//IGNORE', $input); diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Attribute.php b/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Attribute.php index 684dbf7ad..51f7e9e0b 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Attribute.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Attribute.php @@ -5,41 +5,36 @@ namespace PicoFeed\Filter; use PicoFeed\Client\Url; /** - * Attribute Filter class + * Attribute Filter class. * * @author Frederic Guillot - * @package Filter */ class Attribute { /** - * Image proxy url + * Image proxy url. * - * @access private * @var string */ private $image_proxy_url = ''; /** - * Image proxy callback + * Image proxy callback. * - * @access private * @var \Closure|null */ private $image_proxy_callback = null; /** - * lim