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

[PHP] _SERVER var name #9924

Closed
filt3rek opened this issue Oct 19, 2020 · 5 comments
Closed

[PHP] _SERVER var name #9924

filt3rek opened this issue Oct 19, 2020 · 5 comments
Labels
bug platform-php Everything related to PHP

Comments

@filt3rek
Copy link
Contributor

filt3rek commented Oct 19, 2020

Hej !

I'm on this "bug" for several days now it drove me crazy...
I've named a local variable "_SERVER", haxe transpilled that to $_SERVER and it has "overriden" the php _SERVER variable...
I don't know maybe something should be done for something like that ?

@RealyUniqueName RealyUniqueName added the platform-php Everything related to PHP label Oct 19, 2020
@RealyUniqueName RealyUniqueName added this to the Design milestone Oct 19, 2020
@RealyUniqueName
Copy link
Member

It's a builtin global variable in PHP runtime.
Sure we can make compiler rename such variable names in the generated code, but I'm not sure if we should.
It's easy to workaround: just pick another name for your variable.

@filt3rek
Copy link
Contributor Author

Thanks Aleksandr for your reply !
Yes I've renamed my var but reported that for the future because other people can do the same stupid think I've done and get headacke...
I'm sure it occurs also with others built in global vars.
Anyway, thanks for your attention !

@RealyUniqueName
Copy link
Member

Another option is to emit a warning for such variable names.

@Aurel300
Copy link
Member

[...], but I'm not sure if we should.

Sure we should, how is this different from not generating console, window, etc on Javascript? The reserved variable is accessible via php.SuperGlobal._SERVER.

@RealyUniqueName
Copy link
Member

I agree.

@RealyUniqueName RealyUniqueName modified the milestones: Design, Hotfix Oct 19, 2020
@RealyUniqueName RealyUniqueName modified the milestones: Hotfix, Bugs Feb 10, 2021
Simn added a commit that referenced this issue Nov 30, 2023
* destroy

* update haxelib submodule

* submodule

* submodule ffs

* cppia

* remove echoServer

* remove more things

* more

* use patched utest for now

* remove one more

* try utest2

* fix test

* explicitly pass `null` to the `type` argument of `utest.Assert.raises()`

* [php] update test #9924 for compatibility with the latest utest

* [tests] type-hint Vfs.getContent

* fix Vfs.getContent one more time

* fix display tests

* switch to utest master

---------

Co-authored-by: Aleksandr Kuzmenko <alex@stablex.ru>
0b1kn00b pushed a commit to 0b1kn00b/haxe that referenced this issue Jan 25, 2024
* destroy

* update haxelib submodule

* submodule

* submodule ffs

* cppia

* remove echoServer

* remove more things

* more

* use patched utest for now

* remove one more

* try utest2

* fix test

* explicitly pass `null` to the `type` argument of `utest.Assert.raises()`

* [php] update test HaxeFoundation#9924 for compatibility with the latest utest

* [tests] type-hint Vfs.getContent

* fix Vfs.getContent one more time

* fix display tests

* switch to utest master

---------

Co-authored-by: Aleksandr Kuzmenko <alex@stablex.ru>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug platform-php Everything related to PHP
Projects
None yet
Development

No branches or pull requests

3 participants