Skip to content

Commit

Permalink
deps: Upgrade to PHPStan 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tienvx committed Dec 13, 2024
1 parent 03504fb commit 64bfb3f
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@
"roave/security-advisories": "dev-latest",
"friendsofphp/php-cs-fixer": "^3.0",
"php-amqplib/php-amqplib": "^3.0",
"phpstan/phpstan": "^1.9",
"phpstan/phpstan": "^2.0",
"phpunit/phpunit": "^10.1.0|^11.0",
"guzzlehttp/guzzle": "^7.8",
"behat/behat": "^3.13",
"galbar/jsonpath": "^3.0",
"ramsey/uuid": "^4.7",
"pact-foundation/example-protobuf-sync-message-provider": "@dev",
"webonyx/graphql-php": "^15.14",
"rector/rector": "^1.2",
"rector/rector": "^2.0",
"clue/framework-x": "^0.16.0"
},
"autoload": {
Expand Down
7 changes: 4 additions & 3 deletions src/PhpPact/FFI/Model/ArrayData.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function getSize(): int
}

/**
* @param array<int, string> $values
* @param string[] $values
*/
public static function createFrom(array $values): ?self
{
Expand All @@ -38,15 +38,16 @@ public static function createFrom(array $values): ?self
if ($items === null) {
throw new CDataNotCreatedException();
}
foreach ($values as $index => $value) {
$index = 0;
foreach ($values as $value) {
$length = \strlen($value);
$itemSize = $length + 1;
$item = FFI::new("char[{$itemSize}]", false);
if ($item === null) {
throw new CDataNotCreatedException();
}
FFI::memcpy($item, $value, $length);
$items[$index] = $item; // @phpstan-ignore-line
$items[$index++] = $item; // @phpstan-ignore-line
}

return new self($items, $size);
Expand Down
1 change: 1 addition & 0 deletions src/PhpPact/Standalone/MockService/MockServerEnvConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function __construct()

$version = $this->parseEnv('PACT_SPECIFICATION_VERSION');
if (!$version) {
/** @var string */
$version = static::DEFAULT_SPECIFICATION_VERSION;
}

Expand Down
4 changes: 1 addition & 3 deletions src/PhpPact/Standalone/StubService/StubServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ private function getArguments(): array
$results[] = "--loglevel={$this->config->getLogLevel()}";
}

if ($this->config->getPort() !== null) {
$results[] = "--port={$this->config->getPort()}";
}
$results[] = "--port={$this->config->getPort()}";

if ($this->config->getProviderState() !== null) {
$results[] = "--provider-state={$this->config->getProviderState()}";
Expand Down
8 changes: 4 additions & 4 deletions tests/PhpPact/FFI/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,19 @@ public function testAddTextComment(): void
public function testNewInteraction(): void
{
$result = $this->client->newInteraction(1, 'test');
$this->assertIsInt($result);
$this->assertNotEmpty($result);
}

public function testNewMessageInteraction(): void
{
$result = $this->client->newMessageInteraction(1, 'test');
$this->assertIsInt($result);
$this->assertNotEmpty($result);
}

public function testNewSyncMessageInteraction(): void
{
$result = $this->client->newSyncMessageInteraction(1, 'test');
$this->assertIsInt($result);
$this->assertNotEmpty($result);
}

public function testGiven(): void
Expand Down Expand Up @@ -130,7 +130,7 @@ public function testFreePactHandle(): void
public function testNewPact(): void
{
$result = $this->client->newPact('consumer', 'provider');
$this->assertIsInt($result);
$this->assertNotEmpty($result);
$this->client->freePactHandle($result);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/PhpPact/FFI/Model/ArrayDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function testCreateFromArray(): void
$this->assertInstanceOf(ArrayData::class, $arrayData);
$this->assertSame(count($branches), $arrayData->getSize());
foreach ($branches as $index => $branch) {
// @phpstan-ignore offsetAccess.nonOffsetAccessible
// @phpstan-ignore offsetAccess.nonOffsetAccessible,argument.type
$this->assertSame($branch, FFI::string($arrayData->getItems()[$index]));
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/PhpPact/Log/LoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public function testClone(): void
{
$this->expectException(Error::class);
$this->expectExceptionMessage('Call to protected PhpPact\Log\Logger::__clone()');
// @phpstan-ignore expr.resultUnused
clone $this->logger;
}

Expand Down

0 comments on commit 64bfb3f

Please sign in to comment.