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

=& in footnotes #362

Open
tacman opened this issue Nov 8, 2021 · 1 comment
Open

=& in footnotes #362

tacman opened this issue Nov 8, 2021 · 1 comment

Comments

@tacman
Copy link
Contributor

tacman commented Nov 8, 2021

I've been running phpstan level 6, and see this code

		if (isset($this->footnotes[$node_id])) {
			$num =& $this->footnotes_numbers[$node_id];
			if (!isset($num)) {

I'm wondering what the purpose of =& is. Also, I think we can simply say

if (empty($num))

since $num is always set and it can't be null. But I'm not sure.

@michelf
Copy link
Owner

michelf commented Nov 8, 2021

It's supposed to create a reference to $this->footnotes_number[$note_id] so that if you write to $num it'd also change the other place. So this other line is actually assigning to $this->footnote_number[$note_id], and the isset($num) is checking for the existence of $this->footnote_number[$note_id].

Note: In many places in the code I'm using =& simply as a way to avoid warnings about unset variables, but this is not one of those cases.

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

No branches or pull requests

2 participants