From 4a3ae1ca060dab7390e3f2dc4eaa7b74f535439e Mon Sep 17 00:00:00 2001 From: rem42 Date: Wed, 17 Feb 2021 09:05:57 +0100 Subject: [PATCH] chore: clean useless things --- .travis.yml | 2 -- README.md | 2 +- composer.json | 9 +++------ rector.yaml | 21 --------------------- src/Annotation/ExtractAnnotation.php | 14 +++++++------- src/Api/ApiInterface.php | 2 +- src/Client.php | 6 +++--- src/Request/RequestBody.php | 2 +- tests/Annotation/ExtractAnnotationTest.php | 3 +++ tests/ClientTest.php | 10 ++++++---- tests/Fixtures/HttpClientTest.php | 4 ++++ 11 files changed, 29 insertions(+), 46 deletions(-) delete mode 100644 rector.yaml diff --git a/.travis.yml b/.travis.yml index 63f5f0d..edf3ab9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,8 +21,6 @@ jobs: script: composer run-script static-analysis - script: composer run-script code-style-check name: PHP CS-FIXER - - script: composer run-script rector-check - name: RECTOR - script: composer run-script unit-test after_script: ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT name: UNIT-TESTS diff --git a/README.md b/README.md index 3086e57..bf26f94 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Installation ------------ ````bash -$ composer require rem42/scraper "2.x-dev" +composer require rem42/scraper "2.x-dev" ```` Requirement diff --git a/composer.json b/composer.json index 16d74ae..6fcc826 100644 --- a/composer.json +++ b/composer.json @@ -15,11 +15,10 @@ "symfony/serializer-pack": "^1.0" }, "require-dev": { - "rector/rector": "0.7.*", "rem42/php-cs-fixer-config": "^1.0", - "phpstan/phpstan": "0.12.*", - "phpunit/phpunit": "9.*", - "php-coveralls/php-coveralls": "2.*" + "phpstan/phpstan": "^0.12", + "phpunit/phpunit": "^9.0", + "php-coveralls/php-coveralls": "^2.0" }, "suggest": { "ext-json": "If you need to support JSON format", @@ -49,8 +48,6 @@ "static-analysis": "./bin/phpstan analyse src --level=max --no-progress -vvv", "code-style-check": "./bin/php-cs-fixer fix --dry-run --verbose", "code-style-fix": "./bin/php-cs-fixer fix", - "rector-check": "./bin/rector process --dry-run", - "rector-fix": "./bin/rector process", "unit-test": "./bin/phpunit" } } diff --git a/rector.yaml b/rector.yaml deleted file mode 100644 index 83e2d50..0000000 --- a/rector.yaml +++ /dev/null @@ -1,21 +0,0 @@ -parameters: - php_version_features: '7.4' - auto_import_names: true - import_short_classes: false - paths: - - 'src' - - 'tests' - sets: - - 'code-quality' - - 'coding-style' - - 'dead-code' - - 'guzzle' - - 'php74' - - 'phpstan' - - 'phpunit' - #- 'privatization' - - 'psr-4' - - 'solid' - - 'type-declaration' - exclude_rectors: - - 'Rector\TypeDeclaration\Rector\Property\PropertyTypeDeclarationRector' # Use PHP74 to define property diff --git a/src/Annotation/ExtractAnnotation.php b/src/Annotation/ExtractAnnotation.php index 296cafd..3fbae83 100644 --- a/src/Annotation/ExtractAnnotation.php +++ b/src/Annotation/ExtractAnnotation.php @@ -17,7 +17,7 @@ final class ExtractAnnotation public function __construct(AnnotationReader $reader, ScraperRequest $request) { - $this->reflexionClass = new \ReflectionClass(get_class($request)); + $this->reflexionClass = new \ReflectionClass(\get_class($request)); $this->reader = $reader; $this->request = $request; $this->scraperAnnotation = new Scraper(); @@ -33,9 +33,9 @@ public static function extract(ScraperRequest $request): Scraper } /** - * @param \ReflectionClass|null $reflectionClass + * @param null|\ReflectionClass $reflectionClass */ - private function recursive(\ReflectionClass $reflectionClass = null): void + private function recursive(\ReflectionClass $reflectionClass = null): void { if (null === $reflectionClass) { $reflectionClass = $this->reflexionClass; @@ -61,7 +61,7 @@ private function extractAnnotation(Scraper $annotation): void $vars = get_object_vars($this->scraperAnnotation); // Initializing class properties foreach ($vars as $property => $value) { - $scraper->$property = $value; + $scraper->{$property} = $value; } $vars = get_object_vars($annotation); @@ -70,7 +70,7 @@ private function extractAnnotation(Scraper $annotation): void if (preg_match_all('#{(.*?)}#', $value, $matchs)) { foreach ($matchs[1] as $match) { $method = 'get' . ucfirst($match); - $requestValue = $this->request->$method(); + $requestValue = $this->request->{$method}(); $value = str_replace('{' . $match . '}', $requestValue, $value); } } @@ -80,7 +80,7 @@ private function extractAnnotation(Scraper $annotation): void continue; } - $scraper->$property = $value; + $scraper->{$property} = $value; } $this->scraperAnnotation = $scraper; @@ -92,7 +92,7 @@ private function handlePath(Scraper $scraper, ?string $path = null): void return; } - if (strlen($path) > 0 && '/' === $path[0]) { + if (\strlen($path) > 0 && '/' === $path[0]) { $scraper->path = $path; } elseif (isset($scraper->path)) { $scraper->path = rtrim($scraper->path, '/') . '/' . ltrim($path, '/'); diff --git a/src/Api/ApiInterface.php b/src/Api/ApiInterface.php index dfe6c25..50716d5 100644 --- a/src/Api/ApiInterface.php +++ b/src/Api/ApiInterface.php @@ -5,7 +5,7 @@ interface ApiInterface { /** - * @return object|array|bool + * @return array|bool|object */ public function execute(); } diff --git a/src/Client.php b/src/Client.php index 4ba81b7..7718992 100644 --- a/src/Client.php +++ b/src/Client.php @@ -24,12 +24,12 @@ public function __construct(HttpClientInterface $httpClient) } /** - * @return object|array|bool + * @return array|bool|object */ public function send(ScraperRequest $request) { - $this->request = $request; - $annotation = ExtractAnnotation::extract($this->request); + $this->request = $request; + $annotation = ExtractAnnotation::extract($this->request); $options = []; diff --git a/src/Request/RequestBody.php b/src/Request/RequestBody.php index ca849c0..c2f3ecc 100644 --- a/src/Request/RequestBody.php +++ b/src/Request/RequestBody.php @@ -5,7 +5,7 @@ interface RequestBody { /** - * @return array|string|resource + * @return array|resource|string */ public function getBody(); } diff --git a/tests/Annotation/ExtractAnnotationTest.php b/tests/Annotation/ExtractAnnotationTest.php index d1e29a4..45ab320 100644 --- a/tests/Annotation/ExtractAnnotationTest.php +++ b/tests/Annotation/ExtractAnnotationTest.php @@ -11,6 +11,9 @@ use Scraper\Scraper\Tests\Fixtures\TestWithAnnotationParametersRequest; use Scraper\Scraper\Tests\Fixtures\TestWithoutAnnotationRequest; +/** + * @internal + */ final class ExtractAnnotationTest extends TestCase { public function testExtractRequest(): void diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 9d8a854..c6b5d73 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -14,6 +14,9 @@ use Symfony\Contracts\HttpClient\ResponseInterface; use Symfony\Contracts\HttpClient\ResponseStreamInterface; +/** + * @internal + */ final class ClientTest extends TestCase { public function testSend(): void @@ -32,7 +35,7 @@ public function testSend(): void $result = $client->send($request); - $this->assertEquals(true, $result); + $this->assertTrue($result); } public function testResponseWithException(): void @@ -45,10 +48,9 @@ public function testResponseWithException(): void $client = new Client($httpClient); $request = new TestRequest(); - //$this->expectException(ServerExceptionInterface::class); $this->expectException(\Exception::class); - $result = $client->send($request); + $client->send($request); } public function testWithAllOptions(): void @@ -135,7 +137,7 @@ public function testPrivateSend(): void $client = new Client($httpClient); - $reflection = new \ReflectionClass(get_class($client)); + $reflection = new \ReflectionClass(\get_class($client)); $method = $reflection->getMethod('getApiReflectionClass'); $method->setAccessible(true); diff --git a/tests/Fixtures/HttpClientTest.php b/tests/Fixtures/HttpClientTest.php index 8bf9820..f507a74 100644 --- a/tests/Fixtures/HttpClientTest.php +++ b/tests/Fixtures/HttpClientTest.php @@ -6,6 +6,10 @@ use Symfony\Contracts\HttpClient\ResponseInterface; use Symfony\Contracts\HttpClient\ResponseStreamInterface; +/** + * @internal + * @coversNothing + */ final class HttpClientTest implements HttpClientInterface { private ResponseInterface $response;