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

Add dynamic return type for stripslashes_from_strings_only #232

Merged
merged 1 commit into from
Sep 26, 2024

Conversation

IanDelMar
Copy link
Contributor

This PR also adds a class, Faker. This is a helper class for tests to "fake" types. Instead of $string_ = (string)$_GET['string'], one can simply use Faker::type('string'). This is particularly useful for types that cannot be cast. For example:

/** @var numeric-string $numericString */
$numericString = $_GET['numericString'];

can be simplified to Faker::type('numeric-string') as well. @szepeviktor, if you dislike this idea, I’ll revert to the traditional method. Otherwise, I would update all the other tests to use this class. Also, I’m flexible regarding the class name or method names. If there are other preferences, we can rename them.

If we exclude the file from PHPStan analysis, we could even omit the method statements, as the type faking is handled through the docBlock. A new type can be introduced via the @phpstan-type Types.

@szepeviktor
Copy link
Member

Viktor ❤️ Faker

@szepeviktor szepeviktor merged commit 19596c3 into php-stubs:master Sep 26, 2024
5 checks passed
@IanDelMar IanDelMar deleted the stripslashes branch September 26, 2024 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants