Look for PHPDoc comments for non-existent parameters and make alternative suggestion.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Created by PhpStorm. |
||
4 | * User: dsmrt |
||
5 | * Date: 1/11/18 |
||
6 | * Time: 8:30 PM |
||
7 | */ |
||
8 | |||
9 | namespace flipbox\saml\sp\services\messages; |
||
10 | |||
11 | |||
12 | use craft\base\Component; |
||
13 | use flipbox\keychain\records\KeyChainRecord; |
||
14 | use flipbox\saml\core\exceptions\InvalidMessage; |
||
15 | use flipbox\saml\core\helpers\SecurityHelper; |
||
16 | use flipbox\saml\sp\Saml; |
||
17 | use LightSaml\Model\Assertion\Assertion; |
||
18 | use LightSaml\Model\Assertion\EncryptedAssertionReader; |
||
19 | use LightSaml\Validator\Model\Assertion\AssertionTimeValidator; |
||
20 | use LightSaml\Validator\Model\Assertion\AssertionValidator; |
||
21 | use LightSaml\Validator\Model\NameId\NameIdValidator; |
||
22 | use LightSaml\Validator\Model\Statement\StatementValidator; |
||
23 | use LightSaml\Validator\Model\Subject\SubjectValidator; |
||
24 | |||
25 | class Response extends Component |
||
26 | { |
||
27 | |||
28 | /** |
||
29 | * @param Assertion $assertion |
||
30 | * @return bool |
||
31 | */ |
||
32 | public function isValidTimeAssertion(Assertion $assertion) |
||
33 | { |
||
34 | $validator = new AssertionTimeValidator(); |
||
35 | $validator->validateTimeRestrictions($assertion, (new \DateTime())->getTimestamp(), 0); |
||
36 | return true; |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * @param Assertion $assertion |
||
41 | * @return bool |
||
42 | */ |
||
43 | public function isValidAssertion(Assertion $assertion) |
||
44 | { |
||
45 | $nameValidator = new NameIdValidator; |
||
46 | $validator = new AssertionValidator( |
||
47 | $nameValidator, |
||
48 | new SubjectValidator($nameValidator), |
||
49 | new StatementValidator |
||
50 | ); |
||
51 | |||
52 | $validator->validateAssertion($assertion); |
||
53 | |||
54 | return true; |
||
55 | } |
||
56 | |||
57 | |||
58 | /** |
||
59 | * @param KeyChainRecord $chainRecord |
||
0 ignored issues
–
show
|
|||
60 | * @param EncryptedAssertionReader $encryptedAssertion |
||
61 | */ |
||
62 | public function decryptAssertions(\LightSaml\Model\Protocol\Response $response, KeyChainRecord $keyChainRecord) |
||
63 | { |
||
64 | $credential = SecurityHelper::createCredential($keyChainRecord); |
||
65 | |||
66 | $decryptDeserializeContext = new \LightSaml\Model\Context\DeserializationContext(); |
||
67 | |||
68 | /** @var \LightSaml\Model\Assertion\EncryptedAssertionReader $encryptedAssertion */ |
||
69 | foreach ($response->getAllEncryptedAssertions() as $encryptedAssertion) { |
||
70 | $response->addAssertion( |
||
71 | $encryptedAssertion->decryptMultiAssertion([$credential], $decryptDeserializeContext) |
||
72 | ); |
||
73 | } |
||
74 | |||
75 | } |
||
76 | } |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$ireland
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was changed, but the annotation was not.