@@ -41,12 +41,12 @@ class CAS extends Auth\Source
4141 public const AUTHID = '\SimpleSAML\Module\cas\Auth\Source\CAS.AuthId ' ;
4242
4343 /**
44- * @var array with ldap configuration
44+ * @var array<mixed> with ldap configuration
4545 */
4646 private array $ ldapConfig ;
4747
4848 /**
49- * @var array cas configuration
49+ * @var array<mixed> cas configuration
5050 */
5151 private array $ casConfig ;
5252
@@ -64,8 +64,8 @@ class CAS extends Auth\Source
6464 /**
6565 * Constructor for this authentication source.
6666 *
67- * @param array $info Information about this authentication source.
68- * @param array $config Configuration.
67+ * @param array<mixed> $info Information about this authentication source.
68+ * @param array<mixed> $config Configuration.
6969 */
7070 public function __construct (array $ info , array $ config )
7171 {
@@ -105,7 +105,7 @@ public function __construct(array $info, array $config)
105105 * @param string $ticket
106106 * @param string $service
107107 *
108- * @return array username and attributes
108+ * @return array<mixed> username and attributes
109109 */
110110 private function casValidate (string $ ticket , string $ service ): array
111111 {
@@ -114,9 +114,11 @@ private function casValidate(string $ticket, string $service): array
114114 'ticket ' => $ ticket ,
115115 'service ' => $ service ,
116116 ]);
117- $ result = $ httpUtils ->fetch ($ url );
118117
119118 /** @var string $result */
119+ $ result = $ httpUtils ->fetch ($ url );
120+
121+ /** @var string $res */
120122 $ res = preg_split ("/ \r? \n/ " , $ result );
121123
122124 if (strcmp ($ res [0 ], "yes " ) == 0 ) {
@@ -133,7 +135,7 @@ private function casValidate(string $ticket, string $service): array
133135 * @param string $ticket
134136 * @param string $service
135137 *
136- * @return array username and attributes
138+ * @return array<mixed> username and attributes
137139 */
138140 private function casServiceValidate (string $ ticket , string $ service ): array
139141 {
@@ -151,15 +153,17 @@ private function casServiceValidate(string $ticket, string $service): array
151153 $ dom = DOMDocumentFactory::fromString ($ result );
152154 $ xPath = new DOMXpath ($ dom );
153155 $ xPath ->registerNamespace ("cas " , 'http://www.yale.edu/tp/cas ' );
156+
154157 $ success = $ xPath ->query ("/cas:serviceResponse/cas:authenticationSuccess/cas:user " );
155- if ($ success ->length == 0 ) {
158+ if ($ success === false || $ success ->length = == 0 ) {
156159 $ failure = $ xPath ->evaluate ("/cas:serviceResponse/cas:authenticationFailure " );
157160 throw new Exception ("Error when validating CAS service ticket: " . $ failure ->item (0 )->textContent );
158161 } else {
159162 $ attributes = [];
160163 if ($ casattributes = $ this ->casConfig ['attributes ' ]) {
161164 // Some has attributes in the xml - attributes is a list of XPath expressions to get them
162165 foreach ($ casattributes as $ name => $ query ) {
166+ /** @var \DOMNodeList<\DOMNode> $attrs */
163167 $ attrs = $ xPath ->query ($ query );
164168 foreach ($ attrs as $ attrvalue ) {
165169 $ attributes [$ name ][] = $ attrvalue ->textContent ;
@@ -184,7 +188,7 @@ private function casServiceValidate(string $ticket, string $service): array
184188 *
185189 * @param string $ticket
186190 * @param string $service
187- * @return array username and attributes
191+ * @return array<mixed> username and attributes
188192 */
189193 protected function casValidation (string $ ticket , string $ service ): array
190194 {
@@ -201,7 +205,7 @@ protected function casValidation(string $ticket, string $service): array
201205
202206 /**
203207 * Called by linkback, to finish validate/ finish logging in.
204- * @param array $state
208+ * @param array<mixed> $state
205209 */
206210 public function finalStep (array &$ state ): void
207211 {
@@ -237,7 +241,7 @@ public function finalStep(array &$state): void
237241 /**
238242 * Log-in using cas
239243 *
240- * @param array &$state Information about the current authentication.
244+ * @param array<mixed> &$state Information about the current authentication.
241245 */
242246 public function authenticate (array &$ state ): void
243247 {
@@ -264,7 +268,7 @@ public function authenticate(array &$state): void
264268 * should be called with the state. If this operation can be completed without
265269 * showing the user a page, or redirecting, this function should return.
266270 *
267- * @param array &$state Information about the current logout operation.
271+ * @param array<mixed> &$state Information about the current logout operation.
268272 */
269273 public function logout (array &$ state ): void
270274 {
0 commit comments