Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

FixWeakMap object reference offset causingTypeError#8995

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
arnaud-lb merged 2 commits intophp:PHP-8.0fromNevay:fix/weakmap-object-reference
Jul 15, 2022
Merged

FixWeakMap object reference offset causingTypeError#8995

arnaud-lb merged 2 commits intophp:PHP-8.0fromNevay:fix/weakmap-object-reference
Jul 15, 2022

Conversation

Nevay
Copy link
Contributor

FixTypeError when using object reference asWeakMap offset.

$a =newstdClass();$b = &$a;$map =newWeakMap();$map[$a] =true;
Fatal error: Uncaught TypeError: WeakMap key must be an object

Copy link
Member

@cmb69cmb69 left a comment

Choose a reason for hiding this comment

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

Thank you! That looks about right, although I don't quite understand the use case (why referencing an object?)

@Nevay
Copy link
ContributorAuthor

I stumbled across this while using a by-ref parameter which is stored in aWeakMap afterwards (ref-1,ref-2):

functiondoStuff(?object &$obj =null):void {$obj =newstdClass();}doStuff($obj);$map =newWeakMap();$map[$obj] =null;

@cmb69
Copy link
Member

Ah, yeah, that makes sense (although I wish PHP had out parameters for such purposes).

@arnaud-lbarnaud-lb merged commitede92a8 intophp:PHP-8.0Jul 15, 2022
@arnaud-lb
Copy link
Member

Thank you !

arnaud-lb added a commit that referenced this pull requestJul 15, 2022
* PHP-8.1:  [ci skip] NEWS  Fix `WeakMap` object reference offset causing `TypeError` (#8995)
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@iluuu1994iluuu1994iluuu1994 left review comments

@cmb69cmb69cmb69 approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@Nevay@cmb69@arnaud-lb@iluuu1994

[8]ページ先頭

©2009-2025 Movatter.jp