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 sniffs for new and removed PHP constants #263

Closed
jrfnl opened this issue Oct 2, 2016 · 5 comments · Fixed by #526 or vfalies/php7compatibility#2
Closed

Add sniffs for new and removed PHP constants #263

jrfnl opened this issue Oct 2, 2016 · 5 comments · Fixed by #526 or vfalies/php7compatibility#2
Milestone

Comments

@jrfnl
Copy link
Member

jrfnl commented Oct 2, 2016

See title ;-)

@MarkMaldaba
Copy link
Contributor

What new and removed PHP constants? A list or link would be helpful!

@jrfnl
Copy link
Member Author

jrfnl commented Oct 3, 2016

PHP Changelog anyone ?

I haven't created the sniff yet, but have got an initial array with names and versions set up of over 200 new constants in PHP 5+.

For PHP 7.1: Ref: http://php.net/manual/en/migration71.constants.php

@MarkMaldaba
Copy link
Contributor

Ah - I see. This is a completely new Sniff. I thought it was for 7.1 specifically.

btw How are you working these out - trawling the change logs, or via some form of automated process?

I wonder if we could write some code to automatically extract this kind of thing from the tagged source of each release?

@jrfnl
Copy link
Member Author

jrfnl commented Oct 3, 2016

I thought it was for 7.1 specifically.

Ah, no. The issues I opened for 7.1 are prefixed as such. This is a generic new one ;-)

btw How are you working these out - trawling the change logs, or via some form of automated process?

For now manually going through changelogs (as I was going through them anyway).

Automating would be interesting, but might be more time-consuming just to build it vs manually updating for the next ten years or so.

@MarkMaldaba
Copy link
Contributor

MarkMaldaba commented Oct 3, 2016

Automating would be interesting, but might be more time-consuming just to build it vs manually updating for the next ten years or so.

Maybe... or maybe not.

The two ways I thought of are:

  1. Looking at the source. For example, the func_info_t array in zend_func_info.c. If you have a list of release tags (trivial) - and assuming that code hasn't moved around too much - you should be able to extract a full list of functions/constants/keywords, etc. for each PHP version pretty easily (right back to however far we want to go, including PHP4).
  2. Writing a little PHP script that uses built-in PHP features to list all functions/classes/etc. (e.g. using get_defined_functions() or Reflection) and then running it against all PHP releases. Probably most trivially done on Windows, which has pre-compiled binaries you can just unzip and throw code at.

It's something I've been thinking about but I don't have any time right now. I hope to look into it one day, but thought it worth mentioning in case it would save you work in the meantime.

(FWIW, I also wrote a script at one point that trawled the offline version of the PHP docs and extracted version information from that, though I don't know what happened to it (might see if I can dig it out...). That might be another approach. It might be interesting to compare the results these different tactics give, too - I wonder how correct the documentation/changelog actually is?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment