phpapachephp-7.3rector

What is the benefit of using getallheaders() instead of apache_request_headers()?


When using Rector as an aid in upgrading php versions from 7.2 to 7.3, one rule (RenameFunctionRector) changes all instances of apache_request_headers() to getallheaders().

After reading the documentation for both functions, it appears that getallheaders() is an alias and there's no difference between the two as far as I can see. Can anyone explain the reason why getallheaders() exists and if there's any benefit to implementing it?


Solution

  • apache_request_headers was flagged for possible deprecation in 7.4. Although that didn't happen, I think it was added to Rector just in case it did happen eventually.

    As for why it was flagged for deprecation, this thread talks about it, but basically that function's name implies it is Apache-specific, however there are other SAPIs besides that.