Conversation
🎉 Snyk checks have passed. No issues have been found so far.✅ security/snyk check is complete. No issues have been found. (View Details) ✅ license/snyk check is complete. No issues have been found. (View Details) |
|
|
||
| // snippet.uuid_metadata_operations | ||
| try { | ||
| $result = $user->setUUIDMetadata() |
There was a problem hiding this comment.
I other place you used:
$admin->setUuidMetadata()
Is this desired ?
There was a problem hiding this comment.
PHP's function names are case insensitive. this though should be written with uppercase uuid
examples/AccessManager.php
Outdated
| } | ||
|
|
||
| // Helper function to safely execute operations (deprecated - using direct try/catch now) | ||
| function safeTest($callable, $description) |
There was a problem hiding this comment.
Is this method needed? Where it is used?
There was a problem hiding this comment.
nope. probably leftover from copypaste
|
|
||
| class AppContextTest extends TestCase | ||
| { | ||
| public function testExamples(): void |
There was a problem hiding this comment.
Could this name be more descriptive?
There was a problem hiding this comment.
It's a test for examples. how much descriptive a single method name in pretty much self explanatory class should be?
There was a problem hiding this comment.
Maybe testAppContextCodeSnippets ?
examples/AppContext.php
Outdated
| $subscribeKey = getenv('SUBSCRIBE_KEY') ?: 'demo'; | ||
|
|
||
| $config = new PNConfiguration(); | ||
| $config->setSubscribeKey(getenv('SUBSCRIBE_KEY', 'demo')); |
There was a problem hiding this comment.
Why not to pass $publishKey variable here?
| ->profileUrl($user['profileUrl']) | ||
| ->custom($user['custom']) | ||
| ->sync(); | ||
| assert($setUserMetadataResult->getId()); |
There was a problem hiding this comment.
What do you think about: "By default, PHP compiles out assert() calls unless you enable zend.assertions=1 and assert.exception=1. In a typical CLI script they won’t even run, so you’ll never know if one failed."
?
There was a problem hiding this comment.
From what I've found in docs and on php.watch symbols history the default for zend.assertions is 1 so they are by default enabled.
| return random_bytes(static::IV_LENGTH); | ||
| } | ||
|
|
||
| public function getCipherKey($cipherKey = null): string |
There was a problem hiding this comment.
Shouldn't be type-hinted?
| @@ -41,17 +41,17 @@ public function encrypt(string $text, ?string $cipherKey = null): CryptoPayload | |||
| { | |||
There was a problem hiding this comment.
In getSecret method is this required to check:
!is_null($cipherKey)
if method signature enforce cipherKey being not null?
There was a problem hiding this comment.
Probably redundant, but not the scope of this task.
| return new static( | ||
| [ | ||
| LegacyCryptor::CRYPTOR_ID => new LegacyCryptor($cipherKey, $useRandomIV), | ||
| AesCbcCryptor::CRYPTOR_ID => new AesCbcCryptor($cipherKey), |
There was a problem hiding this comment.
Instead of:
aesCbcCryptor::CRYPTOR_ID
shouldn't be:
AesCbcCryptor::CRYPTOR_ID
?
| @@ -193,7 +193,7 @@ protected function customParams() | |||
| } | |||
There was a problem hiding this comment.
Is this ok for buildData method to return null when signature declare return type as string ?
There was a problem hiding this comment.
the type in comment is just a hint for compatibility with parent IIRC
| @@ -139,4 +171,361 @@ public function testThrowErrorOnNoFileFound(): void | |||
| $this->expectException(PubNubServerException::class); | |||
There was a problem hiding this comment.
In testThrowErrorOnMalformedResponse
there is
$pubnub->setClient($client);
and
$this->pubnub->setClient($client);
Are those two needed?
There was a problem hiding this comment.
$this->pubnub->setClient($client); this one was not needed
This adds a lot of samples. Improves testing and coverage