Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support rex superglobals array types #556

Open
staabm opened this issue Aug 7, 2023 · 2 comments
Open

Support rex superglobals array types #556

staabm opened this issue Aug 7, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@staabm
Copy link
Member

staabm commented Aug 7, 2023

$form = rex_post('form', 'array[string]', []); should be detected as array<string> etc.

@gharlan
Copy link
Member

gharlan commented Aug 7, 2023

array[string] scheint mir unterstützt zu werden:

if (preg_match('/^array\[(.+)\]$/', $vartype, $match) === 1) {
$valueType = $this->resolveTypeFromString($match[1]);
if ($valueType === null) {
throw new ShouldNotHappenException();
}
return new ArrayType(
new MixedType(),
$valueType
);
}

Was mir aber zu fehlen scheint (nicht getestet), sind Array-Shapes, die in rex so notiert werden:

$form = rex_post('form', [
    ['foo', 'int', 1],
    ['kitchen', 'array[string]'],
]);

Für das psalm-Plugin habe ich es hier umgesetzt (keine Ahnung ob hilfreich): https://github.com/redaxo/psalm-plugin/blob/main/src/Provider/RexTypeReturnProvider.php#L138

@staabm staabm added the enhancement New feature or request label Aug 23, 2023
@gharlan
Copy link
Member

gharlan commented Mar 13, 2024

In 5.17 kam noch eine weitere Array-Variante hinzu: redaxo/redaxo#6031

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants