1

I have a bunch of PHP 5.6 code that I would like to get up to 7.2. My biggest concern was the change that causes an error when you call a function without enough parameters. Previously, this was a warning. This is the change I know for a fact affects me, but others may as well. So what I did is I put together a small sample file and started opening it in various IDEs to see if any of them would tell me that it is not valid 7.2. So far I am 0 for 3.

Apparently this is a run time error, so simply running the file or running it with -l doesn't work. So how can I make sure my code is acceptable for PHP 7.2 without manually going through every file?

9
  • 3
    1. Install php 7 in a test environment (e.g. your local computer). 2. Test your code using that version. 3. Fix any problems until everything works. Commented Oct 24, 2018 at 21:43
  • The problem is by the time I finish that, PHP 200 will be released. Commented Oct 24, 2018 at 21:45
  • 2
    Don't you have unit tests? If not, then it's a good time to add them Commented Oct 25, 2018 at 1:25
  • I guess I wasn't clear enough. There is too much code to simply add unit tests. Support for php 5.6 ends in about a month. I cannot add unit tests to 15 year's worth of code in a month. Commented Oct 25, 2018 at 14:11
  • 1
    I guess I wasn't clear enough. There is too much code to simply add unit tests. Support for php 5.6 ends in about a month. I cannot add unit tests to 15 year's worth of code in a month. time for the company to pay the technical debt. Commented Oct 30, 2018 at 17:48

1 Answer 1

4

Sorry about all the down voters who didn't bother leaving a reason why. I was in your EXACT situation, and here is what I did:

I used a static code analysis tool. I tried a few, but the first one that actually worked how I wanted to was Phan. Installation was a pain and the documentation isn't the best, but once you figure out the syntax, it's very useful.

  1. Create a list of php files you want to validate.

    cd C:\SomeDir dir /s /b *.php > C:\phpfiles.txt

  2. Run phan with that list as an argument.

    vendor\bin\phan -f C:\phpfiles.txt > C:\output.txt

  3. If you only want certain results, for example if you only want PhanParamTooFew results, use findstr:

    findstr /c:"PhanParamTooFew " C:\output.txt > C:\filteredoutput.txt

There are config settings to do that third bit, but I couldn't get it to work.

2
  • Did you just answer your own question thinking it was asked by someone else? 👀😂 Commented Oct 30, 2018 at 19:09
  • 2
    Haha the "exact" was capital for a reason. I continued seeking answers after posting and this is what I came up with. I hope to help future travelers. Commented Oct 30, 2018 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.