Skip to content

Commit d8b7541

Browse files
committed
TASK: Adjust phpstan config to apply level 8 rules to the Flow/Security context and remove breaking changes
1 parent 036e277 commit d8b7541

File tree

9 files changed

+31
-24
lines changed

9 files changed

+31
-24
lines changed

Neos.Flow/Classes/Security/Authentication/Provider/FileBasedSimpleKeyProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function authenticate(TokenInterface $authenticationToken)
107107
protected function validateCredentials(PasswordTokenInterface $authenticationToken): void
108108
{
109109
$key = $this->fileBasedSimpleKeyService->getKey($this->options['keyName']);
110-
if (!$this->hashService->validatePassword($authenticationToken->getPassword(),$key)) {
110+
if (!$this->hashService->validatePassword($authenticationToken->getPassword(), $key)) {
111111
$authenticationToken->setAuthenticationStatus(TokenInterface::WRONG_CREDENTIALS);
112112
return;
113113
}

Neos.Flow/Classes/Security/Authorization/Privilege/Entity/Doctrine/EntityPrivilege.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
* source code.
1212
*/
1313

14-
use Doctrine\Persistence\Mapping\ClassMetadata;
1514
use Doctrine\ORM\EntityManager;
1615
use Doctrine\ORM\EntityManagerInterface;
1716
use Neos\Eel\Context as EelContext;

Neos.Flow/Classes/Security/Authorization/Privilege/Entity/Doctrine/EntityPrivilegeExpressionParser.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ class EntityPrivilegeExpressionParser extends CompilingEelParser
2525
/**
2626
* @param array<string,mixed> $result
2727
* @param array<string,mixed> $sub
28+
* @return void
2829
*/
29-
public function NotExpression_exp(&$result, $sub): void
30+
public function NotExpression_exp(&$result, $sub)
3031
{
3132
if (!isset($result['code'])) {
3233
$result['code'] = '$context';
@@ -37,27 +38,30 @@ public function NotExpression_exp(&$result, $sub): void
3738
/**
3839
* @param array<string,mixed> $result
3940
* @param array<string,mixed> $sub
41+
* @return void
4042
*/
41-
public function Disjunction_rgt(&$result, $sub): void
43+
public function Disjunction_rgt(&$result, $sub)
4244
{
4345
$result['code'] = '$context->callAndWrap(\'disjunction\', array(' . $this->unwrapExpression($result['code']) . ', ' . $this->unwrapExpression($sub['code']) . '))';
4446
}
4547

4648
/**
4749
* @param array<string,mixed> $result
4850
* @param array<string,mixed> $sub
51+
* @return
4952
*/
50-
public function Conjunction_rgt(&$result, $sub): void
53+
public function Conjunction_rgt(&$result, $sub)
5154
{
5255
$result['code'] = '$context->callAndWrap(\'conjunction\', array(' . $this->unwrapExpression($result['code']) . ', ' . $this->unwrapExpression($sub['code']) . '))';
5356
}
5457

5558
/**
5659
* @param array<string,mixed> $result
5760
* @param array<string,mixed> $sub
61+
* @return void
5862
* @throws ParserException
5963
*/
60-
public function Comparison_rgt(&$result, $sub): void
64+
public function Comparison_rgt(&$result, $sub)
6165
{
6266
$lval = $result['code'];
6367
$rval = $sub['code'];

Neos.Flow/Classes/Security/Authorization/Privilege/Entity/Doctrine/PropertyConditionGenerator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ public function getSql(DoctrineSqlFilter $sqlFilter, ORMClassMetadata $targetEnt
254254
} elseif ($targetEntity->isSingleValuedAssociation($targetEntityPropertyName) === true && $targetEntity->isAssociationInverseSide($targetEntityPropertyName) === true) {
255255
throw new InvalidQueryRewritingConstraintException(
256256
'Single valued properties from the inverse side are not supported in a content security constraint path! Got: "'
257-
. $this->path . ' ' . $this->operator . ' ' . json_encode($this->operandDefinition) . '"'
258-
, 1416397754
257+
. $this->path . ' ' . $this->operator . ' ' . json_encode($this->operandDefinition) . '"',
258+
1416397754
259259
);
260260
} elseif ($targetEntity->isCollectionValuedAssociation($targetEntityPropertyName) === true) {
261261
return $this->getSqlForPropertyContains($sqlFilter, $quoteStrategy, $targetEntity, $targetTableAlias, $targetEntityPropertyName);

Neos.Flow/Classes/Security/Cryptography/HashService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function injectSettings(array $settings)
7272
* @return string The hash of the string
7373
* @throws InvalidArgumentForHashGenerationException if something else than a string was given as parameter
7474
*/
75-
public function generateHmac(string $string): string
75+
public function generateHmac(string $string)
7676
{
7777
return hash_hmac('sha1', $string, $this->getEncryptionKey());
7878
}
@@ -117,7 +117,7 @@ public function validateHmac($string, $hmac)
117117
* @throws InvalidHashException if the hash did not fit to the data.
118118
* @todo Mark as API once it is more stable
119119
*/
120-
public function validateAndStripHmac(string $string): string
120+
public function validateAndStripHmac(string $string)
121121
{
122122
if (strlen($string) < 40) {
123123
throw new InvalidArgumentForHashGenerationException('A hashed string must contain at least 40 characters, the given string was only ' . strlen($string) . ' characters long.', 1320830276);

Neos.Flow/Classes/Security/Cryptography/RsaWalletServiceInterface.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function registerPublicKeyFromString($publicKeyString);
5454
* @return OpenSslRsaKey The public key
5555
* @throws InvalidKeyPairIdException If the given fingerprint identifies no valid key pair
5656
*/
57-
public function getPublicKey(string $fingerprint): OpenSslRsaKey;
57+
public function getPublicKey($fingerprint);
5858

5959
/**
6060
* Decrypts the given cypher with the private key identified by the given fingerprint
@@ -67,7 +67,7 @@ public function getPublicKey(string $fingerprint): OpenSslRsaKey;
6767
* @throws InvalidKeyPairIdException If the given fingerprint identifies no valid keypair
6868
* @throws DecryptionNotAllowedException If the given fingerprint identifies a keypair for encrypted passwords
6969
*/
70-
public function decrypt(string $cypher, string $fingerprint): string;
70+
public function decrypt($cypher, $fingerprint);
7171

7272
/**
7373
* Signs the given plaintext with the private key identified by the given fingerprint
@@ -77,7 +77,7 @@ public function decrypt(string $cypher, string $fingerprint): string;
7777
* @return string The signature of the given plaintext
7878
* @throws InvalidKeyPairIdException If the given fingerprint identifies no valid keypair
7979
*/
80-
public function sign(string $plaintext, string $fingerprint): string;
80+
public function sign($plaintext, $fingerprint);
8181

8282
/**
8383
* Checks whether the given signature is valid for the given plaintext
@@ -88,7 +88,7 @@ public function sign(string $plaintext, string $fingerprint): string;
8888
* @param string $fingerprint The fingerprint to identify to correct public key
8989
* @return boolean true if the signature is correct for the given plaintext and public key
9090
*/
91-
public function verifySignature(string $plaintext, string $signature, string $fingerprint): bool;
91+
public function verifySignature($plaintext, $signature, $fingerprint);
9292

9393
/**
9494
* Encrypts the given plaintext with the public key identified by the given fingerprint
@@ -109,12 +109,13 @@ public function encryptWithPublicKey($plaintext, $fingerprint);
109109
* @param string $fingerprint The fingerprint to identify to correct private key
110110
* @return boolean true if the password is correct
111111
*/
112-
public function checkRSAEncryptedPassword(string $encryptedPassword, string $passwordHash, string $salt, string $fingerprint): bool;
112+
public function checkRSAEncryptedPassword($encryptedPassword, $passwordHash, $salt, $fingerprint);
113113

114114
/**
115115
* Destroys the keypair identified by the given fingerprint
116116
*
117+
* @return void
117118
* @throws InvalidKeyPairIdException If the given fingerprint identifies no valid key pair
118119
*/
119-
public function destroyKeypair(string $fingerprint): void;
120+
public function destroyKeypair($fingerprint);
120121
}

Neos.Flow/Classes/Security/Cryptography/RsaWalletServicePhp.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public function registerPublicKeyFromString($publicKeyString)
169169
* @return OpenSslRsaKey The public key
170170
* @throws InvalidKeyPairIdException If the given fingerprint identifies no valid key pair
171171
*/
172-
public function getPublicKey(string $fingerprint): OpenSslRsaKey
172+
public function getPublicKey($fingerprint)
173173
{
174174
if (!isset($this->keys[$fingerprint])) {
175175
throw new InvalidKeyPairIdException('Invalid keypair fingerprint given', 1231438860);
@@ -212,7 +212,7 @@ public function encryptWithPublicKey($plaintext, $fingerprint)
212212
* @throws DecryptionNotAllowedException If the given fingerprint identifies a keypair for encrypted passwords
213213
* @throws SecurityException If decryption failed for some other reason
214214
*/
215-
public function decrypt(string $cypher, string $fingerprint): string
215+
public function decrypt($cypher, $fingerprint)
216216
{
217217
if (!isset($this->keys[$fingerprint])) {
218218
throw new InvalidKeyPairIdException('Invalid keypair fingerprint given', 1231438861);
@@ -235,7 +235,7 @@ public function decrypt(string $cypher, string $fingerprint): string
235235
* @return string The signature of the given plaintext
236236
* @throws InvalidKeyPairIdException If the given fingerprint identifies no valid keypair
237237
*/
238-
public function sign(string $plaintext, string $fingerprint): string
238+
public function sign($plaintext, $fingerprint)
239239
{
240240
if (!isset($this->keys[$fingerprint])) {
241241
throw new InvalidKeyPairIdException('Invalid keypair fingerprint given', 1299095799);
@@ -257,7 +257,7 @@ public function sign(string $plaintext, string $fingerprint): string
257257
* @return boolean true if the signature is correct for the given plaintext and public key
258258
* @throws InvalidKeyPairIdException
259259
*/
260-
public function verifySignature(string $plaintext, string $signature, string $fingerprint): bool
260+
public function verifySignature($plaintext, $signature, $fingerprint)
261261
{
262262
if (!isset($this->keys[$fingerprint])) {
263263
throw new InvalidKeyPairIdException('Invalid keypair fingerprint given', 1304959763);
@@ -279,7 +279,7 @@ public function verifySignature(string $plaintext, string $signature, string $fi
279279
* @return boolean true if the password is correct
280280
* @throws InvalidKeyPairIdException If the given fingerprint identifies no valid keypair
281281
*/
282-
public function checkRSAEncryptedPassword(string $encryptedPassword, string $passwordHash, string $salt, string $fingerprint): bool
282+
public function checkRSAEncryptedPassword($encryptedPassword, $passwordHash, $salt, $fingerprint)
283283
{
284284
if (!isset($this->keys[$fingerprint])) {
285285
throw new InvalidKeyPairIdException('Invalid keypair fingerprint given', 1233655216);
@@ -296,7 +296,7 @@ public function checkRSAEncryptedPassword(string $encryptedPassword, string $pas
296296
* @param string $fingerprint The fingerprint
297297
* @throws InvalidKeyPairIdException If the given fingerprint identifies no valid key pair
298298
*/
299-
public function destroyKeypair(string $fingerprint): void
299+
public function destroyKeypair($fingerprint): void
300300
{
301301
if (!isset($this->keys[$fingerprint])) {
302302
throw new InvalidKeyPairIdException('Invalid keypair fingerprint given', 1231438863);

Neos.Flow/Classes/Security/SessionDataContainer.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ public function getSecurityTokens(): array
4747
* Set the current list of security tokens with their data.
4848
*
4949
* @param array<TokenInterface> $securityTokens
50+
* @return void
5051
*/
51-
public function setSecurityTokens(array $securityTokens): void
52+
public function setSecurityTokens(array $securityTokens)
5253
{
5354
foreach ($securityTokens as $token) {
5455
if ($token instanceof SessionlessTokenInterface) {
@@ -72,8 +73,9 @@ public function getCsrfProtectionTokens(): array
7273
* set the list of currently active CSRF tokens.
7374
*
7475
* @param array<string,string|bool> $csrfProtectionTokens
76+
* @return void
7577
*/
76-
public function setCsrfProtectionTokens(array $csrfProtectionTokens): void
78+
public function setCsrfProtectionTokens(array $csrfProtectionTokens)
7779
{
7880
$this->csrfProtectionTokens = $csrfProtectionTokens;
7981
}

phpstan.neon.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
parameters:
22
level: 8
33
paths:
4+
- Neos.Flow/Classes/Security
45
- Neos.Flow/Classes/Session
56
- Neos.Flow/Classes/SignalSlot
67
- Neos.Flow/Classes/Utility

0 commit comments

Comments
 (0)