Skip to content

Commit

Permalink
fix psalm issues (#5595)
Browse files Browse the repository at this point in the history
  • Loading branch information
gharlan committed Feb 20, 2023
1 parent b4886ff commit 61a06ae
Show file tree
Hide file tree
Showing 15 changed files with 94 additions and 148 deletions.
17 changes: 11 additions & 6 deletions .tools/phpstan/baseline.neon
Expand Up @@ -1625,11 +1625,6 @@ parameters:
count: 1
path: ../../redaxo/src/core/lib/autoload.php

-
message: "#^Method rex_be_controller\\:\\:getPageObject\\(\\) has parameter \\$page with no value type specified in iterable type array\\.$#"
count: 1
path: ../../redaxo/src/core/lib/be/controller.php

-
message: "#^Method rex_be_controller\\:\\:includeCurrentPageSubPath\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -2866,7 +2861,7 @@ parameters:
path: ../../redaxo/src/core/lib/sql/table.php

-
message: "#^Parameter \\#2 \\$createCallback of static method rex_sql_table\\:\\:getInstance\\(\\) expects \\(callable\\(\\.\\.\\.mixed\\)\\: static\\(rex_sql_table\\)\\|null\\)\\|null, Closure\\(mixed, mixed\\)\\: static\\(rex_sql_table\\) given\\.$#"
message: "#^Parameter \\#2 \\$createCallback of static method rex_sql_table\\:\\:getInstance\\(\\) expects \\(callable\\(\\.\\.\\.mixed\\)\\: static\\(rex_sql_table\\)\\|null\\)\\|null, Closure\\(int, string\\)\\: static\\(rex_sql_table\\) given\\.$#"
count: 1
path: ../../redaxo/src/core/lib/sql/table.php

Expand Down Expand Up @@ -2920,6 +2915,16 @@ parameters:
count: 1
path: ../../redaxo/src/core/lib/util/file.php

-
message: "#^Method rex_file\\:\\:putCache\\(\\) has parameter \\$content with no value type specified in iterable type array\\.$#"
count: 1
path: ../../redaxo/src/core/lib/util/file.php

-
message: "#^Method rex_file\\:\\:putConfig\\(\\) has parameter \\$content with no value type specified in iterable type array\\.$#"
count: 1
path: ../../redaxo/src/core/lib/util/file.php

-
message: "#^Method rex_finder\\:\\:callFactoryClass\\(\\) has parameter \\$arguments with no value type specified in iterable type array\\.$#"
count: 1
Expand Down
1 change: 0 additions & 1 deletion .tools/psalm/baseline-taint.xml
Expand Up @@ -76,7 +76,6 @@
</file>
<file src="redaxo/src/core/lib/response.php">
<TaintedHeader>
<code>$name .': ' . $value</code>
<code>$str</code>
</TaintedHeader>
</file>
Expand Down
89 changes: 1 addition & 88 deletions .tools/psalm/baseline.xml
Expand Up @@ -2671,34 +2671,6 @@
<code>$_SERVER['PHP_SELF']</code>
</PossiblyUndefinedArrayOffset>
</file>
<file src="redaxo/src/core/boot.php">
<MixedArgument>
<code>$REX['BACKEND_FOLDER']</code>
<code>$REX['BACKEND_FOLDER']</code>
<code>$REX['HTDOCS_PATH']</code>
<code>$REX['HTDOCS_PATH']</code>
<code>$value</code>
</MixedArgument>
<MixedArgumentTypeCoercion>
<code>$key</code>
</MixedArgumentTypeCoercion>
<MixedArrayAccess>
<code>$REX['BACKEND_FOLDER']</code>
<code>$REX['BACKEND_FOLDER']</code>
<code>$REX['HTDOCS_PATH']</code>
<code>$REX['HTDOCS_PATH']</code>
<code>$REX['REDAXO']</code>
</MixedArrayAccess>
<MixedAssignment>
<code>$value</code>
</MixedAssignment>
<MixedOperand>
<code>rex::getProperty('hsts_max_age', 31536000)</code>
</MixedOperand>
<PossiblyUndefinedArrayOffset>
<code>$_SERVER['REQUEST_TIME_FLOAT']</code>
</PossiblyUndefinedArrayOffset>
</file>
<file src="redaxo/src/core/console.php">
<PossiblyNullArgument>
<code>$command-&gt;getName()</code>
Expand Down Expand Up @@ -3015,9 +2987,6 @@
<MixedArgument>
<code>$this-&gt;meta_navigation</code>
</MixedArgument>
<PossiblyNullReference>
<code>isPopup</code>
</PossiblyNullReference>
</file>
<file src="redaxo/src/core/fragments/core/navigation.php">
<MixedArgument>
Expand Down Expand Up @@ -3339,11 +3308,6 @@
<code>$strategy</code>
</NoValue>
</file>
<file src="redaxo/src/core/layout/bottom.php">
<PossiblyNullReference>
<code>hasLayout</code>
</PossiblyNullReference>
</file>
<file src="redaxo/src/core/layout/top.php">
<MixedArrayAccess>
<code>$block['headline']</code>
Expand All @@ -3352,9 +3316,6 @@
<MixedAssignment>
<code>$block</code>
</MixedAssignment>
<PossiblyNullReference>
<code>hasLayout</code>
</PossiblyNullReference>
</file>
<file src="redaxo/src/core/lib/api_function.php">
<MixedArgument>
Expand Down Expand Up @@ -3437,7 +3398,6 @@
<code>$page</code>
<code>$pageArray['title']</code>
<code>$pageArray['title']</code>
<code>$page[$i]</code>
<code>$plugin-&gt;getProperty('page')</code>
<code>$subProperties</code>
<code>$subProperties['title']</code>
Expand All @@ -3459,10 +3419,6 @@
<MixedArrayAccess>
<code>$subProperties['title']</code>
</MixedArrayAccess>
<MixedArrayOffset>
<code>self::$pages[$page[0]]</code>
<code>self::$pages[$page[0]]</code>
</MixedArrayOffset>
<MixedAssignment>
<code>$k</code>
<code>$page</code>
Expand All @@ -3479,21 +3435,6 @@
<code>$check($page)</code>
<code>$check($subpage)</code>
</MixedFunctionCall>
<PossiblyNullArgument>
<code>$currentPage-&gt;getPath()</code>
<code>$path</code>
<code>$path</code>
<code>$path</code>
<code>$path</code>
</PossiblyNullArgument>
<PossiblyNullReference>
<code>getHref</code>
<code>getPath</code>
<code>getSubPath</code>
<code>getTitle</code>
<code>getTitle</code>
<code>setHasLayout</code>
</PossiblyNullReference>
</file>
<file src="redaxo/src/core/lib/be/navigation.php">
<MixedArgumentTypeCoercion>
Expand Down Expand Up @@ -3528,11 +3469,6 @@
<code>isActive</code>
</MixedMethodCall>
</file>
<file src="redaxo/src/core/lib/be/page.php">
<PossiblyNullReference>
<code>getParent</code>
</PossiblyNullReference>
</file>
<file src="redaxo/src/core/lib/clang/clang.php">
<MixedArrayAccess>
<code>$data['priority']</code>
Expand All @@ -3551,9 +3487,6 @@
</MixedReturnTypeCoercion>
</file>
<file src="redaxo/src/core/lib/clang/service.php">
<PossiblyNullArrayOffset>
<code>$clangs</code>
</PossiblyNullArrayOffset>
<PossiblyNullReference>
<code>getId</code>
<code>getId</code>
Expand Down Expand Up @@ -4523,6 +4456,7 @@
<code>$__file</code>
<code>$__file</code>
<code>$__file</code>
<code>$cache</code>
<code>$dir</code>
<code>$key</code>
<code>$key</code>
Expand Down Expand Up @@ -4873,8 +4807,6 @@
<file src="redaxo/src/core/lib/sql/table.php">
<MixedArgument>
<code>$column</code>
<code>$db</code>
<code>$name</code>
<code>$oldName</code>
<code>$oldName</code>
<code>$stepParts</code>
Expand Down Expand Up @@ -4903,19 +4835,8 @@
<code>isModified</code>
</MixedMethodCall>
<PossiblyNullArgument>
<code>$column-&gt;getDefault()</code>
<code>$column-&gt;getExtra()</code>
<code>$comment</code>
<code>$oldName</code>
</PossiblyNullArgument>
<PossiblyNullReference>
<code>equals</code>
<code>equals</code>
<code>equals</code>
<code>setName</code>
<code>setName</code>
<code>setName</code>
</PossiblyNullReference>
</file>
<file src="redaxo/src/core/lib/sql/util.php">
<MixedArgument>
Expand Down Expand Up @@ -4963,15 +4884,7 @@
<code>$_SERVER['SERVER_PROTOCOL']</code>
</PossiblyUndefinedArrayOffset>
</file>
<file src="redaxo/src/core/lib/util/editor.php">
<PossiblyInvalidArgument>
<code>$line</code>
</PossiblyInvalidArgument>
</file>
<file src="redaxo/src/core/lib/util/file.php">
<MixedArgument>
<code>$content</code>
</MixedArgument>
<MixedInferredReturnType>
<code>array|T</code>
</MixedInferredReturnType>
Expand Down
8 changes: 0 additions & 8 deletions psalm.xml
Expand Up @@ -59,14 +59,6 @@
<file name="redaxo/src/core/pages/login.php"/>
</errorLevel>
</InvalidGlobal>
<UnnecessaryVarAnnotation>
<errorLevel type="suppress">
<!-- Fragments always contain a `@var rex_fragment $this` annotation, which is unused for psalm -->
<directory name="redaxo/src/addons/structure/plugins/content/fragments"/>
<directory name="redaxo/src/addons/structure/plugins/history/fragments"/>
<directory name="redaxo/src/core/fragments"/>
</errorLevel>
</UnnecessaryVarAnnotation>
<!-- level 2 issues - slightly lazy code writing, but provably low false-negatives -->
<DeprecatedMethod>
<errorLevel type="info">
Expand Down
21 changes: 14 additions & 7 deletions redaxo/src/core/boot.php
Expand Up @@ -3,10 +3,13 @@
/**
* REDAXO main boot file.
*
* @global string $REX['HTDOCS_PATH'] [Required] Relative path to htdocs directory
* @global string $REX['BACKEND_FOLDER'] [Required] Name of backend folder
* @global boolean $REX['REDAXO'] [Required] Backend/Frontend flag
* @global boolean $REX['LOAD_PAGE'] [Optional] Wether the front controller should be loaded or not. Default value is false.
* @var array{HTDOCS_PATH: non-empty-string, BACKEND_FOLDER: non-empty-string, REDAXO: bool, LOAD_PAGE?: bool, PATH_PROVIDER?: object, URL_PROVIDER?: object} $REX
* HTDOCS_PATH [Required] Relative path to htdocs directory
* BACKEND_FOLDER [Required] Name of backend folder
* REDAXO [Required] Backend/Frontend flag
* LOAD_PAGE [Optional] Wether the front controller should be loaded or not. Default value is false.
* PATH_PROVIDER [Optional] Custom path provider
* URL_PROVIDER [Optional] Custom url provider
*/

define('REX_MIN_PHP_VERSION', '8.1');
Expand Down Expand Up @@ -73,7 +76,7 @@
rex_url::init($urlProvider);

// start timer at the very beginning
rex::setProperty('timer', new rex_timer($_SERVER['REQUEST_TIME_FLOAT']));
rex::setProperty('timer', new rex_timer($_SERVER['REQUEST_TIME_FLOAT'] ?? null));
// add backend flag to rex
rex::setProperty('redaxo', $REX['REDAXO']);
// add core lang directory to rex_i18n
Expand Down Expand Up @@ -102,9 +105,13 @@
);
rex_file::putCache($cacheFile, $config);
}
/**
* @var string $key
* @var mixed $value
*/
foreach ($config as $key => $value) {
if (in_array($key, array('fileperm', 'dirperm'))) {
$value = octdec($value);
$value = octdec((string) $value);
}
rex::setProperty($key, $value);
}
Expand Down Expand Up @@ -137,7 +144,7 @@
}

