Skip to content

Commit

Permalink
Support namespaced classes for REDAXO 6
Browse files Browse the repository at this point in the history
  • Loading branch information
gharlan committed May 19, 2024
1 parent a9038eb commit 4b3f6ec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<UndefinedClass>
<errorLevel type="suppress">
<referencedClass name="Redaxo\Core\Http\Request" />
<referencedClass name="Redaxo\Core\Util\Type" />
</errorLevel>
</UndefinedClass>
</issueHandlers>
</psalm>
6 changes: 4 additions & 2 deletions src/Provider/RexTypeReturnProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
use Psalm\Type\Atomic\TNull;
use Psalm\Type\Atomic\TString;
use Psalm\Type\Union;
use Redaxo\Core\Http\Request;
use Redaxo\Core\Util\Type as RedaxoType;
use rex_request;
use rex_type;

Expand All @@ -33,7 +35,7 @@ final class RexTypeReturnProvider implements MethodReturnTypeProviderInterface,
{
public static function getClassLikeNames(): array
{
return [rex_type::class, rex_request::class];
return [rex_type::class, rex_request::class, RedaxoType::class, Request::class];
}

public static function getFunctionIds(): array
Expand All @@ -43,7 +45,7 @@ public static function getFunctionIds(): array

public static function getMethodReturnType(MethodReturnTypeProviderEvent $event): ?Union
{
if (rex_type::class === $event->getFqClasslikeName()) {
if (in_array($event->getFqClasslikeName(), [rex_type::class, RedaxoType::class], true)) {
if ('cast' === $event->getMethodNameLowercase()) {
return self::resolveType($event->getCallArgs()[1]->value);
}
Expand Down

0 comments on commit 4b3f6ec

Please sign in to comment.