Skip to content

Commit

Permalink
chore: clean useless things
Browse files Browse the repository at this point in the history
  • Loading branch information
rem42 committed Feb 17, 2021
1 parent e98ff3b commit 4a3ae1c
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 46 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Installation
------------

````bash
$ composer require rem42/scraper "2.x-dev"
composer require rem42/scraper "2.x-dev"
````

Requirement
Expand Down
9 changes: 3 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
}
21 changes: 0 additions & 21 deletions rector.yaml

This file was deleted.

14 changes: 7 additions & 7 deletions src/Annotation/ExtractAnnotation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -33,9 +33,9 @@ public static function extract(ScraperRequest $request): Scraper
}

/**
* @param \ReflectionClass<ScraperRequest>|null $reflectionClass
* @param null|\ReflectionClass<ScraperRequest> $reflectionClass
*/
private function recursive(\ReflectionClass $reflectionClass = null): void
private function recursive(\ReflectionClass $reflectionClass = null): void
{
if (null === $reflectionClass) {
$reflectionClass = $this->reflexionClass;
Expand All @@ -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);
Expand All @@ -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);
}
}
Expand All @@ -80,7 +80,7 @@ private function extractAnnotation(Scraper $annotation): void
continue;
}

$scraper->$property = $value;
$scraper->{$property} = $value;
}

$this->scraperAnnotation = $scraper;
Expand All @@ -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, '/');
Expand Down
2 changes: 1 addition & 1 deletion src/Api/ApiInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
interface ApiInterface
{
/**
* @return object|array<object>|bool
* @return array<object>|bool|object
*/
public function execute();
}
6 changes: 3 additions & 3 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ public function __construct(HttpClientInterface $httpClient)
}

/**
* @return object|array<object>|bool
* @return array<object>|bool|object
*/
public function send(ScraperRequest $request)
{
$this->request = $request;
$annotation = ExtractAnnotation::extract($this->request);
$this->request = $request;
$annotation = ExtractAnnotation::extract($this->request);

$options = [];

Expand Down
2 changes: 1 addition & 1 deletion src/Request/RequestBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
interface RequestBody
{
/**
* @return array<string, string>|string|resource
* @return array<string, string>|resource|string
*/
public function getBody();
}
3 changes: 3 additions & 0 deletions tests/Annotation/ExtractAnnotationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
use Symfony\Contracts\HttpClient\ResponseInterface;
use Symfony\Contracts\HttpClient\ResponseStreamInterface;

/**
* @internal
*/
final class ClientTest extends TestCase
{
public function testSend(): void
Expand All @@ -32,7 +35,7 @@ public function testSend(): void

$result = $client->send($request);

$this->assertEquals(true, $result);
$this->assertTrue($result);
}

public function testResponseWithException(): void
Expand All @@ -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
Expand Down Expand Up @@ -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);

Expand Down
4 changes: 4 additions & 0 deletions tests/Fixtures/HttpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
use Symfony\Contracts\HttpClient\ResponseInterface;
use Symfony\Contracts\HttpClient\ResponseStreamInterface;

/**
* @internal
* @coversNothing
*/
final class HttpClientTest implements HttpClientInterface
{
private ResponseInterface $response;
Expand Down

0 comments on commit 4a3ae1c

Please sign in to comment.