@@ -84,7 +84,7 @@ class Aggregator
8484 /**
8585 * Duration we should cache generated metadata.
8686 *
87- * @var int
87+ * @var int|null
8888 */
8989 protected $ cacheGenerated ;
9090
@@ -160,7 +160,7 @@ class Aggregator
160160 *
161161 * @var string
162162 */
163- protected $ cacheId ;
163+ protected $ cacheId = ' dummy ' ;
164164
165165 /**
166166 * The cache tag for our generated metadata.
@@ -170,7 +170,7 @@ class Aggregator
170170 *
171171 * @var string
172172 */
173- protected $ cacheTag ;
173+ protected $ cacheTag = ' dummy ' ;
174174
175175 /**
176176 * The registration information for our generated metadata.
@@ -220,21 +220,23 @@ protected function __construct($id, Configuration $config)
220220 $ signKey = $ config ->getString ('sign.privatekey ' , null );
221221 if ($ signKey !== null ) {
222222 $ signKey = System::resolvePath ($ signKey , $ certDir );
223- $ this -> signKey = @file_get_contents ($ signKey );
224- if ($ this -> signKey === null ) {
223+ $ sk = @file_get_contents ($ signKey );
224+ if ($ sk === false ) {
225225 throw new Exception ('Unable to load private key from ' .var_export ($ signKey , true ));
226226 }
227+ $ this ->signKey = $ sk ;
227228 }
228229
229230 $ this ->signKeyPass = $ config ->getString ('sign.privatekey_pass ' , null );
230231
231232 $ signCert = $ config ->getString ('sign.certificate ' , null );
232233 if ($ signCert !== null ) {
233234 $ signCert = System::resolvePath ($ signCert , $ certDir );
234- $ this -> signCert = @file_get_contents ($ signCert );
235- if ($ this -> signCert === null ) {
235+ $ sc = @file_get_contents ($ signCert );
236+ if ($ sc === false ) {
236237 throw new Exception ('Unable to load certificate file from ' .var_export ($ signCert , true ));
237238 }
239+ $ this ->signCert = $ sc ;
238240 }
239241
240242 $ this ->signAlg = $ config ->getString ('sign.algorithm ' , XMLSecurityKey::RSA_SHA1 );
@@ -244,7 +246,7 @@ protected function __construct($id, Configuration $config)
244246
245247 $ this ->sslCAFile = $ config ->getString ('ssl.cafile ' , null );
246248
247- $ this ->regInfo = $ config ->getArray ('RegistrationInfo ' , null );
249+ $ this ->regInfo = $ config ->getArray ('RegistrationInfo ' , [] );
248250
249251 $ this ->initSources ($ config ->getConfigList ('sources ' ));
250252 }
@@ -256,6 +258,7 @@ protected function __construct($id, Configuration $config)
256258 * This is called from the constructor, and can be overridden in subclasses.
257259 *
258260 * @param array $sources The sources as an array of SimpleSAML_Configuration objects.
261+ * @return void
259262 */
260263 protected function initSources (array $ sources )
261264 {
@@ -269,6 +272,7 @@ protected function initSources(array $sources)
269272 * Return an instance of the aggregator with the given id.
270273 *
271274 * @param string $id The id of the aggregator.
275+ * @return Aggregator
272276 */
273277 public static function getAggregator ($ id )
274278 {
@@ -297,6 +301,7 @@ public function getId()
297301 * @param string $data The data.
298302 * @param int $expires The timestamp the data expires.
299303 * @param string|null $tag An extra tag that can be used to verify the validity of the cached data.
304+ * @return void
300305 */
301306 public function addCacheItem ($ id , $ data , $ expires , $ tag = null )
302307 {
@@ -305,7 +310,7 @@ public function addCacheItem($id, $data, $expires, $tag = null)
305310 assert ('is_int($expires) ' );
306311 assert ('is_null($tag) || is_string($tag) ' );
307312
308- $ cacheFile = $ this ->cacheDirectory .'/ ' .$ id ;
313+ $ cacheFile = strval ( $ this ->cacheDirectory ) .'/ ' .$ id ;
309314 try {
310315 System::writeFile ($ cacheFile , $ data );
311316 } catch (\Exception $ e ) {
@@ -339,7 +344,7 @@ public function isCacheValid($id, $tag = null)
339344 assert ('is_string($id) ' );
340345 assert ('is_null($tag) || is_string($tag) ' );
341346
342- $ cacheFile = $ this ->cacheDirectory .'/ ' .$ id ;
347+ $ cacheFile = strval ( $ this ->cacheDirectory ) .'/ ' .$ id ;
343348 if (!file_exists ($ cacheFile )) {
344349 return false ;
345350 }
@@ -390,7 +395,7 @@ public function getCacheItem($id, $tag = null)
390395 return null ;
391396 }
392397
393- $ cacheFile = $ this ->cacheDirectory .'/ ' .$ id ;
398+ $ cacheFile = strval ( $ this ->cacheDirectory ) .'/ ' .$ id ;
394399 return @file_get_contents ($ cacheFile );
395400 }
396401
@@ -405,7 +410,7 @@ public function getCacheFile($id)
405410 {
406411 assert ('is_string($id) ' );
407412
408- $ cacheFile = $ this ->cacheDirectory .'/ ' .$ id ;
413+ $ cacheFile = strval ( $ this ->cacheDirectory ) .'/ ' .$ id ;
409414 if (!file_exists ($ cacheFile )) {
410415 return null ;
411416 }
@@ -427,13 +432,15 @@ public function getCAFile()
427432
428433 /**
429434 * Sign the generated EntitiesDescriptor.
435+ * @return void
430436 */
431437 protected function addSignature (SignedElement $ element )
432438 {
433439 if ($ this ->signKey === null ) {
434440 return ;
435441 }
436442
443+ /** @var string $this->signAlg */
437444 $ privateKey = new XMLSecurityKey ($ this ->signAlg , ['type ' => 'private ' ]);
438445 if ($ this ->signKeyPass !== null ) {
439446 $ privateKey ->passphrase = $ this ->signKeyPass ;
@@ -456,14 +463,8 @@ protected function addSignature(SignedElement $element)
456463 *
457464 * @return array An array containing all the EntityDescriptors found.
458465 */
459- private static function extractEntityDescriptors ($ entity )
466+ private static function extractEntityDescriptors (EntitiesDescriptor $ entity )
460467 {
461- assert ('$entity instanceof EntitiesDescriptor ' );
462-
463- if (!($ entity instanceof EntitiesDescriptor)) {
464- return [];
465- }
466-
467468 $ results = [];
468469 foreach ($ entity ->children as $ child ) {
469470 if ($ child instanceof EntityDescriptor) {
@@ -488,7 +489,7 @@ protected function getEntitiesDescriptor()
488489 $ now = time ();
489490
490491 // add RegistrationInfo extension if enabled
491- if ($ this ->regInfo !== null ) {
492+ if (! empty ( $ this ->regInfo ) ) {
492493 $ ri = new RegistrationInfo ();
493494 $ ri ->registrationInstant = $ now ;
494495 foreach ($ this ->regInfo as $ riName => $ riValues ) {
@@ -607,6 +608,7 @@ protected function filter(EntitiesDescriptor $descriptor)
607608 * Set this aggregator to exclude a set of entities from the resulting aggregate.
608609 *
609610 * @param array|null $entities The entity IDs of the entities to exclude.
611+ * @return void
610612 */
611613 public function excludeEntities ($ entities )
612614 {
@@ -634,6 +636,7 @@ public function excludeEntities($entities)
634636 * - 'shib13-aa': all SHIB1.3-capable attribute authorities.
635637 *
636638 * @param array|null $set An array of the different roles and protocols to filter by.
639+ * @return void
637640 */
638641 public function setFilters ($ set )
639642 {
@@ -728,6 +731,7 @@ public function getMetadata()
728731
729732 /**
730733 * Update the cached copy of our metadata.
734+ * @return void
731735 */
732736 public function updateCache ()
733737 {
0 commit comments