From b71d6c68c8fd5bc1628532d928632868032c43c1 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Thu, 24 Oct 2019 10:39:20 +0200 Subject: [PATCH] Improve phpdoc --- src/Css/Processor.php | 5 ++++- src/Css/Property/Processor.php | 21 +++++++++++++-------- src/Css/Property/Property.php | 4 ++-- src/Css/Rule/Processor.php | 26 +++++++++++++++++--------- src/Css/Rule/Rule.php | 5 +++-- src/CssToInlineStyles.php | 6 ++++++ 6 files changed, 45 insertions(+), 22 deletions(-) diff --git a/src/Css/Processor.php b/src/Css/Processor.php index 75d0dcc..0c5ceb1 100644 --- a/src/Css/Processor.php +++ b/src/Css/Processor.php @@ -11,7 +11,8 @@ class Processor * Get the rules from a given CSS-string * * @param string $css - * @param array $existingRules + * @param Rule[] $existingRules + * * @return Rule[] */ public function getRules($css, $existingRules = array()) @@ -27,6 +28,7 @@ public function getRules($css, $existingRules = array()) * Get the CSS from the style-tags in the given HTML-string * * @param string $html + * * @return string */ public function getCssFromStyleTags($html) @@ -47,6 +49,7 @@ public function getCssFromStyleTags($html) /** * @param string $css + * * @return string */ private function doCleanup($css) diff --git a/src/Css/Property/Processor.php b/src/Css/Property/Processor.php index 2751fe6..3b01861 100644 --- a/src/Css/Property/Processor.php +++ b/src/Css/Property/Processor.php @@ -7,10 +7,11 @@ class Processor { /** - * Split a string into seperate properties + * Split a string into separate properties * * @param string $propertiesString - * @return array + * + * @return string[] */ public function splitIntoSeparateProperties($propertiesString) { @@ -40,8 +41,9 @@ public function splitIntoSeparateProperties($propertiesString) } /** - * @param $string - * @return mixed|string + * @param string $string + * + * @return string */ private function cleanup($string) { @@ -58,9 +60,10 @@ private function cleanup($string) } /** - * Convert a property-string into an object + * Converts a property-string into an object * * @param string $property + * * @return Property|null */ public function convertToObject($property, Specificity $specificity = null) @@ -82,9 +85,10 @@ public function convertToObject($property, Specificity $specificity = null) } /** - * Convert an array of property-strings into objects + * Converts an array of property-strings into objects + * + * @param string[] $properties * - * @param array $properties * @return Property[] */ public function convertArrayToObjects(array $properties, Specificity $specificity = null) @@ -106,7 +110,8 @@ public function convertArrayToObjects(array $properties, Specificity $specificit /** * Build the property-string for multiple properties * - * @param array $properties + * @param Property[] $properties + * * @return string */ public function buildPropertiesString(array $properties) diff --git a/src/Css/Property/Property.php b/src/Css/Property/Property.php index 0452461..c8970cf 100644 --- a/src/Css/Property/Property.php +++ b/src/Css/Property/Property.php @@ -23,8 +23,8 @@ final class Property /** * Property constructor. - * @param $name - * @param $value + * @param string $name + * @param string $value * @param Specificity|null $specificity */ public function __construct($name, $value, Specificity $specificity = null) diff --git a/src/Css/Rule/Processor.php b/src/Css/Rule/Processor.php index b5dddb5..d183262 100644 --- a/src/Css/Rule/Processor.php +++ b/src/Css/Rule/Processor.php @@ -8,10 +8,11 @@ class Processor { /** - * Split a string into seperate rules + * Splits a string into separate rules * * @param string $rulesString - * @return array + * + * @return string[] */ public function splitIntoSeparateRules($rulesString) { @@ -22,6 +23,7 @@ public function splitIntoSeparateRules($rulesString) /** * @param string $string + * * @return string */ private function cleanup($string) @@ -39,11 +41,12 @@ private function cleanup($string) } /** - * Convert a rule-string into an object + * Converts a rule-string into an object * * @param string $rule * @param int $originalOrder - * @return array + * + * @return Rule[] */ public function convertToObjects($rule, $originalOrder) { @@ -74,11 +77,13 @@ public function convertToObjects($rule, $originalOrder) } /** - * Calculate the specificity based on a CSS Selector string, + * Calculates the specificity based on a CSS Selector string, * Based on the patterns from premailer/css_parser by Alex Dunae * * @see https://github.com/premailer/css_parser/blob/master/lib/css_parser/regexps.rb + * * @param string $selector + * * @return Specificity */ public function calculateSpecificityBasedOnASelector($selector) @@ -118,7 +123,9 @@ public function calculateSpecificityBasedOnASelector($selector) } /** - * @param array $rules + * @param string[] $rules + * @param Rule[] $objects + * * @return Rule[] */ public function convertArrayToObjects(array $rules, array $objects = array()) @@ -133,12 +140,13 @@ public function convertArrayToObjects(array $rules, array $objects = array()) } /** - * Sort an array on the specificity element in an ascending way + * Sorts an array on the specificity element in an ascending way * Lower specificity will be sorted to the beginning of the array * + * @param Rule $e1 The first element. + * @param Rule $e2 The second element. + * * @return int - * @param Rule $e1 The first element. - * @param Rule $e2 The second element. */ public static function sortOnSpecificity(Rule $e1, Rule $e2) { diff --git a/src/Css/Rule/Rule.php b/src/Css/Rule/Rule.php index 1f2b59f..563889e 100644 --- a/src/Css/Rule/Rule.php +++ b/src/Css/Rule/Rule.php @@ -3,6 +3,7 @@ namespace TijsVerkoyen\CssToInlineStyles\Css\Rule; use Symfony\Component\CssSelector\Node\Specificity; +use TijsVerkoyen\CssToInlineStyles\Css\Property\Property; final class Rule { @@ -12,7 +13,7 @@ final class Rule private $selector; /** - * @var array + * @var Property[] */ private $properties; @@ -55,7 +56,7 @@ public function getSelector() /** * Get properties * - * @return array + * @return Property[] */ public function getProperties() { diff --git a/src/CssToInlineStyles.php b/src/CssToInlineStyles.php index cec1d4c..3268c5f 100644 --- a/src/CssToInlineStyles.php +++ b/src/CssToInlineStyles.php @@ -28,6 +28,7 @@ public function __construct() * * @param string $html * @param string $css + * * @return string */ public function convert($html, $css = null) @@ -54,6 +55,7 @@ public function convert($html, $css = null) * * @param \DOMElement $element * @param Css\Property\Property[] $properties + * * @return \DOMElement */ public function inlineCssOnElement(\DOMElement $element, array $properties) @@ -88,6 +90,7 @@ public function inlineCssOnElement(\DOMElement $element, array $properties) * Get the current inline styles for a given DOMElement * * @param \DOMElement $element + * * @return Css\Property\Property[] */ public function getInlineStyles(\DOMElement $element) @@ -103,6 +106,7 @@ public function getInlineStyles(\DOMElement $element) /** * @param string $html + * * @return \DOMDocument */ protected function createDomDocumentFromHtml($html) @@ -118,6 +122,7 @@ protected function createDomDocumentFromHtml($html) /** * @param \DOMDocument $document + * * @return string */ protected function getHtmlFromDocument(\DOMDocument $document) @@ -144,6 +149,7 @@ protected function getHtmlFromDocument(\DOMDocument $document) /** * @param \DOMDocument $document * @param Css\Rule\Rule[] $rules + * * @return \DOMDocument */ protected function inline(\DOMDocument $document, array $rules)