Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions .tools/phpstan/baseline/missingType.iterableValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,6 @@
'count' => 1,
'path' => __DIR__ . '/../../../src/Content/StructureContext.php',
];
$ignoreErrors[] = [
'rawMessage' => 'Method Redaxo\\Core\\Content\\StructureElement::__construct() has parameter $params with no value type specified in iterable type array.',
'count' => 1,
'path' => __DIR__ . '/../../../src/Content/StructureElement.php',
];
$ignoreErrors[] = [
'rawMessage' => 'Method Redaxo\\Core\\Content\\StructureElement::_hasValue() has parameter $prefixes with no value type specified in iterable type array.',
'count' => 1,
'path' => __DIR__ . '/../../../src/Content/StructureElement.php',
];
$ignoreErrors[] = [
'rawMessage' => 'Method Redaxo\\Core\\Content\\StructureElement::getUrl() has parameter $params with no value type specified in iterable type array.',
'count' => 1,
Expand Down Expand Up @@ -678,31 +668,6 @@
'count' => 1,
'path' => __DIR__ . '/../../../src/View/View.php',
];
$ignoreErrors[] = [
'rawMessage' => 'Method Redaxo\\Core\\Content\\Category@anonymous/tests/Content/CategoryTest.php:175::__construct() has parameter $params with no value type specified in iterable type array.',
'count' => 1,
'path' => __DIR__ . '/../../../tests/Content/CategoryTest.php',
];
$ignoreErrors[] = [
'rawMessage' => 'Method Redaxo\\Core\\Tests\\Content\\CategoryTest::createCategories() has parameter $lev1Params with no value type specified in iterable type array.',
'count' => 1,
'path' => __DIR__ . '/../../../tests/Content/CategoryTest.php',
];
$ignoreErrors[] = [
'rawMessage' => 'Method Redaxo\\Core\\Tests\\Content\\CategoryTest::createCategories() has parameter $lev2Params with no value type specified in iterable type array.',
'count' => 1,
'path' => __DIR__ . '/../../../tests/Content/CategoryTest.php',
];
$ignoreErrors[] = [
'rawMessage' => 'Method Redaxo\\Core\\Tests\\Content\\CategoryTest::createCategories() has parameter $lev3Params with no value type specified in iterable type array.',
'count' => 1,
'path' => __DIR__ . '/../../../tests/Content/CategoryTest.php',
];
$ignoreErrors[] = [
'rawMessage' => 'Method Redaxo\\Core\\Tests\\Content\\CategoryTest::createCategory() has parameter $params with no value type specified in iterable type array.',
'count' => 1,
'path' => __DIR__ . '/../../../tests/Content/CategoryTest.php',
];
$ignoreErrors[] = [
'rawMessage' => 'Method Redaxo\\Core\\Tests\\MediaPool\\MediaPoolTest::testIsAllowedExtension() has parameter $args with no value type specified in iterable type array.',
'count' => 1,
Expand Down
15 changes: 0 additions & 15 deletions .tools/phpstan/baseline/missingType.parameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,6 @@
'count' => 1,
'path' => __DIR__ . '/../../../src/Content/Linkmap/CategoryTree.php',
];
$ignoreErrors[] = [
'rawMessage' => 'Method Redaxo\\Core\\Content\\Linkmap\\CategoryTreeRenderer::formatLi() has parameter $currentCategoryId with no type specified.',
'count' => 1,
'path' => __DIR__ . '/../../../src/Content/Linkmap/CategoryTreeRenderer.php',
];
$ignoreErrors[] = [
'rawMessage' => 'Method Redaxo\\Core\\Content\\Linkmap\\CategoryTreeRenderer::formatLi() has parameter $liAttr with no type specified.',
'count' => 1,
'path' => __DIR__ . '/../../../src/Content/Linkmap/CategoryTreeRenderer.php',
];
$ignoreErrors[] = [
'rawMessage' => 'Method Redaxo\\Core\\Content\\Linkmap\\CategoryTreeRenderer::formatLi() has parameter $linkAttr with no type specified.',
'count' => 1,
'path' => __DIR__ . '/../../../src/Content/Linkmap/CategoryTreeRenderer.php',
];
$ignoreErrors[] = [
'rawMessage' => 'Method Redaxo\\Core\\Content\\Linkmap\\CategoryTreeRenderer::getTree() has parameter $categoryId with no type specified.',
'count' => 1,
Expand Down
49 changes: 0 additions & 49 deletions .tools/psalm/baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1240,8 +1240,6 @@
<code><![CDATA[escape($hiddenFields)]]></code>
</MixedOperand>
<PossiblyNullArgument>
<code><![CDATA[$article->getValue('parent_id')]]></code>
<code><![CDATA[$article->getValue('parent_id')]]></code>
<code><![CDATA[Request::request('clang_a', 'int', null)]]></code>
<code><![CDATA[Request::request('clang_b', 'int', null)]]></code>
</PossiblyNullArgument>
Expand All @@ -1256,7 +1254,6 @@
<code><![CDATA[escape($article->getValue('updateuser'))]]></code>
</PossiblyNullOperand>
<PossiblyNullReference>
<code><![CDATA[getName]]></code>
<code><![CDATA[getValue]]></code>
</PossiblyNullReference>
</file>
Expand All @@ -1275,7 +1272,6 @@
</PossiblyInvalidArrayAccess>
<PossiblyNullReference>
<code><![CDATA[addSubpage]]></code>
<code><![CDATA[getCategoryId]]></code>
<code><![CDATA[getSubpages]]></code>
</PossiblyNullReference>
</file>
Expand Down Expand Up @@ -1832,9 +1828,6 @@
<code><![CDATA[$toSql->getValue('path')]]></code>
<code><![CDATA[$toSql->getValue('path')]]></code>
</PossiblyNullOperand>
<PossiblyNullReference>
<code><![CDATA[getCategoryId]]></code>
</PossiblyNullReference>
<PossiblyUndefinedArrayOffset>
<code><![CDATA[$data['template']]]></code>
<code><![CDATA[$data['template']]]></code>
Expand Down Expand Up @@ -1949,7 +1942,6 @@
<code><![CDATA[$value]]></code>
</MixedAssignment>
<PossiblyNullArgument>
<code><![CDATA[$article]]></code>
<code><![CDATA[$article]]></code>
<code><![CDATA[$articleId]]></code>
<code><![CDATA[$articleId]]></code>
Expand All @@ -1966,10 +1958,6 @@
<code><![CDATA[$CM->getValue('priority')]]></code>
<code><![CDATA[$CM->getValue('priority')]]></code>
</PossiblyNullOperand>
<PossiblyNullReference>
<code><![CDATA[getCategoryId]]></code>
<code><![CDATA[getId]]></code>
</PossiblyNullReference>
</file>
<file src="src/Content/Linkmap/ArticleListRenderer.php">
<MixedArgument>
Expand Down Expand Up @@ -1999,10 +1987,6 @@
<MixedArgument>
<code><![CDATA[$categoryId]]></code>
</MixedArgument>
<MixedOperand>
<code><![CDATA[$liAttr]]></code>
<code><![CDATA[$linkAttr]]></code>
</MixedOperand>
</file>
<file src="src/Content/ModulePermission.php">
<MixedReturnTypeCoercion>
Expand All @@ -2024,18 +2008,6 @@
<code><![CDATA[$params['category_id']]]></code>
</MixedAssignment>
</file>
<file src="src/Content/StructureElement.php">
<MixedAssignment>
<code><![CDATA[$prefix]]></code>
<code><![CDATA[$value]]></code>
</MixedAssignment>
<MixedOperand>
<code><![CDATA[$prefix]]></code>
</MixedOperand>
<MixedReturnStatement>
<code><![CDATA[$this->$val]]></code>
</MixedReturnStatement>
</file>
<file src="src/Content/Template.php">
<MixedReturnStatement>
<code><![CDATA[array_find($this->getContentSections(), static fn (ContentSection $s) => $s->id === $id)]]></code>
Expand Down Expand Up @@ -3474,10 +3446,6 @@
<MixedMethodCall>
<code><![CDATA[setValue]]></code>
</MixedMethodCall>
<PossiblyNullReference>
<code><![CDATA[getCategoryId]]></code>
<code><![CDATA[getPathAsArray]]></code>
</PossiblyNullReference>
</file>
<file src="src/MetaInfo/Handler/CategoryHandler.php">
<MixedArgument>
Expand Down Expand Up @@ -3508,9 +3476,6 @@
<code><![CDATA[$ep->getSubject()]]></code>
<code><![CDATA[$ep->getSubject()]]></code>
</MixedReturnStatement>
<PossiblyNullReference>
<code><![CDATA[getPathAsArray]]></code>
</PossiblyNullReference>
</file>
<file src="src/MetaInfo/Handler/LanguageHandler.php">
<ImplementedReturnTypeMismatch>
Expand Down Expand Up @@ -3615,9 +3580,6 @@
<code><![CDATA[$name]]></code>
<code><![CDATA[$value]]></code>
</MixedOperand>
<PossiblyNullReference>
<code><![CDATA[getId]]></code>
</PossiblyNullReference>
</file>
<file src="src/RexVar/LinkVar.php">
<MixedArgument>
Expand All @@ -3627,9 +3589,6 @@
<code><![CDATA[$name]]></code>
<code><![CDATA[$value]]></code>
</MixedOperand>
<PossiblyNullReference>
<code><![CDATA[getId]]></code>
</PossiblyNullReference>
</file>
<file src="src/RexVar/MediaListVar.php">
<MixedArgument>
Expand Down Expand Up @@ -4101,13 +4060,8 @@
<MixedMethodCall>
<code><![CDATA[$method]]></code>
</MixedMethodCall>
<PossiblyNullArgument>
<code><![CDATA[$cat]]></code>
</PossiblyNullArgument>
<PossiblyNullReference>
<code><![CDATA[getChildren]]></code>
<code><![CDATA[getName]]></code>
<code><![CDATA[getName]]></code>
</PossiblyNullReference>
</file>
<file src="src/View/View.php">
Expand Down Expand Up @@ -4180,9 +4134,6 @@
<MixedArgumentTypeCoercion>
<code><![CDATA[$callback]]></code>
</MixedArgumentTypeCoercion>
<MixedAssignment>
<code><![CDATA[$value]]></code>
</MixedAssignment>
</file>
<file src="tests/Database/SelectTest.php">
<MixedArrayAccess>
Expand Down
4 changes: 2 additions & 2 deletions pages/structure/content.metainfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
$articleIcon = $articleStatusTypes[$status][2];
$structureContext = new StructureContext([
'article_id' => Request::request('article_id', 'int'),
'category_id' => $article->getCategoryId(),
'category_id' => $article->categoryId,
'clang_id' => Request::request('clang', 'int'),
]);

Expand Down Expand Up @@ -114,7 +114,7 @@
$formElements = [];
$formElements[] = [
'label' => '<label for="rex-id-meta-article-name">' . I18n::msg('header_article_name') . '</label>',
'field' => '<input class="form-control" type="text" id="rex-id-meta-article-name" name="meta_article_name" value="' . htmlspecialchars(Article::get($articleId, $clang)->getName()) . '" />',
'field' => '<input class="form-control" type="text" id="rex-id-meta-article-name" name="meta_article_name" value="' . escape(Article::require($articleId, $clang)->name) . '" />',
];
$fragment = new Fragment();
$fragment->setVar('elements', $formElements, false);
Expand Down
8 changes: 4 additions & 4 deletions pages/structure/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
}

