From a4b365958788833d64fe08951159f845681d9820 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Thu, 14 Sep 2023 12:44:53 +0000 Subject: [PATCH] Apply fixes from StyleCI --- src/Expression/AppendCallbackExpression.php | 2 - .../DoubleQuotesCallbackExpression.php | 1 - .../StaticFloatCallbackExpression.php | 2 - .../StaticIntCallbackExpression.php | 2 - src/Trait/HasDomCrawlerGetter.php | 7 +- tests/SampleOnlineTest.php | 11 +- tests/SampleTest.php | 126 +++++++++--------- 7 files changed, 68 insertions(+), 83 deletions(-) diff --git a/src/Expression/AppendCallbackExpression.php b/src/Expression/AppendCallbackExpression.php index 7d3d96c..9c3a8cb 100644 --- a/src/Expression/AppendCallbackExpression.php +++ b/src/Expression/AppendCallbackExpression.php @@ -9,7 +9,6 @@ * the LICENSE file that was distributed with this source code. */ - declare(strict_types=1); namespace Cacing69\Cquery\Expression; @@ -35,7 +34,6 @@ public function __construct(string $raw) $extractRefNode = new DefinerExtractor($extract[1]); if (preg_match('/^\s*append\(\s*([a-z0-9_]*\(.+\))\s*\)$/', $raw, $extract)) { - $extractChild = $this->extractChild($extract[1]); $_childCallback = $extractChild->getExpression()->getCallback(); diff --git a/src/Expression/DoubleQuotesCallbackExpression.php b/src/Expression/DoubleQuotesCallbackExpression.php index 2417acd..44bc548 100644 --- a/src/Expression/DoubleQuotesCallbackExpression.php +++ b/src/Expression/DoubleQuotesCallbackExpression.php @@ -9,7 +9,6 @@ * the LICENSE file that was distributed with this source code. */ - declare(strict_types=1); namespace Cacing69\Cquery\Expression; diff --git a/src/Expression/StaticFloatCallbackExpression.php b/src/Expression/StaticFloatCallbackExpression.php index 470eddd..e85e61a 100644 --- a/src/Expression/StaticFloatCallbackExpression.php +++ b/src/Expression/StaticFloatCallbackExpression.php @@ -9,7 +9,6 @@ * the LICENSE file that was distributed with this source code. */ - declare(strict_types=1); namespace Cacing69\Cquery\Expression; @@ -34,7 +33,6 @@ public function __construct(string $raw) $this->callback = function ($value) use ($raw) { preg_match(self::$signature, $raw, $_extract); - return floatval($_extract[1]); }; diff --git a/src/Expression/StaticIntCallbackExpression.php b/src/Expression/StaticIntCallbackExpression.php index 802a403..b35a867 100644 --- a/src/Expression/StaticIntCallbackExpression.php +++ b/src/Expression/StaticIntCallbackExpression.php @@ -9,7 +9,6 @@ * the LICENSE file that was distributed with this source code. */ - declare(strict_types=1); namespace Cacing69\Cquery\Expression; @@ -34,7 +33,6 @@ public function __construct(string $raw) $this->callback = function ($value) use ($raw) { preg_match(self::$signature, $raw, $_extract); - return intval($_extract[1]); }; diff --git a/src/Trait/HasDomCrawlerGetter.php b/src/Trait/HasDomCrawlerGetter.php index 0fc327a..61c900a 100644 --- a/src/Trait/HasDomCrawlerGetter.php +++ b/src/Trait/HasDomCrawlerGetter.php @@ -42,7 +42,6 @@ public function get(): Collection $_data = $_data->extract($filterExepression->getCallMethodParameter()); } elseif ($filterExepression->getCallMethod() === 'filter') { throw new CqueryException("filter on `{$filterExepression->getCallMethod()}` not yet available"); - } elseif ($filterExepression->getCallMethod() === 'static') { throw new CqueryException("filter on `{$filterExepression->getCallMethod()}` not yet available"); } elseif ($filterExepression->getCallMethod() === 'static.extract') { @@ -104,7 +103,6 @@ public function get(): Collection ->each(function (Crawler $node, $i) use (&$_data, $definer) { $node->filter($definer->getExpression()->getRef())->each(function (Crawler $_node, $_i) use ($i, &$_data, $definer) { if (is_array($definer->getExpression()->getCallMethodParameter()) && count($definer->getExpression()->getCallMethodParameter()) === 1) { - $__callParameter = $definer->getExpression()->getCallMethodParameter()[0]; $__text = null; @@ -115,7 +113,7 @@ public function get(): Collection $__text = $_node->attr($__callParameter); } - if($definer->getExpression()->getCallback()) { + if ($definer->getExpression()->getCallback()) { $__callbackFilterEach = $definer->getExpression()->getCallback(); $__text = $__callbackFilterEach($__text); } @@ -144,7 +142,7 @@ public function get(): Collection ->filterXPath($definer->getExpression()->getNodeXpath()) ->extract($definer->getExpression()->getCallMethodParameter()); - if(count($_static) > 1) { + if (count($_static) > 1) { throw new CqueryException('you cannot append if there was multiple element exist on your document'); } @@ -177,7 +175,6 @@ public function get(): Collection }); // throw new CqueryException("error query definer, there are no matching rows each column."); - } elseif (count($_data ?? []) > $_bound) { // if(!($definer->getExpression() instanceof AppendNodeCallbackExpression)) { throw new CqueryException('error query definer, there are no matching rows each column.'); diff --git a/tests/SampleOnlineTest.php b/tests/SampleOnlineTest.php index 84543f8..dcf8182 100644 --- a/tests/SampleOnlineTest.php +++ b/tests/SampleOnlineTest.php @@ -18,10 +18,9 @@ final class SampleOnlineTest extends TestCase { - - /** - * @group ignore - */ + /** + * @group ignore + */ public function testGetGoogleTitle() { $data = new Cquery(GOOGLE); @@ -39,7 +38,6 @@ public function testGetGoogleTitle() /** * @group ignore */ - public function testHttpBinTestWithActions() { $data = new Cquery(HTTP_BIN_TEST_K6_FORM_POST); @@ -86,7 +84,6 @@ public function testGetAndLimitUserAgents() /** * @group ignore */ - public function testClickLinkOnSemver() { $data = new Cquery(SEMVER_ORG); @@ -116,7 +113,6 @@ public function testClickLinkOnSemver() /** * @group ignore */ - public function testFormSearchOnWikipedia() { $data = new Cquery(WIKIPEDIA); @@ -143,7 +139,6 @@ public function testFormSearchOnWikipedia() /** * @group ignore */ - public function testFormSearchOnWikipediaButWithClickFirst() { $data = new Cquery(WIKIPEDIA); diff --git a/tests/SampleTest.php b/tests/SampleTest.php index 7b8921d..3eb0095 100644 --- a/tests/SampleTest.php +++ b/tests/SampleTest.php @@ -1349,15 +1349,15 @@ public function testWithAppendUsedSelector() $this->assertCount(9, $result); - $this->assertSame("MAIN TITLE", $result[0]["head"]); - $this->assertSame("MAIN TITLE", $result[1]["head"]); - $this->assertSame("MAIN TITLE", $result[2]["head"]); - $this->assertSame("MAIN TITLE", $result[3]["head"]); - $this->assertSame("MAIN TITLE", $result[4]["head"]); - $this->assertSame("MAIN TITLE", $result[5]["head"]); - $this->assertSame("MAIN TITLE", $result[6]["head"]); - $this->assertSame("MAIN TITLE", $result[7]["head"]); - $this->assertSame("MAIN TITLE", $result[8]["head"]); + $this->assertSame('MAIN TITLE', $result[0]['head']); + $this->assertSame('MAIN TITLE', $result[1]['head']); + $this->assertSame('MAIN TITLE', $result[2]['head']); + $this->assertSame('MAIN TITLE', $result[3]['head']); + $this->assertSame('MAIN TITLE', $result[4]['head']); + $this->assertSame('MAIN TITLE', $result[5]['head']); + $this->assertSame('MAIN TITLE', $result[6]['head']); + $this->assertSame('MAIN TITLE', $result[7]['head']); + $this->assertSame('MAIN TITLE', $result[8]['head']); } public function testWithAppendNestedUsedSelector() @@ -1375,15 +1375,15 @@ public function testWithAppendNestedUsedSelector() $this->assertCount(9, $result); - $this->assertSame("main-txt content-title", $result[0]["head_class"]); - $this->assertSame("main-txt content-title", $result[1]["head_class"]); - $this->assertSame("main-txt content-title", $result[2]["head_class"]); - $this->assertSame("main-txt content-title", $result[3]["head_class"]); - $this->assertSame("main-txt content-title", $result[4]["head_class"]); - $this->assertSame("main-txt content-title", $result[5]["head_class"]); - $this->assertSame("main-txt content-title", $result[6]["head_class"]); - $this->assertSame("main-txt content-title", $result[7]["head_class"]); - $this->assertSame("main-txt content-title", $result[8]["head_class"]); + $this->assertSame('main-txt content-title', $result[0]['head_class']); + $this->assertSame('main-txt content-title', $result[1]['head_class']); + $this->assertSame('main-txt content-title', $result[2]['head_class']); + $this->assertSame('main-txt content-title', $result[3]['head_class']); + $this->assertSame('main-txt content-title', $result[4]['head_class']); + $this->assertSame('main-txt content-title', $result[5]['head_class']); + $this->assertSame('main-txt content-title', $result[6]['head_class']); + $this->assertSame('main-txt content-title', $result[7]['head_class']); + $this->assertSame('main-txt content-title', $result[8]['head_class']); } public function testWithIntWithAppendExpressionUsedSelector() @@ -1401,15 +1401,15 @@ public function testWithIntWithAppendExpressionUsedSelector() $this->assertCount(9, $result); - $this->assertSame(9, $result[0]["head_id"]); - $this->assertSame(9, $result[1]["head_id"]); - $this->assertSame(9, $result[2]["head_id"]); - $this->assertSame(9, $result[3]["head_id"]); - $this->assertSame(9, $result[4]["head_id"]); - $this->assertSame(9, $result[5]["head_id"]); - $this->assertSame(9, $result[6]["head_id"]); - $this->assertSame(9, $result[7]["head_id"]); - $this->assertSame(9, $result[8]["head_id"]); + $this->assertSame(9, $result[0]['head_id']); + $this->assertSame(9, $result[1]['head_id']); + $this->assertSame(9, $result[2]['head_id']); + $this->assertSame(9, $result[3]['head_id']); + $this->assertSame(9, $result[4]['head_id']); + $this->assertSame(9, $result[5]['head_id']); + $this->assertSame(9, $result[6]['head_id']); + $this->assertSame(9, $result[7]['head_id']); + $this->assertSame(9, $result[8]['head_id']); } public function testWithAppendWithIntExpressionUsedSelector() @@ -1427,15 +1427,15 @@ public function testWithAppendWithIntExpressionUsedSelector() $this->assertCount(9, $result); - $this->assertSame(9, $result[0]["head_id"]); - $this->assertSame(9, $result[1]["head_id"]); - $this->assertSame(9, $result[2]["head_id"]); - $this->assertSame(9, $result[3]["head_id"]); - $this->assertSame(9, $result[4]["head_id"]); - $this->assertSame(9, $result[5]["head_id"]); - $this->assertSame(9, $result[6]["head_id"]); - $this->assertSame(9, $result[7]["head_id"]); - $this->assertSame(9, $result[8]["head_id"]); + $this->assertSame(9, $result[0]['head_id']); + $this->assertSame(9, $result[1]['head_id']); + $this->assertSame(9, $result[2]['head_id']); + $this->assertSame(9, $result[3]['head_id']); + $this->assertSame(9, $result[4]['head_id']); + $this->assertSame(9, $result[5]['head_id']); + $this->assertSame(9, $result[6]['head_id']); + $this->assertSame(9, $result[7]['head_id']); + $this->assertSame(9, $result[8]['head_id']); } public function testWithAppendWithDoubleQupteExpression() @@ -1453,15 +1453,15 @@ public function testWithAppendWithDoubleQupteExpression() $this->assertCount(9, $result); - $this->assertSame("staticValue", $result[0]["static_value"]); - $this->assertSame("staticValue", $result[1]["static_value"]); - $this->assertSame("staticValue", $result[2]["static_value"]); - $this->assertSame("staticValue", $result[3]["static_value"]); - $this->assertSame("staticValue", $result[4]["static_value"]); - $this->assertSame("staticValue", $result[5]["static_value"]); - $this->assertSame("staticValue", $result[6]["static_value"]); - $this->assertSame("staticValue", $result[7]["static_value"]); - $this->assertSame("staticValue", $result[8]["static_value"]); + $this->assertSame('staticValue', $result[0]['static_value']); + $this->assertSame('staticValue', $result[1]['static_value']); + $this->assertSame('staticValue', $result[2]['static_value']); + $this->assertSame('staticValue', $result[3]['static_value']); + $this->assertSame('staticValue', $result[4]['static_value']); + $this->assertSame('staticValue', $result[5]['static_value']); + $this->assertSame('staticValue', $result[6]['static_value']); + $this->assertSame('staticValue', $result[7]['static_value']); + $this->assertSame('staticValue', $result[8]['static_value']); } public function testWithStaticNumericExpression() @@ -1479,15 +1479,15 @@ public function testWithStaticNumericExpression() $this->assertCount(9, $result); - $this->assertSame(19, $result[0]["static_number"]); - $this->assertSame(19, $result[1]["static_number"]); - $this->assertSame(19, $result[2]["static_number"]); - $this->assertSame(19, $result[3]["static_number"]); - $this->assertSame(19, $result[4]["static_number"]); - $this->assertSame(19, $result[5]["static_number"]); - $this->assertSame(19, $result[6]["static_number"]); - $this->assertSame(19, $result[7]["static_number"]); - $this->assertSame(19, $result[8]["static_number"]); + $this->assertSame(19, $result[0]['static_number']); + $this->assertSame(19, $result[1]['static_number']); + $this->assertSame(19, $result[2]['static_number']); + $this->assertSame(19, $result[3]['static_number']); + $this->assertSame(19, $result[4]['static_number']); + $this->assertSame(19, $result[5]['static_number']); + $this->assertSame(19, $result[6]['static_number']); + $this->assertSame(19, $result[7]['static_number']); + $this->assertSame(19, $result[8]['static_number']); } public function testWithStaticFloatExpression() @@ -1505,15 +1505,15 @@ public function testWithStaticFloatExpression() $this->assertCount(9, $result); - $this->assertSame(1.9, $result[0]["static_number"]); - $this->assertSame(1.9, $result[1]["static_number"]); - $this->assertSame(1.9, $result[2]["static_number"]); - $this->assertSame(1.9, $result[3]["static_number"]); - $this->assertSame(1.9, $result[4]["static_number"]); - $this->assertSame(1.9, $result[5]["static_number"]); - $this->assertSame(1.9, $result[6]["static_number"]); - $this->assertSame(1.9, $result[7]["static_number"]); - $this->assertSame(1.9, $result[8]["static_number"]); + $this->assertSame(1.9, $result[0]['static_number']); + $this->assertSame(1.9, $result[1]['static_number']); + $this->assertSame(1.9, $result[2]['static_number']); + $this->assertSame(1.9, $result[3]['static_number']); + $this->assertSame(1.9, $result[4]['static_number']); + $this->assertSame(1.9, $result[5]['static_number']); + $this->assertSame(1.9, $result[6]['static_number']); + $this->assertSame(1.9, $result[7]['static_number']); + $this->assertSame(1.9, $result[8]['static_number']); } public function testWithFilterNested()