php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #68530 Which parameters to send to a function
Submitted: 2014-12-01 01:08 UTC Modified: 2014-12-01 20:29 UTC
From: ignasimg at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ignasimg at gmail dot com
New email:
PHP Version: OS:

 

 [2014-12-01 01:08 UTC] ignasimg at gmail dot com
Description:
------------
Recently I did a wrapper for JSON_encode and JSON_decode, to deal with non UTF8 strings aswell, I tested them and didn't had any issue.

The problem came when I uploaded the code to my production server, which doesn't have the same php version as my development computer.

both JSON_encode and JSON_decode have signatures that added new parameters quite recently, so my server was expecting those calls with 1/2 parameters and when it seen 3 it went WTF?


I needed that code asap so instead of upgrading my server to the most recent version I just deleted the noisy parameters from the code (I was not really using them, just to make the wrappers more convinient in the future)

But then it came to my mind, it could be of great use a function which given reference to a function can tell (at least) how many parameters it expects.

Or even better, named parameters. Would solve funny issues like:

JSON_encode defines options parameter in 5.3.0 and depth in 5.5.0 and
JSON_decode defines options parameter in 5.4.0 and depth in 5.3.0


Anyway just an idea : )


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-12-01 20:29 UTC] aharvey@php.net
-Status: Open +Status: Not a bug
 [2014-12-01 20:29 UTC] aharvey@php.net
You can get that information via reflection, and the documentation includes full change logs for each function detailing when parameters are added, in addition to those changes being noted in the migration guide for that version.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 15:00:02 2026 UTC