Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 6 additions & 36 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
parameters:
ignoreErrors:
-
message: '#^Parameter \#3 \$iv of class Patchlevel\\Hydrator\\Extension\\Cryptography\\Cipher\\CipherKey constructor expects non\-empty\-string, string given\.$#'
identifier: argument.type
count: 1
path: src/Extension/Cryptography/BaseCryptographer.php

-
message: '#^Method Patchlevel\\Hydrator\\Extension\\Cryptography\\Cipher\\OpensslCipher\:\:encrypt\(\) should return non\-empty\-string but returns string\.$#'
identifier: return.type
Expand Down Expand Up @@ -90,42 +96,6 @@ parameters:
count: 1
path: src/Normalizer/ObjectNormalizer.php

-
message: '#^Call to method clear\(\) on an unknown class Patchlevel\\Hydrator\\Cryptography\\Store\\InMemoryCipherKeyStore\.$#'
identifier: class.notFound
count: 1
path: tests/Benchmark/HydratorWithCryptographyBench.php

-
message: '#^Call to static method createWithOpenssl\(\) on an unknown class Patchlevel\\Hydrator\\Cryptography\\BaseCryptographer\.$#'
identifier: class.notFound
count: 1
path: tests/Benchmark/HydratorWithCryptographyBench.php

-
message: '#^Instantiated class Patchlevel\\Hydrator\\Cryptography\\CryptographyExtension not found\.$#'
identifier: class.notFound
count: 1
path: tests/Benchmark/HydratorWithCryptographyBench.php

-
message: '#^Instantiated class Patchlevel\\Hydrator\\Cryptography\\Store\\InMemoryCipherKeyStore not found\.$#'
identifier: class.notFound
count: 1
path: tests/Benchmark/HydratorWithCryptographyBench.php

-
message: '#^Parameter \#1 \$extension of method Patchlevel\\Hydrator\\HydratorBuilder\:\:useExtension\(\) expects Patchlevel\\Hydrator\\Extension, Patchlevel\\Hydrator\\Cryptography\\CryptographyExtension given\.$#'
identifier: argument.type
count: 1
path: tests/Benchmark/HydratorWithCryptographyBench.php

-
message: '#^Property Patchlevel\\Hydrator\\Tests\\Benchmark\\HydratorWithCryptographyBench\:\:\$store has unknown class Patchlevel\\Hydrator\\Cryptography\\Store\\InMemoryCipherKeyStore as its type\.$#'
identifier: class.notFound
count: 1
path: tests/Benchmark/HydratorWithCryptographyBench.php

-
message: '#^Property Patchlevel\\Hydrator\\Tests\\Unit\\Extension\\Cryptography\\Fixture\\ChildWithSensitiveDataWithIdentifierDto\:\:\$email is never read, only written\.$#'
identifier: property.onlyWritten
Expand Down
6 changes: 4 additions & 2 deletions src/Extension/Cryptography/BaseCryptographer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
use Patchlevel\Hydrator\Extension\Cryptography\Store\CipherKeyStore;

use function array_key_exists;
use function base64_decode;
use function base64_encode;
use function is_array;

/**
Expand Down Expand Up @@ -52,7 +54,7 @@ public function encrypt(string $subjectId, mixed $value): array
'__enc' => 'v1',
'data' => $this->cipher->encrypt($cipherKey, $value),
'method' => $cipherKey->method,
'iv' => $cipherKey->iv,
'iv' => base64_encode($cipherKey->iv),
];
}

Expand All @@ -70,7 +72,7 @@ public function decrypt(string $subjectId, mixed $encryptedData): mixed
new CipherKey(
$cipherKey->key,
$encryptedData['method'] ?? $cipherKey->method,
$encryptedData['iv'] ?? $cipherKey->iv,
isset($encryptedData['iv']) ? base64_decode($encryptedData['iv']) : $cipherKey->iv,
),
$encryptedData['data'],
);
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Extension/Cryptography/BaseCryptographerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function testEncrypt(): void
'__enc' => 'v1',
'data' => 'encrypted',
'method' => 'methodA',
'iv' => 'random',
'iv' => 'cmFuZG9t',
];

self::assertEquals($expected, $cryptographer->encrypt('foo', 'info@patchlevel.de'));
Expand Down Expand Up @@ -81,7 +81,7 @@ public function testEncryptWithoutKey(): void
'__enc' => 'v1',
'data' => 'encrypted',
'method' => 'methodA',
'iv' => 'random',
'iv' => 'cmFuZG9t',
];

self::assertEquals($expected, $cryptographer->encrypt('foo', 'info@patchlevel.de'));
Expand Down Expand Up @@ -115,7 +115,7 @@ public function testDecrypt(): void
'__enc' => 'v1',
'data' => 'encrypted',
'method' => 'methodA',
'iv' => 'random',
'iv' => 'cmFuZG9t',
],
),
);
Expand Down
Loading