Skip to content

Commit 4bdbdee

Browse files
committed
ignore Safe\unserialize - only in newer safe-php, breaking change to use it now
1 parent 4df3d5a commit 4bdbdee

File tree

7 files changed

+10
-14
lines changed

7 files changed

+10
-14
lines changed

benchmarks/ASTUnserializationBench.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
use GraphQL\Language\Parser;
66
use Nuwave\Lighthouse\Schema\AST\DocumentAST;
77

8-
use function Safe\unserialize;
9-
108
/**
119
* @BeforeMethods({"prepareSchema"})
1210
*/
@@ -54,6 +52,7 @@ public function prepareSchema(): void
5452
*/
5553
public function benchUnserializeDocumentNode(): void
5654
{
55+
// @phpstan-ignore theCodingMachineSafe.function (Safe\unserialize is not available in thecodingmachine/safe ^1 and ^2)
5756
unserialize($this->documentNode);
5857
}
5958

@@ -64,6 +63,7 @@ public function benchUnserializeDocumentNode(): void
6463
*/
6564
public function benchUnserializeDocumentAST(): void
6665
{
66+
// @phpstan-ignore theCodingMachineSafe.function (Safe\unserialize is not available in thecodingmachine/safe ^1 and ^2)
6767
unserialize($this->documentAST);
6868
}
6969
}

src/Execution/ContextSerializer.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
use Nuwave\Lighthouse\Support\Contracts\GraphQLContext;
1010
use Nuwave\Lighthouse\Support\Contracts\SerializesContext;
1111

12-
use function Safe\unserialize;
13-
1412
class ContextSerializer implements SerializesContext
1513
{
1614
use SerializesAndRestoresModelIdentifiers;
@@ -44,6 +42,7 @@ public function unserialize(string $context): GraphQLContext
4442
[
4543
'request' => $rawRequest,
4644
'user' => $rawUser
45+
// @phpstan-ignore theCodingMachineSafe.function (Safe\unserialize is not available in thecodingmachine/safe ^1 and ^2)
4746
] = unserialize($context);
4847

4948
if ($rawRequest) {

src/Subscriptions/Storage/RedisStorageManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
use Nuwave\Lighthouse\Subscriptions\Contracts\StoresSubscriptions;
1111
use Nuwave\Lighthouse\Subscriptions\Subscriber;
1212

13-
use function Safe\unserialize;
14-
1513
/**
1614
* Stores subscribers and topics in redis.
1715
*
@@ -89,6 +87,7 @@ public function subscribersByTopic(string $topic): Collection
8987

9088
// Other entries may contain invalid values.
9189
try {
90+
// @phpstan-ignore theCodingMachineSafe.function (Safe\unserialize is not available in thecodingmachine/safe ^1 and ^2)
9291
$subscriber = unserialize($subscriber);
9392

9493
// This key exists so remove it from the list of missing keys.
@@ -166,6 +165,7 @@ protected function getSubscriber(string $channelKey): ?Subscriber
166165
$subscriber = $this->connection->command('get', [$channelKey]);
167166

168167
return is_string($subscriber)
168+
// @phpstan-ignore theCodingMachineSafe.function (Safe\unserialize is not available in thecodingmachine/safe ^1 and ^2)
169169
? unserialize($subscriber)
170170
: null;
171171
}

src/Subscriptions/Subscriber.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
use Nuwave\Lighthouse\Support\Contracts\GraphQLContext;
1212
use Nuwave\Lighthouse\Support\Contracts\SerializesContext;
1313

14-
use function Safe\unserialize;
15-
1614
class Subscriber
1715
{
1816
/**
@@ -105,6 +103,7 @@ public function __unserialize(array $data): void
105103
$this->topic = $data['topic'];
106104

107105
$documentNode = AST::fromArray(
106+
// @phpstan-ignore theCodingMachineSafe.function (Safe\unserialize is not available in thecodingmachine/safe ^1 and ^2)
108107
unserialize($data['query']),
109108
);
110109
assert($documentNode instanceof DocumentNode, 'We know the type since it is set during construction and serialized.');

tests/Integration/Async/AsyncDirectiveTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
use Nuwave\Lighthouse\Support\Contracts\GraphQLContext;
1111
use Tests\DBTestCase;
1212

13-
use function Safe\unserialize;
14-
1513
final class AsyncDirectiveTest extends DBTestCase
1614
{
1715
public function testDispatchesMutation(): void
@@ -40,6 +38,7 @@ public function testDispatchesMutation(): void
4038
foreach ($jobs as $job) {
4139
$this->assertInstanceOf(AsyncMutation::class, $job);
4240

41+
// @phpstan-ignore theCodingMachineSafe.function (Safe\unserialize is not available in thecodingmachine/safe ^1 and ^2)
4342
$jobCycledThroughSerialization = unserialize(serialize($job));
4443
$this->assertInstanceOf(AsyncMutation::class, $jobCycledThroughSerialization);
4544
Container::getInstance()->call([$jobCycledThroughSerialization, 'handle']);
@@ -73,6 +72,7 @@ public function testDispatchesMutationOnCustomQueue(): void
7372
$this->assertInstanceOf(AsyncMutation::class, $job);
7473
$this->assertSame('custom', $job->queue);
7574

75+
// @phpstan-ignore theCodingMachineSafe.function (Safe\unserialize is not available in thecodingmachine/safe ^1 and ^2)
7676
$jobCycledThroughSerialization = unserialize(serialize($job));
7777
$this->assertInstanceOf(AsyncMutation::class, $jobCycledThroughSerialization);
7878
Container::getInstance()->call([$jobCycledThroughSerialization, 'handle']);

tests/Unit/Schema/AST/DocumentASTTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
use Tests\TestCase;
1212
use Tests\Utils\Models\User;
1313

14-
use function Safe\unserialize;
15-
1614
final class DocumentASTTest extends TestCase
1715
{
1816
public function testParsesSimpleSchema(): void
@@ -100,6 +98,7 @@ public function testBeSerialized(): void
10098
directive @foo on FIELD
10199
GRAPHQL);
102100

101+
// @phpstan-ignore theCodingMachineSafe.function (Safe\unserialize is not available in thecodingmachine/safe ^1 and ^2)
103102
$reserialized = unserialize(
104103
serialize($documentAST),
105104
);

tests/Unit/Subscriptions/SubscriberTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
use Tests\TestCase;
1313
use Tests\TestsSerialization;
1414

15-
use function Safe\unserialize;
16-
1715
final class SubscriberTest extends TestCase
1816
{
1917
use TestsSerialization;
@@ -47,6 +45,7 @@ public function testSerializable(): void
4745

4846
$channel = $subscriber->channel;
4947

48+
// @phpstan-ignore theCodingMachineSafe.function (Safe\unserialize is not available in thecodingmachine/safe ^1 and ^2)
5049
$serialized = unserialize(serialize($subscriber));
5150

5251
$this->assertInstanceOf(Subscriber::class, $serialized);

0 commit comments

Comments
 (0)