diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 9c1c04b..c12ff17 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -19,7 +19,7 @@ EOF; $config = new PhpCsFixer\Config(); return $config->setRules([ - '@PHP80Migration' => true, + '@PHP80Migration:risky' => true, '@PSR12' => true, 'header_comment' => [ 'comment_type' => 'PHPDoc', diff --git a/composer.json b/composer.json index ddb662f..ab767ec 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ "scripts": { "test": "./vendor/bin/phpunit --no-coverage", "check-style": "./vendor/bin/php-cs-fixer fix --verbose --dry-run", - "fix-style": "./vendor/bin/php-cs-fixer fix --verbose", + "fix-style": "./vendor/bin/php-cs-fixer fix --verbose --allow-risky=yes", "check-code": "./vendor/bin/phpstan analyse -c phpstan.neon --no-progress --ansi" } } diff --git a/src/Entities/Account.php b/src/Entities/Account.php index 1c81e6e..57f142b 100644 --- a/src/Entities/Account.php +++ b/src/Entities/Account.php @@ -13,6 +13,8 @@ * @link https://www.oxidmodule.com */ +declare(strict_types=1); + namespace D3\KlicktippPhpClient\Entities; use D3\KlicktippPhpClient\Exceptions\BaseException; diff --git a/src/Entities/Field.php b/src/Entities/Field.php index 199c84f..a28999c 100644 --- a/src/Entities/Field.php +++ b/src/Entities/Field.php @@ -13,6 +13,8 @@ * @link https://www.oxidmodule.com */ +declare(strict_types=1); + namespace D3\KlicktippPhpClient\Entities; use D3\KlicktippPhpClient\Exceptions\BaseException; diff --git a/src/Entities/FieldList.php b/src/Entities/FieldList.php index 8b98bea..dbe9d3e 100644 --- a/src/Entities/FieldList.php +++ b/src/Entities/FieldList.php @@ -13,6 +13,8 @@ * @link https://www.oxidmodule.com */ +declare(strict_types=1); + namespace D3\KlicktippPhpClient\Entities; use Doctrine\Common\Collections\ArrayCollection; diff --git a/src/Entities/Subscriber.php b/src/Entities/Subscriber.php index 787eee4..8cc322d 100644 --- a/src/Entities/Subscriber.php +++ b/src/Entities/Subscriber.php @@ -13,6 +13,8 @@ * @link https://www.oxidmodule.com */ +declare(strict_types=1); + namespace D3\KlicktippPhpClient\Entities; use D3\KlicktippPhpClient\Exceptions\BaseException; @@ -158,9 +160,7 @@ class Subscriber extends ArrayCollection public function getFields(): ArrayCollection { return $this->filter( - function ($value, $key) { - return str_starts_with($key, 'field'); - } + fn ($value, $key) => str_starts_with($key, 'field') ); } diff --git a/src/Entities/SubscriberList.php b/src/Entities/SubscriberList.php index bbc48a5..16ce28e 100644 --- a/src/Entities/SubscriberList.php +++ b/src/Entities/SubscriberList.php @@ -13,6 +13,8 @@ * @link https://www.oxidmodule.com */ +declare(strict_types=1); + namespace D3\KlicktippPhpClient\Entities; use Doctrine\Common\Collections\ArrayCollection; diff --git a/src/Entities/Subscription.php b/src/Entities/Subscription.php index 7c75649..41d242c 100644 --- a/src/Entities/Subscription.php +++ b/src/Entities/Subscription.php @@ -13,6 +13,8 @@ * @link https://www.oxidmodule.com */ +declare(strict_types=1); + namespace D3\KlicktippPhpClient\Entities; use D3\KlicktippPhpClient\Exceptions\BaseException; diff --git a/src/Entities/SubscriptionList.php b/src/Entities/SubscriptionList.php index 87bffe0..466e188 100644 --- a/src/Entities/SubscriptionList.php +++ b/src/Entities/SubscriptionList.php @@ -13,6 +13,8 @@ * @link https://www.oxidmodule.com */ +declare(strict_types=1); + namespace D3\KlicktippPhpClient\Entities; use Doctrine\Common\Collections\ArrayCollection; diff --git a/src/Entities/Tag.php b/src/Entities/Tag.php index 7b2c651..85716fe 100644 --- a/src/Entities/Tag.php +++ b/src/Entities/Tag.php @@ -13,6 +13,8 @@ * @link https://www.oxidmodule.com */ +declare(strict_types=1); + namespace D3\KlicktippPhpClient\Entities; use D3\KlicktippPhpClient\Exceptions\BaseException; diff --git a/src/Entities/TagList.php b/src/Entities/TagList.php index cd76038..e98069b 100644 --- a/src/Entities/TagList.php +++ b/src/Entities/TagList.php @@ -13,6 +13,8 @@ * @link https://www.oxidmodule.com */ +declare(strict_types=1); + namespace D3\KlicktippPhpClient\Entities; use Doctrine\Common\Collections\ArrayCollection; diff --git a/src/Exceptions/BaseException.php b/src/Exceptions/BaseException.php index 94a3578..5af096d 100644 --- a/src/Exceptions/BaseException.php +++ b/src/Exceptions/BaseException.php @@ -13,6 +13,8 @@ * @link https://www.oxidmodule.com */ +declare(strict_types=1); + namespace D3\KlicktippPhpClient\Exceptions; use Exception; diff --git a/src/Exceptions/NoCredentialsException.php b/src/Exceptions/NoCredentialsException.php index 2964ce4..59c5a09 100644 --- a/src/Exceptions/NoCredentialsException.php +++ b/src/Exceptions/NoCredentialsException.php @@ -13,6 +13,8 @@ * @link https://www.oxidmodule.com */ +declare(strict_types=1); + namespace D3\KlicktippPhpClient\Exceptions; class NoCredentialsException extends BaseException diff --git a/src/Resources/Account.php b/src/Resources/Account.php index 0e48d6c..fa3524e 100644 --- a/src/Resources/Account.php +++ b/src/Resources/Account.php @@ -13,6 +13,8 @@ * @link https://www.oxidmodule.com */ +declare(strict_types=1); + namespace D3\KlicktippPhpClient\Resources; use D3\KlicktippPhpClient\Entities\Account as AccountEntity; diff --git a/src/Resources/Field.php b/src/Resources/Field.php index 5e3ee81..86a4dfa 100644 --- a/src/Resources/Field.php +++ b/src/Resources/Field.php @@ -13,6 +13,8 @@ * @link https://www.oxidmodule.com */ +declare(strict_types=1); + namespace D3\KlicktippPhpClient\Resources; use D3\KlicktippPhpClient\Entities\Field as FieldEntity; @@ -63,7 +65,7 @@ class Field extends Model */ public function create(string $name): string { - return current( + return (string) current( $this->connection->requestAndParse( 'POST', 'field.json', diff --git a/src/Resources/Model.php b/src/Resources/Model.php index d8e3e29..3c354a1 100644 --- a/src/Resources/Model.php +++ b/src/Resources/Model.php @@ -13,6 +13,8 @@ * @link https://www.oxidmodule.com */ +declare(strict_types=1); + namespace D3\KlicktippPhpClient\Resources; use D3\KlicktippPhpClient\Connection; diff --git a/src/Resources/Subscriber.php b/src/Resources/Subscriber.php index db8046d..41237f4 100644 --- a/src/Resources/Subscriber.php +++ b/src/Resources/Subscriber.php @@ -13,6 +13,8 @@ * @link https://www.oxidmodule.com */ +declare(strict_types=1); + namespace D3\KlicktippPhpClient\Resources; use D3\KlicktippPhpClient\Entities\Subscriber as SubscriberEntity; @@ -111,7 +113,7 @@ class Subscriber extends Model */ public function search(string $mailAddress): string { - return current( + return (string) current( $this->connection->requestAndParse( 'POST', 'subscriber/search.json', @@ -328,9 +330,9 @@ class Subscriber extends Model /** * @throws BaseException */ - public function signoff(string $apikey, string $emailAddress): string + public function signoff(string $apikey, string $emailAddress): bool { - return current( + return (bool) current( $this->connection->requestAndParse( 'POST', 'subscriber/signoff.json', diff --git a/src/Resources/SubscriptionProcess.php b/src/Resources/SubscriptionProcess.php index 2baa5dc..d31e223 100644 --- a/src/Resources/SubscriptionProcess.php +++ b/src/Resources/SubscriptionProcess.php @@ -13,6 +13,8 @@ * @link https://www.oxidmodule.com */ +declare(strict_types=1); + namespace D3\KlicktippPhpClient\Resources; use D3\KlicktippPhpClient\Entities\Subscription as SubscriptionEntity; diff --git a/src/Resources/Tag.php b/src/Resources/Tag.php index fcae57c..7ae2c89 100644 --- a/src/Resources/Tag.php +++ b/src/Resources/Tag.php @@ -13,6 +13,8 @@ * @link https://www.oxidmodule.com */ +declare(strict_types=1); + namespace D3\KlicktippPhpClient\Resources; use D3\KlicktippPhpClient\Entities\Tag as TagEntity; @@ -64,7 +66,7 @@ class Tag extends Model */ public function create(string $name): string { - return current( + return (string) current( $this->connection->requestAndParse( 'POST', 'tag.json', diff --git a/tests/integration/IntegrationTestCase.php b/tests/integration/IntegrationTestCase.php index 2f76040..250abfe 100644 --- a/tests/integration/IntegrationTestCase.php +++ b/tests/integration/IntegrationTestCase.php @@ -13,6 +13,8 @@ * @link https://www.oxidmodule.com */ +declare(strict_types=1); + namespace D3\KlicktippPhpClient\tests\integration; use D3\KlicktippPhpClient\Connection; diff --git a/tests/integration/Resources/AccountTest.php b/tests/integration/Resources/AccountTest.php index 582b139..15f91e9 100644 --- a/tests/integration/Resources/AccountTest.php +++ b/tests/integration/Resources/AccountTest.php @@ -13,6 +13,8 @@ * @link https://www.oxidmodule.com */ +declare(strict_types=1); + namespace D3\KlicktippPhpClient\tests\integration\Resources; use D3\KlicktippPhpClient\Entities\Account as AccountEntity; @@ -139,7 +141,7 @@ class AccountTest extends IntegrationTestCase * @covers \D3\KlicktippPhpClient\Resources\Account::getEntity * @dataProvider getDataProvider */ - public function testGet(ResponseInterface $response, ?array $expected, bool $expectException = false) + public function testGet(ResponseInterface $response, ?array $expected, bool $expectException = false): void { $sut = new Account($this->getConnectionMock($response)); @@ -180,7 +182,7 @@ class AccountTest extends IntegrationTestCase * @covers \D3\KlicktippPhpClient\Resources\Account::update * @dataProvider updateDataProvider */ - public function testUpdate(ResponseInterface $response, ?bool $expected, bool $expectException = false) + public function testUpdate(ResponseInterface $response, ?bool $expected, bool $expectException = false): void { $sut = new Account($this->getConnectionMock($response)); diff --git a/tests/integration/Resources/FieldTest.php b/tests/integration/Resources/FieldTest.php index 12bee6d..dd8d7f2 100644 --- a/tests/integration/Resources/FieldTest.php +++ b/tests/integration/Resources/FieldTest.php @@ -13,6 +13,8 @@ * @link https://www.oxidmodule.com */ +declare(strict_types=1); + namespace D3\KlicktippPhpClient\tests\integration\Resources; use D3\KlicktippPhpClient\Entities\Field as FieldEntity; @@ -37,7 +39,7 @@ class FieldTest extends IntegrationTestCase * @covers \D3\KlicktippPhpClient\Resources\Field::index * @dataProvider indexDataProvider */ - public function testIndex(ResponseInterface $response, ?FieldList $expected, bool $expectException = false) + public function testIndex(ResponseInterface $response, ?FieldList $expected, bool $expectException = false): void { $sut = new Field($this->getConnectionMock($response)); @@ -102,7 +104,7 @@ class FieldTest extends IntegrationTestCase * @covers \D3\KlicktippPhpClient\Resources\Field::getEntity * @dataProvider getDataProvider */ - public function testGet(ResponseInterface $response, ?array $expected, bool $expectException = false) + public function testGet(ResponseInterface $response, ?array $expected, bool $expectException = false): void { $sut = new Field($this->getConnectionMock($response)); @@ -139,7 +141,7 @@ class FieldTest extends IntegrationTestCase * @covers \D3\KlicktippPhpClient\Resources\Field::create * @dataProvider createDataProvider */ - public function testCreate(ResponseInterface $response, ?string $expected, bool $expectException = false) + public function testCreate(ResponseInterface $response, ?string $expected, bool $expectException = false): void { $sut = new Field($this->getConnectionMock($response)); @@ -170,7 +172,7 @@ class FieldTest extends IntegrationTestCase * @covers \D3\KlicktippPhpClient\Resources\Field::update * @dataProvider updateDataProvider */ - public function testUpdate(ResponseInterface $response, ?bool $expected, bool $expectException = false) + public function testUpdate(ResponseInterface $response, ?bool $expected, bool $expectException = false): void { $sut = new Field($this->getConnectionMock($response)); @@ -201,7 +203,7 @@ class FieldTest extends IntegrationTestCase * @covers \D3\KlicktippPhpClient\Resources\Field::delete * @dataProvider deleteDataProvider */ - public function testDelete(ResponseInterface $response, ?bool $expected, bool $expectException = false) + public function testDelete(ResponseInterface $response, ?bool $expected, bool $expectException = false): void { $sut = new Field($this->getConnectionMock($response)); diff --git a/tests/integration/Resources/SubscriberTest.php b/tests/integration/Resources/SubscriberTest.php index 80d42e8..4a80e27 100644 --- a/tests/integration/Resources/SubscriberTest.php +++ b/tests/integration/Resources/SubscriberTest.php @@ -13,6 +13,8 @@ * @link https://www.oxidmodule.com */ +declare(strict_types=1); + namespace D3\KlicktippPhpClient\tests\integration\Resources; use D3\KlicktippPhpClient\Entities\Subscriber as SubscriberEntity; @@ -54,7 +56,7 @@ class SubscriberTest extends IntegrationTestCase * @covers \D3\KlicktippPhpClient\Resources\Subscriber::index * @dataProvider indexDataProvider */ - public function testIndex(ResponseInterface $response, ?SubscriberList $expected, bool $expectException = false) + public function testIndex(ResponseInterface $response, ?SubscriberList $expected, bool $expectException = false): void { $sut = new Subscriber($this->getConnectionMock($response)); @@ -96,7 +98,7 @@ class SubscriberTest extends IntegrationTestCase * @covers \D3\KlicktippPhpClient\Resources\Subscriber::getEntity * @dataProvider getDataProvider */ - public function testGet(ResponseInterface $response, ?array $expected, bool $expectException = false) + public function testGet(ResponseInterface $response, ?array $expected, bool $expectException = false): void { $sut = new Subscriber($this->getConnectionMock($response)); diff --git a/tests/integration/Resources/SubscriptionProcessTest.php b/tests/integration/Resources/SubscriptionProcessTest.php index 3eb56da..003a98e 100644 --- a/tests/integration/Resources/SubscriptionProcessTest.php +++ b/tests/integration/Resources/SubscriptionProcessTest.php @@ -13,6 +13,8 @@ * @link https://www.oxidmodule.com */ +declare(strict_types=1); + namespace D3\KlicktippPhpClient\tests\integration\Resources; use D3\KlicktippPhpClient\Entities\Subscription; @@ -36,7 +38,7 @@ class SubscriptionProcessTest extends IntegrationTestCase * @covers \D3\KlicktippPhpClient\Resources\SubscriptionProcess::index * @dataProvider indexDataProvider */ - public function testIndex(ResponseInterface $response, ?SubscriptionList $expected, bool $expectException = false) + public function testIndex(ResponseInterface $response, ?SubscriptionList $expected, bool $expectException = false): void { $sut = new SubscriptionProcess($this->getConnectionMock($response)); @@ -73,7 +75,7 @@ class SubscriptionProcessTest extends IntegrationTestCase * @covers \D3\KlicktippPhpClient\Resources\SubscriptionProcess::getEntity * @dataProvider getDataProvider */ - public function testGet(ResponseInterface $response, ?array $expected, bool $expectException = false) + public function testGet(ResponseInterface $response, ?array $expected, bool $expectException = false): void { $sut = new SubscriptionProcess($this->getConnectionMock($response)); @@ -121,7 +123,7 @@ class SubscriptionProcessTest extends IntegrationTestCase * @covers \D3\KlicktippPhpClient\Resources\SubscriptionProcess::create * @dataProvider getDataProvider */ - public function testCreate(ResponseInterface $response, ?array $expected, bool $expectException = false) + public function testCreate(ResponseInterface $response, ?array $expected, bool $expectException = false): void { $sut = new SubscriptionProcess($this->getConnectionMock($response)); @@ -145,7 +147,7 @@ class SubscriptionProcessTest extends IntegrationTestCase * @covers \D3\KlicktippPhpClient\Resources\SubscriptionProcess::update * @dataProvider updateDataProvider */ - public function testUpdate(ResponseInterface $response, ?bool $expected, bool $expectException = false) + public function testUpdate(ResponseInterface $response, ?bool $expected, bool $expectException = false): void { $sut = new SubscriptionProcess($this->getConnectionMock($response)); @@ -176,7 +178,7 @@ class SubscriptionProcessTest extends IntegrationTestCase * @covers \D3\KlicktippPhpClient\Resources\SubscriptionProcess::redirect * @dataProvider redirectDataProvider */ - public function testRedirect(ResponseInterface $response, ?string $expected, bool $expectException = false) + public function testRedirect(ResponseInterface $response, ?string $expected, bool $expectException = false): void { $sut = new SubscriptionProcess($this->getConnectionMock($response)); diff --git a/tests/integration/Resources/TagTest.php b/tests/integration/Resources/TagTest.php index 505e1e9..7c6d82a 100644 --- a/tests/integration/Resources/TagTest.php +++ b/tests/integration/Resources/TagTest.php @@ -13,6 +13,8 @@ * @link https://www.oxidmodule.com */ +declare(strict_types=1); + namespace D3\KlicktippPhpClient\tests\integration\Resources; use D3\KlicktippPhpClient\Entities\Tag as TagEntity; @@ -36,7 +38,7 @@ class TagTest extends IntegrationTestCase * @covers \D3\KlicktippPhpClient\Resources\Tag::index * @dataProvider indexDataProvider */ - public function testIndex(ResponseInterface $response, ?TagList $expected, bool $expectException = false) + public function testIndex(ResponseInterface $response, ?TagList $expected, bool $expectException = false): void { $sut = new Tag($this->getConnectionMock($response)); @@ -73,7 +75,7 @@ class TagTest extends IntegrationTestCase * @covers \D3\KlicktippPhpClient\Resources\Tag::getEntity * @dataProvider getDataProvider */ - public function testGet(ResponseInterface $response, ?array $expected, bool $expectException = false) + public function testGet(ResponseInterface $response, ?array $expected, bool $expectException = false): void { $sut = new Tag($this->getConnectionMock($response)); @@ -112,7 +114,7 @@ class TagTest extends IntegrationTestCase * @covers \D3\KlicktippPhpClient\Resources\Tag::create * @dataProvider createDataProvider */ - public function testCreate(ResponseInterface $response, ?string $expected, bool $expectException = false) + public function testCreate(ResponseInterface $response, ?string $expected, bool $expectException = false): void { $sut = new Tag($this->getConnectionMock($response)); @@ -143,7 +145,7 @@ class TagTest extends IntegrationTestCase * @covers \D3\KlicktippPhpClient\Resources\Tag::update * @dataProvider updateDataProvider */ - public function testUpdate(ResponseInterface $response, ?bool $expected, bool $expectException = false) + public function testUpdate(ResponseInterface $response, ?bool $expected, bool $expectException = false): void { $sut = new Tag($this->getConnectionMock($response)); @@ -174,7 +176,7 @@ class TagTest extends IntegrationTestCase * @covers \D3\KlicktippPhpClient\Resources\Tag::delete * @dataProvider deleteDataProvider */ - public function testDelete(ResponseInterface $response, ?bool $expected, bool $expectException = false) + public function testDelete(ResponseInterface $response, ?bool $expected, bool $expectException = false): void { $sut = new Tag($this->getConnectionMock($response)); diff --git a/tests/unit/Entities/AccountTest.php b/tests/unit/Entities/AccountTest.php index 9321e7a..f6f5d8f 100644 --- a/tests/unit/Entities/AccountTest.php +++ b/tests/unit/Entities/AccountTest.php @@ -13,6 +13,8 @@ * @link https://www.oxidmodule.com */ +declare(strict_types=1); + namespace D3\KlicktippPhpClient\tests\unit\Entities; use D3\KlicktippPhpClient\Entities\Account; diff --git a/tests/unit/Entities/FieldTest.php b/tests/unit/Entities/FieldTest.php index f79bb3a..d74aec0 100644 --- a/tests/unit/Entities/FieldTest.php +++ b/tests/unit/Entities/FieldTest.php @@ -13,6 +13,8 @@ * @link https://www.oxidmodule.com */ +declare(strict_types=1); + namespace D3\KlicktippPhpClient\tests\unit\Entities; use D3\KlicktippPhpClient\Entities\Field; @@ -73,7 +75,7 @@ class FieldTest extends TestCase * @covers \D3\KlicktippPhpClient\Entities\Field::getName * @dataProvider getSomethingDataProvider */ - public function testGetSomething(string $methodName, string $expectedValue) + public function testGetSomething(string $methodName, string $expectedValue): void { $this->assertSame( $expectedValue, diff --git a/tests/unit/Entities/SubscriberTest.php b/tests/unit/Entities/SubscriberTest.php index 93bce20..d719d7a 100644 --- a/tests/unit/Entities/SubscriberTest.php +++ b/tests/unit/Entities/SubscriberTest.php @@ -13,6 +13,8 @@ * @link https://www.oxidmodule.com */ +declare(strict_types=1); + namespace D3\KlicktippPhpClient\tests\unit\Entities; use D3\KlicktippPhpClient\Entities\Subscriber; @@ -169,7 +171,7 @@ class SubscriberTest extends TestCase * @covers \D3\KlicktippPhpClient\Entities\Subscriber::getSmsReferrer * @dataProvider getSomethingDataProvider */ - public function testGetSomething(string $methodName, string $expectedValue) + public function testGetSomething(string $methodName, string $expectedValue): void { $this->assertSame( $expectedValue, @@ -371,7 +373,7 @@ class SubscriberTest extends TestCase * @throws ReflectionException * @covers \D3\KlicktippPhpClient\Entities\Subscriber::getFields */ - public function testGetFields() + public function testGetFields(): void { $fields = $this->callMethod( $this->entity, @@ -466,7 +468,7 @@ class SubscriberTest extends TestCase * @covers \D3\KlicktippPhpClient\Entities\Subscriber::getOutbounds * @dataProvider getTagsDataProvider */ - public function testGetTags(string $methodName, int $expectedCount) + public function testGetTags(string $methodName, int $expectedCount): void { $tags = $this->callMethod( $this->entity, @@ -497,7 +499,7 @@ class SubscriberTest extends TestCase * @covers \D3\KlicktippPhpClient\Entities\Subscriber::isTagSet * @dataProvider isTagSetDataProvider */ - public function testIsTagSet(string $searchTagId, bool $expected) + public function testIsTagSet(string $searchTagId, bool $expected): void { $tagList = new ArrayCollection([ "12494453", @@ -628,7 +630,7 @@ class SubscriberTest extends TestCase ?array $newTagList, InvokedCount $removeTagInvocation, InvokedCount $setTagInvocation - ) { + ): void { $entityMock = $this->getMockBuilder(Subscriber::class) ->disableOriginalConstructor() ->onlyMethods(['getTags']) @@ -671,7 +673,7 @@ class SubscriberTest extends TestCase * @covers \D3\KlicktippPhpClient\Entities\Subscriber::isManualTagSet * @dataProvider isManualTagSetDataProvider */ - public function testIsManualTagSet(string $searchTagId, bool $expected) + public function testIsManualTagSet(string $searchTagId, bool $expected): void { $this->assertSame( $expected, @@ -698,7 +700,7 @@ class SubscriberTest extends TestCase * @covers \D3\KlicktippPhpClient\Entities\Subscriber::getFinishedCampaignTime * @dataProvider getTagDataProvider */ - public function testGetTag(string $testMethodName, string $invokedMethodName) + public function testGetTag(string $testMethodName, string $invokedMethodName): void { $fixtureDate = '2024-12-24 18:00:00'; $fixture = new DateTime($fixtureDate);