diff options
author | Andres Rey <[email protected]> | 2016-12-23 19:11:32 -0300 |
---|---|---|
committer | GitHub <[email protected]> | 2016-12-23 19:11:32 -0300 |
commit | dd353da76f26f1822278279f5aa81ed43625c300 (patch) | |
tree | 2eddabe4998c850f3adf05ea93cb2385ec2d5e8c /src | |
parent | acf1af50defa03cd5ca884a478c2f214ca650025 (diff) | |
parent | 6e9fa0706e97627e1749b0a5e6a0215c472ccaf1 (diff) |
Merge pull request #12 from andreskrey/analysis-q5A7rj
Apply fixes from StyleCI
Diffstat (limited to 'src')
-rw-r--r-- | src/HTMLParser.php | 29 | ||||
-rw-r--r-- | src/Readability.php | 23 | ||||
-rw-r--r-- | src/ReadabilityInterface.php | 4 |
3 files changed, 28 insertions, 28 deletions
diff --git a/src/HTMLParser.php b/src/HTMLParser.php index 80ad3fe..9157c79 100644 --- a/src/HTMLParser.php +++ b/src/HTMLParser.php @@ -86,7 +86,7 @@ class HTMLParser 'pre', 'table', 'ul', - 'select' + 'select', ]; /** @@ -104,7 +104,7 @@ class HTMLParser 'weightClasses' => true, 'removeReadabilityTags' => true, 'fixRelativeURLs' => false, - 'originalURL' => 'http://fakehost' + 'originalURL' => 'http://fakehost', ]; $this->environment = Environment::createDefaultEnvironment($defaults); @@ -192,7 +192,7 @@ class HTMLParser 'author' => isset($this->metadata['author']) ? $this->metadata['author'] : null, 'image' => isset($this->metadata['image']) ? $this->metadata['image'] : null, 'article' => $result, - 'html' => $result->C14N() + 'html' => $result->C14N(), ]; } @@ -358,7 +358,6 @@ class HTMLParser return $pathBase . $uri; } - private function nextElement($node) { $next = $node; @@ -765,7 +764,6 @@ class HTMLParser * along with appendChild, would shift the nodes position and the current foreach will behave in * unpredictable ways. */ - } } @@ -779,7 +777,7 @@ class HTMLParser } /** - * TODO To be moved to Readability + * TODO To be moved to Readability. * * @param DOMDocument $article * @@ -827,7 +825,7 @@ class HTMLParser } /** - * TODO To be moved to Readability + * TODO To be moved to Readability. * * @param DOMDocument $article * @@ -845,7 +843,7 @@ class HTMLParser } /** - * TODO To be moved to Readability + * TODO To be moved to Readability. * * @param DOMDocument $article * @@ -865,12 +863,11 @@ class HTMLParser // TODO must be done via readability $paragraph->parentNode->removeChild($paragraph); } - } } /** - * TODO To be moved to Readability + * TODO To be moved to Readability. * * @param DOMDocument $article * @@ -893,7 +890,6 @@ class HTMLParser $DOMNodeList = $article->getElementsByTagName($tag); $length = $DOMNodeList->length; for ($i = 0; $i < $length; $i++) { - $node = $DOMNodeList->item($length - 1 - $i); $node = new Readability($node); @@ -944,17 +940,17 @@ class HTMLParser } } } - } /** * Clean a node of all elements of type "tag". - * (Unless it's a youtube/vimeo video. People love movies.) + * (Unless it's a youtube/vimeo video. People love movies.). * * TODO To be moved to Readability * * @param Element * @param string tag to clean + * * @return void **/ public function _clean(DOMDocument $article, $tag) @@ -990,6 +986,7 @@ class HTMLParser * TODO To be moved to Readability * * @param DOMDocument $article + * * @return void **/ public function _cleanHeaders(DOMDocument $article) @@ -1006,11 +1003,12 @@ class HTMLParser } /** - * Remove the passed node + * Remove the passed node. * * TODO To be moved to Readability * * @param \DOMNode $node + * * @return void **/ public function removeNode(\DOMNode $node) @@ -1025,7 +1023,7 @@ class HTMLParser * Checks if the node is a byline. * * @param Readability $node - * @param string $matchString + * @param string $matchString * * @return bool */ @@ -1070,6 +1068,7 @@ class HTMLParser * tags are, in practice, paragraphs. * * @param Readability $node + * * @return bool */ private function hasSinglePNode(Readability $node) diff --git a/src/Readability.php b/src/Readability.php index 8d6ecc4..027858f 100644 --- a/src/Readability.php +++ b/src/Readability.php @@ -198,7 +198,7 @@ class Readability extends Element implements ReadabilityInterface */ public function getClassWeight() { -// TODO To implement. How to get config from html parser from readability + // TODO To implement. How to get config from html parser from readability // if ($this->getConfig()->getOption('weightClasses')) { // return 0; // } @@ -253,7 +253,7 @@ class Readability extends Element implements ReadabilityInterface { // Check if the setAttribute method exists, as some elements lack of it (and calling it anyway throws an exception) if (method_exists($this->node, 'setAttribute')) { - $this->contentScore = (float)$score; + $this->contentScore = (float) $score; // Set score in an attribute of the tag to prevent losing it while creating new Readability objects. $this->node->setAttribute('data-readability', $this->contentScore); @@ -283,7 +283,7 @@ class Readability extends Element implements ReadabilityInterface /** * Changes the node tag name. Since tagName on DOMElement is a read only value, this must be done creating a new - * element with the new tag name and importing it to the main DOMDocument + * element with the new tag name and importing it to the main DOMDocument. * * @param string $value */ @@ -316,7 +316,7 @@ class Readability extends Element implements ReadabilityInterface } /** - * Removes the current node and returns the next node to be parsed (child, sibling or parent) + * Removes the current node and returns the next node to be parsed (child, sibling or parent). * * @param Readability $node * @@ -335,11 +335,10 @@ class Readability extends Element implements ReadabilityInterface * for parents. * * @param Readability $originalNode - * @param bool $ignoreSelfAndKids + * @param bool $ignoreSelfAndKids * * @return Readability */ - public function getNextNode($originalNode, $ignoreSelfAndKids = false) { /* @@ -402,7 +401,6 @@ class Readability extends Element implements ReadabilityInterface * Replaces child node with a new one. * * @param Readability $newNode - * */ public function replaceChild(Readability $newNode) { @@ -413,7 +411,7 @@ class Readability extends Element implements ReadabilityInterface * Creates a new node based on the text content of the original node. * * @param Readability $originalNode - * @param string $tagName + * @param string $tagName * * @return Readability */ @@ -460,8 +458,9 @@ class Readability extends Element implements ReadabilityInterface * provided one. * * @param Readability $node - * @param string $tagName - * @param int $maxDepth + * @param string $tagName + * @param int $maxDepth + * * @return bool */ public function hasAncestorTag(Readability $node, $tagName, $maxDepth = 3) @@ -477,16 +476,18 @@ class Readability extends Element implements ReadabilityInterface $node = $node->getParent(); $depth++; } + return false; } /** * @param bool $filterEmptyDOMText Filter empty DOMText nodes? + * * @return array */ public function getChildren($filterEmptyDOMText = false) { - $ret = array(); + $ret = []; /** @var \DOMNode $node */ foreach ($this->node->childNodes as $node) { if ($filterEmptyDOMText && $node->nodeName === '#text' && !trim($node->nodeValue)) { diff --git a/src/ReadabilityInterface.php b/src/ReadabilityInterface.php index 5917454..0dee01b 100644 --- a/src/ReadabilityInterface.php +++ b/src/ReadabilityInterface.php @@ -47,6 +47,7 @@ interface ReadabilityInterface extends ElementInterface /** * @param bool $normalize Normalize white space? + * * @return string */ public function getTextContent($normalize); @@ -70,11 +71,10 @@ interface ReadabilityInterface extends ElementInterface /** * @param Readability $originalNode - * @param bool $ignoreSelfAndKids + * @param bool $ignoreSelfAndKids * * @return Readability */ - public function getNextNode($originalNode, $ignoreSelfAndKids = false); /** |