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 stubs for ext-random (PHP 8.2) #8633

Closed
wants to merge 31 commits into from
Closed

Conversation

alies-dev
Copy link
Contributor

@alies-dev alies-dev commented Oct 30, 2022

First, simple version of functionality introduced or moved to ext-random.

I'm new to make this sort of changes to Psalm and open for any suggestions (but prefer to spit changes into few PRs if it's possible).

At the first iteration it's almost a cope of https://github.com/php/php-src/blob/master/ext/random/random.stub.php

Greg Hargreaves and others added 15 commits October 17, 2022 00:33
…rrent`, `end` and `reset`

Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
…s not return `null`

Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
Enhance type detection for internal php functions `key`, `current`, `end` and `reset`
…required-param-mismatch-missing-error

ensure callbacks have the required number of params

define('MT_RAND_PHP', 1);

namespace {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these functions and consts from above are existing ones (in PHP 8.1 and older) and moved to ext-random. Not sure what to do with stubs in this case

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need those stubbed at all? Callmap should be enough for those. I skimmed the RFC, what I understood is that everything is in an extension but the extension is always installed and can't be disabled so it's basically part of the core.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@orklah
this is a good question. ext-random should be a part of the code, but you can potentially recompile PHP without it (as far as I understand it in case of this ext). What do you need in such cases - just add to the Callmap?


public function getBytes(int $length): string {}

public function shuffleArray(array $array): array {}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to add more specific array info later as a separate PR (if it's possible)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine by me :)

@orklah
Copy link
Collaborator

orklah commented Oct 31, 2022

Thanks for this!

However, we kinda revamped our handling of extensions for Psalm 5. Would you mind targeting the master branch for this? It would be easier to merge later

@alies-dev alies-dev changed the base branch from 4.x to master October 31, 2022 18:52
@alies-dev
Copy link
Contributor Author

@orklah
Oops. it seems like I produced some changed my solving conflicts after changing base branch. I'll take a loom to this PR in few days to fix it. Thanks for the review!

@alies-dev alies-dev closed this Nov 2, 2022
@alies-dev alies-dev deleted the ext-random branch November 2, 2022 13:09
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.

None yet

8 participants