if (true === rex::getProperty('use_hsts') && rex_request::isHttps()) {
rex_response::setHeader('Strict-Transport-Security', 'max-age='.rex::getProperty('hsts_max_age', 31536000)); // default 1 year
rex_response::setHeader('Strict-Transport-Security', 'max-age='.(int) rex::getProperty('hsts_max_age', 31536000)); // default 1 year
}
}

Expand Down
2 changes: 1 addition & 1 deletion redaxo/src/core/fragments/core/header.php
Expand Up @@ -4,7 +4,7 @@
* @psalm-scope-this rex_fragment
*/

$isPopup = rex_be_controller::getCurrentPageObject()->isPopup();
$isPopup = rex_be_controller::requireCurrentPageObject()->isPopup();
$isLogin = ('login' === rex_be_controller::getCurrentPage());
$isSetup = ('setup' === rex_be_controller::getCurrentPage());
?>
Expand Down
2 changes: 1 addition & 1 deletion redaxo/src/core/layout/bottom.php
@@ -1,6 +1,6 @@
<?php

$curPage = rex_be_controller::getCurrentPageObject();
$curPage = rex_be_controller::requireCurrentPageObject();

if (!$curPage->hasLayout()) {
if (rex_request::isPJAXRequest()) {
Expand Down
2 changes: 1 addition & 1 deletion redaxo/src/core/layout/top.php
Expand Up @@ -4,7 +4,7 @@
* Layout Kopf des Backends.
*/

$curPage = rex_be_controller::getCurrentPageObject();
$curPage = rex_be_controller::requireCurrentPageObject();
$user = rex::getUser();

if (rex_request::isPJAXRequest()) {
Expand Down

0 comments on commit 61a06ae

Please sign in to comment.