// ----- Artikel wurde gefunden - Kategorie holen
$OOArt = Article::get($articleId, $clang);
$categoryId = $OOArt->getCategoryId();
$OOArt = Article::require($articleId, $clang);
$categoryId = $OOArt->categoryId;

// ----- Request Parameter
$subpage = Controller::getCurrentPagePart(2);
Expand All @@ -86,13 +86,13 @@
]);

// ----- Titel anzeigen
echo View::title(I18n::msg('content') . ': ' . escape($OOArt->getName()), '');
echo View::title(I18n::msg('content') . ': ' . escape($OOArt->name), '');

// ----- Languages
echo View::clangSwitchAsButtons($context);

// ----- category pfad und rechte
echo View::structureBreadcrumb($categoryId, $articleId, $clang);
echo View::structureBreadcrumb($categoryId ?? 0, $articleId, $clang);

// ----- EXTENSION POINT
echo Extension::registerPoint(new ExtensionPoint('STRUCTURE_CONTENT_HEADER', '', [
Expand Down
2 changes: 1 addition & 1 deletion pages/structure/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
$catName = I18n::msg('root_level');
$category = Category::get($structureContext->getCategoryId(), $structureContext->getClangId());
if ($category) {
$catName = $category->getName();
$catName = $category->name;
}

$addCategory = '';
Expand Down
6 changes: 3 additions & 3 deletions pages/structure/linkmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ function insertLink(link,name){
if ($category) {
foreach ($category->getParentTree() as $parent) {
$n = [];
$n['title'] = str_replace(' ', '&nbsp;', escape($parent->getName()));
$n['href'] = $context->getUrl(['category_id' => $parent->getId()]);
$n['title'] = str_replace(' ', '&nbsp;', escape($parent->name));
$n['href'] = $context->getUrl(['category_id' => $parent->id]);
$navigation[] = $n;
}
}
Expand All @@ -137,7 +137,7 @@ function insertLink(link,name){
$fragment->setVar('content', $panel, false);
$content[] = $fragment->parse('core/page/section.php');

$articleList = new ArticleList($context);
$articleList = new ArticleList();
$panel = $articleList->getList($categoryId);

$fragment = new Fragment();
Expand Down
16 changes: 16 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,10 @@
new MethodCallToPropertyFetch(Cronjob\CronjobExecutor::class, 'getMessage', 'message'),
new MethodCallToPropertyFetch(Cronjob\CronjobExecutor::class, 'hasMessage', 'message'),

new MethodCallToPropertyFetch(Content\Article::class, 'getCategoryId', 'categoryId'), // changed from int to ?int
new MethodCallToPropertyFetch(Content\Article::class, 'getTemplateKey', 'templateKey'),
new MethodCallToPropertyFetch(Content\Article::class, 'hasTemplate', 'templateKey'), // changed from bool to ?string, callers using the bool need manual adjustment

new MethodCallToPropertyFetch(Content\ArticleSlice::class, 'getId', 'id'),
new MethodCallToPropertyFetch(Content\ArticleSlice::class, 'getArticleId', 'articleId'),
new MethodCallToPropertyFetch(Content\ArticleSlice::class, 'getClang', 'clangId'),
Expand All @@ -548,6 +552,18 @@
new MethodCallToPropertyFetch(Content\ContentSection::class, 'getId', 'id'),
new MethodCallToPropertyFetch(Content\ContentSection::class, 'getName', 'name'),

new MethodCallToPropertyFetch(Content\StructureElement::class, 'getId', 'id'),
new MethodCallToPropertyFetch(Content\StructureElement::class, 'getParentId', 'parentId'),
new MethodCallToPropertyFetch(Content\StructureElement::class, 'getClangId', 'clangId'),
new MethodCallToPropertyFetch(Content\StructureElement::class, 'getName', 'name'),
new MethodCallToPropertyFetch(Content\StructureElement::class, 'getPriority', 'priority'),
new MethodCallToPropertyFetch(Content\StructureElement::class, 'getPath', 'path'), // changed from string to array, callers using the string need manual adjustment
new MethodCallToPropertyFetch(Content\StructureElement::class, 'getPathAsArray', 'path'),
new MethodCallToPropertyFetch(Content\StructureElement::class, 'getCreateDate', 'createDate'),
new MethodCallToPropertyFetch(Content\StructureElement::class, 'getUpdateDate', 'updateDate'),
new MethodCallToPropertyFetch(Content\StructureElement::class, 'getCreateUser', 'createUser'),
new MethodCallToPropertyFetch(Content\StructureElement::class, 'getUpdateUser', 'updateUser'),

new MethodCallToPropertyFetch(Language\Language::class, 'getId', 'id'),
new MethodCallToPropertyFetch(Language\Language::class, 'getCode', 'code'),
new MethodCallToPropertyFetch(Language\Language::class, 'getName', 'name'),
Expand Down
1 change: 0 additions & 1 deletion src/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public static function delete(): string

StructureElement::clearInstancePool();
StructureElement::clearInstanceListPool();
StructureElement::resetClassVars();

if (function_exists('opcache_reset')) {
opcache_reset();
Expand Down
2 changes: 1 addition & 1 deletion src/Content/ApiFunction/ArticleCopy.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function execute(): Result
}

if (
!$user->getComplexPerm('structure')->hasCategoryPerm($article->getCategoryId())
!$user->getComplexPerm('structure')->hasCategoryPerm($article->categoryId)
|| !$user->getComplexPerm('structure')->hasCategoryPerm($categoryCopyIdNew)
) {
throw new ApiFunctionException(I18n::msg('no_rights_to_this_function'));
Expand Down
2 changes: 1 addition & 1 deletion src/Content/ApiFunction/ArticleDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function execute(): Result
throw new ApiFunctionException('Unable to find article with id "' . $articleId . '"!');
}

if (!$user->getComplexPerm('structure')->hasCategoryPerm($article->getCategoryId())) {
if (!$user->getComplexPerm('structure')->hasCategoryPerm($article->categoryId)) {
throw new ApiFunctionException(I18n::msg('no_rights_to_this_function'));
}

Expand Down
2 changes: 1 addition & 1 deletion src/Content/ApiFunction/ArticleEdit.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function execute(): Result

if (
!$user->getComplexPerm('clang')->hasPerm($clang)
|| !$user->getComplexPerm('structure')->hasCategoryPerm($article->getCategoryId())
|| !$user->getComplexPerm('structure')->hasCategoryPerm($article->categoryId)
) {
throw new ApiFunctionException(I18n::msg('no_rights_to_this_function'));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Content/ApiFunction/ArticleMove.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function execute(): Result
throw new ApiFunctionException('Unable to find category with id "' . $categoryIdNew . '"!');
}

$categoryId = $article->getCategoryId();
$categoryId = $article->categoryId ?? 0;

if (
!$user->getComplexPerm('structure')->hasCategoryPerm($categoryId)
Expand Down
2 changes: 1 addition & 1 deletion src/Content/ApiFunction/ArticleSliceMove.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function execute(): Result

if (
!$user->getComplexPerm('clang')->hasPerm($clang)
|| !$user->getComplexPerm('structure')->hasCategoryPerm($article->getCategoryId())
|| !$user->getComplexPerm('structure')->hasCategoryPerm($article->categoryId)
|| !$user->getComplexPerm('modules')->hasPerm($moduleKey)
) {
throw new ApiFunctionException(I18n::msg('no_rights_to_this_function'));
Expand Down
2 changes: 1 addition & 1 deletion src/Content/ApiFunction/ArticleSliceStatusChange.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function execute(): Result

if (
!$user->getComplexPerm('clang')->hasPerm($clang)
|| !$user->getComplexPerm('structure')->hasCategoryPerm($article->getCategoryId())
|| !$user->getComplexPerm('structure')->hasCategoryPerm($article->categoryId)
) {
throw new ApiFunctionException(I18n::msg('no_rights_to_this_function'));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Content/ApiFunction/ArticleStatusChange.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function execute(): Result

if (
!$user->getComplexPerm('clang')->hasPerm($clang)
|| !$user->getComplexPerm('structure')->hasCategoryPerm($article->getCategoryId())
|| !$user->getComplexPerm('structure')->hasCategoryPerm($article->categoryId)
) {
throw new ApiFunctionException(I18n::msg('no_rights_to_this_function'));
}
Expand Down
Loading
Loading