Skip to content

Commit 2380cb4

Browse files
committed
Fix Psalm-issues
1 parent 9cabc30 commit 2380cb4

3 files changed

Lines changed: 18 additions & 12 deletions

File tree

hooks/hook_cron.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ function metarefresh_hook_cron(&$croninfo)
2222
$mconfig = \SimpleSAML\Configuration::getOptionalConfig('config-metarefresh.php');
2323

2424
$sets = $mconfig->getConfigList('sets', []);
25-
$stateFile = $config->getPathValue('datadir', 'data/').'metarefresh-state.php';
25+
/** @var string $datadir */
26+
$datadir = $config->getPathValue('datadir', 'data/');
27+
$stateFile = $datadir.'metarefresh-state.php';
2628

2729
foreach ($sets as $setkey => $set) {
2830
// Only process sets where cron matches the current cron tag
@@ -42,6 +44,10 @@ function metarefresh_hook_cron(&$croninfo)
4244

4345
$outputDir = $set->getString('outputDir');
4446
$outputDir = $config->resolvePath($outputDir);
47+
if ($outputDir === null) {
48+
throw \Exception("Invalid outputDir specified.");
49+
}
50+
4551
$outputFormat = $set->getValueValidate('outputFormat', ['flatfile', 'serialize'], 'flatfile');
4652

4753
$oldMetadataSrc = \SimpleSAML\Metadata\MetaDataStorageSource::getSource([

lib/ARP.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class ARP
3636
* @param string $prefix
3737
* @param string $suffix
3838
*/
39-
public function __construct($metadata, $attributemap_filename, $prefix, $suffix)
39+
public function __construct(array $metadata, $attributemap_filename, $prefix, $suffix)
4040
{
4141
$this->metadata = $metadata;
4242
$this->prefix = $prefix;
@@ -135,7 +135,7 @@ private function getEntryXML($entry)
135135
*
136136
* @return string
137137
*/
138-
private function getEntryXMLcontent($entry)
138+
private function getEntryXMLcontent(array $entry)
139139
{
140140
if (!array_key_exists('attributes', $entry)) {
141141
return '';

lib/MetaLoader.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ public function __construct($expire = null, $stateFile = null, $oldMetadataSrc =
5555
$this->stateFile = $stateFile;
5656

5757
// Read file containing $state from disk
58-
if (is_readable($stateFile)) {
59-
include $stateFile;
58+
if (!is_null($stateFile) && is_readable($stateFile)) {
59+
include($stateFile);
6060
}
6161
}
6262

@@ -94,7 +94,7 @@ public function setTypes($types)
9494
* @param $source array
9595
* @return void
9696
*/
97-
public function loadSource($source)
97+
public function loadSource(array $source)
9898
{
9999
if (preg_match('@^https?://@i', $source['src'])) {
100100
// Build new HTTP context
@@ -225,7 +225,7 @@ public function loadSource($source)
225225
* @param array $source
226226
* @return array
227227
*/
228-
private function createContext($source)
228+
private function createContext(array $source)
229229
{
230230
$config = Configuration::getInstance();
231231
$name = $config->getString('technicalcontact_name', null);
@@ -255,7 +255,7 @@ private function createContext($source)
255255
* @param array $source
256256
* @return void
257257
*/
258-
private function addCachedMetadata($source)
258+
private function addCachedMetadata(array $source)
259259
{
260260
if (isset($this->oldMetadataSrc)) {
261261
foreach ($this->types as $type) {
@@ -278,7 +278,7 @@ private function addCachedMetadata($source)
278278
* @param array $responseHeaders
279279
* @return void
280280
*/
281-
private function saveState($source, $responseHeaders)
281+
private function saveState(array $source, array $responseHeaders)
282282
{
283283
if (isset($source['conditionalGET']) && $source['conditionalGET']) {
284284
// Headers section
@@ -309,7 +309,7 @@ private function saveState($source, $responseHeaders)
309309
* @return \SimpleSAML\Metadata\SAMLParser[]
310310
* @throws \Exception
311311
*/
312-
private function loadXML($data, $source)
312+
private function loadXML($data, array $source)
313313
{
314314
try {
315315
$doc = \SAML2\DOMDocumentFactory::fromString($data);
@@ -379,7 +379,7 @@ public function dumpMetadataStdOut()
379379
* @param array|null $template The template.
380380
* @return void
381381
*/
382-
private function addMetadata($filename, $metadata, $type, $template = null)
382+
private function addMetadata($filename, array $metadata, $type, array $template = null)
383383
{
384384
if ($metadata === null) {
385385
return;
@@ -418,7 +418,7 @@ private function addMetadata($filename, $metadata, $type, $template = null)
418418
* @param \SimpleSAML\Configuration $config
419419
* @return void
420420
*/
421-
public function writeARPfile($config)
421+
public function writeARPfile(Configuration $config)
422422
{
423423
Assert::isInstanceOf($config, Configuration::class);
424424

0 commit comments

Comments
 (0)