diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 5dace52..7a9066c 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,6 +1,8 @@ name: CI on: + schedule: + - cron: '00 1 * * 1' # At 01:00 on Mondays. push: branches: - master @@ -38,8 +40,8 @@ jobs: - name: Install dependencies run: composer install --prefer-dist --dev -# - name: Run fixer -# run: ./vendor/bin/php-cs-fixer fix --config=.php_cs_config.php -v --dry-run --stop-on-violation + - name: Run fixer + run: ./vendor/bin/php-cs-fixer fix . -v --dry-run --stop-on-violation - name: Run tests run: ./vendor/bin/phpunit diff --git a/.gitignore b/.gitignore index d79fc8d..2d466a4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ build vendor composer.lock +.phpunit.result.cache +.php-cs-fixer.cache # Share ide configuration !.idea/inspectionProfiles/* diff --git a/.php_cs_config.php b/.php_cs_config.php index 308bac4..debaeee 100644 --- a/.php_cs_config.php +++ b/.php_cs_config.php @@ -1,49 +1,38 @@ setRiskyAllowed(true) - ->setRules([ - '@PSR2' => true, - 'psr4' => true, - 'phpdoc_indent' => true, - 'array_syntax' => ['syntax' => 'short'], - 'blank_line_before_statement' => false, - 'strict_comparison' => true, - 'strict_param' => true, - 'no_null_property_initialization' => true, - 'yoda_style' => false, - 'ordered_imports' => ['sortAlgorithm' => 'alpha'], - 'ordered_class_elements' => [ - 'use_trait', - 'constant_public', - 'constant_protected', - 'constant_private', - 'property_public', - 'property_protected', - 'property_private', - 'construct', - 'destruct', - 'magic', - 'phpunit', - 'method_public', - 'method_protected', - 'method_private' - ], - ]) - ->setFinder( - PhpCsFixer\Finder::create() - ->in(__DIR__.'/src') - ->in(__DIR__.'/tests') - ) + +$finder = PhpCsFixer\Finder::create() + ->in(__DIR__.'/src') + ->in(__DIR__ . '/tests') ; -// special handling of fabbot.io service if it's using too old PHP CS Fixer version -try { - PhpCsFixer\FixerFactory::create() - ->registerBuiltInFixers() - ->registerCustomFixers($config->getCustomFixers()) - ->useRuleSet(new PhpCsFixer\RuleSet($config->getRules())); -} catch (PhpCsFixer\ConfigurationException\InvalidConfigurationException $e) { - $config->setRules([]); -} catch (UnexpectedValueException $e) { - $config->setRules([]); -} -return $config; \ No newline at end of file + +return PhpCsFixer\Config::create() + ->setFinder($finder) + ->setRiskyAllowed(true) + ->setRules([ + '@PSR2' => true, + 'psr4' => true, + 'phpdoc_indent' => true, + 'array_syntax' => ['syntax' => 'short'], + 'blank_line_before_statement' => false, + 'strict_comparison' => true, + 'strict_param' => true, + 'no_null_property_initialization' => true, + 'yoda_style' => false, + 'ordered_imports' => ['sortAlgorithm' => 'alpha'], + 'ordered_class_elements' => [ + 'use_trait', + 'constant_public', + 'constant_protected', + 'constant_private', + 'property_public', + 'property_protected', + 'property_private', + 'construct', + 'destruct', + 'magic', + 'phpunit', + 'method_public', + 'method_protected', + 'method_private' + ], + ]); diff --git a/composer.json b/composer.json index 364efbe..3d27c20 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "ext-dom": "*" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.0", + "friendsofphp/php-cs-fixer": "^3.16", "phpunit/phpunit": "^9.5.2" }, "autoload": { diff --git a/src/Collection/ElementCollection.php b/src/Collection/ElementCollection.php index 2238966..e2fc4af 100644 --- a/src/Collection/ElementCollection.php +++ b/src/Collection/ElementCollection.php @@ -11,7 +11,6 @@ */ class ElementCollection implements \IteratorAggregate, \Countable { - /** * @var Element[] */ diff --git a/src/Collection/Filters/StringFilter/RegexStringFilter.php b/src/Collection/Filters/StringFilter/RegexStringFilter.php index 9416a12..a1f3763 100644 --- a/src/Collection/Filters/StringFilter/RegexStringFilter.php +++ b/src/Collection/Filters/StringFilter/RegexStringFilter.php @@ -9,7 +9,6 @@ */ class RegexStringFilter implements StringFilterInterface { - /** * @var string */ diff --git a/src/Collection/Modify/StringModify/RegexReplace.php b/src/Collection/Modify/StringModify/RegexReplace.php index a01ad58..ab8a5bf 100644 --- a/src/Collection/Modify/StringModify/RegexReplace.php +++ b/src/Collection/Modify/StringModify/RegexReplace.php @@ -9,7 +9,6 @@ */ class RegexReplace implements StringModifyInterface { - /** * @var string */ diff --git a/src/Collection/ObjectCollection.php b/src/Collection/ObjectCollection.php index 9dfcfae..669d81d 100644 --- a/src/Collection/ObjectCollection.php +++ b/src/Collection/ObjectCollection.php @@ -11,7 +11,6 @@ */ class ObjectCollection implements \IteratorAggregate, \Countable { - /** * @var ElementFinderInterface[] */ diff --git a/src/Collection/StringCollection.php b/src/Collection/StringCollection.php index 05abf39..66630b5 100644 --- a/src/Collection/StringCollection.php +++ b/src/Collection/StringCollection.php @@ -12,7 +12,6 @@ */ class StringCollection implements \IteratorAggregate, \Countable { - /** * @var string[] */ diff --git a/src/DomNodeListAction/DomNodeListActionInterface.php b/src/DomNodeListAction/DomNodeListActionInterface.php index 36c3356..17e1249 100644 --- a/src/DomNodeListAction/DomNodeListActionInterface.php +++ b/src/DomNodeListAction/DomNodeListActionInterface.php @@ -1,4 +1,5 @@ dom = new \DomDocument(); $this->expressionTranslator = $translator ?? new XpathExpression(); $this->dom->registerNodeClass(\DOMElement::class, Element::class); @@ -180,12 +167,12 @@ final public function object(string $expression, bool $outerHtml = false): Objec foreach ($items as $node) { assert($node instanceof \DOMElement); $html = $outerHtml - ? NodeHelper::getOuterContent($node) - : NodeHelper::getInnerContent($node); + ? NodeHelper::getOuterContent($node) + : NodeHelper::getInnerContent($node); if (trim($html) === '') { $html = ''; } - if ($this->type === static::DOCUMENT_XML and strpos($html, 'type === static::DOCUMENT_XML and !str_contains($html, '' . $html . ''; } $result[] = new ElementFinder($html, $type, $this->expressionTranslator); @@ -225,7 +212,7 @@ private function setData(string $data): self $internalErrors = libxml_use_internal_errors(true); $disableEntities = false; if (\LIBXML_VERSION < 20900) { - $disableEntities = libxml_disable_entity_loader(true); + $disableEntities = libxml_disable_entity_loader(); } if (static::DOCUMENT_HTML === $this->type) { diff --git a/src/ElementFinder/Element.php b/src/ElementFinder/Element.php index 348eb27..9b7b988 100644 --- a/src/ElementFinder/Element.php +++ b/src/ElementFinder/Element.php @@ -9,7 +9,6 @@ */ class Element extends \DOMElement { - /** * @return array Array */ diff --git a/src/ElementFinderInterface.php b/src/ElementFinderInterface.php index 040f9e6..85341b8 100644 --- a/src/ElementFinderInterface.php +++ b/src/ElementFinderInterface.php @@ -13,7 +13,6 @@ */ interface ElementFinderInterface { - /** * @throws \Exception */ diff --git a/src/Helper/FormHelper.php b/src/Helper/FormHelper.php index 4a30f59..e59cfa1 100644 --- a/src/Helper/FormHelper.php +++ b/src/Helper/FormHelper.php @@ -11,7 +11,6 @@ */ class FormHelper { - /** * @var ElementFinderInterface */