[RFC|Rejected] [API] API functions accept arrays as arguments

These RFCs were either rejected or have been replaced by an alternative proposal. They will not be included in phpBB.
User avatar
callumacrae
Former Team Member
Posts: 1046
Joined: Tue Apr 27, 2010 9:37 am
Location: England
Contact:

Re: [RFC] [API] API functions accept arrays as arguments

Post by callumacrae » Sun Jul 29, 2012 7:00 pm

includes/acp/acp_users.php, line 287:

Code: Select all

$result = user_ban(substr($action, 3), $ban, 0, 0, 0, $ban_reason, $ban_give_reason);
viewtopic.php, line 1096:

Code: Select all

get_user_rank($row['user_rank'], false, $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);
includes/mcp/mcp_forum.php, line 92:

Code: Select all

make_jumpbox($url . "&i=$id&action=$action&mode=$mode" . (($merge_select) ? $selected_ids : ''), $forum_id, false, 'm_', true);
includes/mcp/mcp_front.php, line 329:

Code: Select all

make_jumpbox(append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=forum_view'), 0, false, 'm_', true);
includes/functions.php, line 1083:

Code: Select all

$zone_trunc = truncate_string($zone, 50, 255, false, '...');
Could you tell me what any of them do without consulting the documentation? You don't have to look far to find code like this.
Made by developers, for developers!
My blog

User avatar
brunoais
Registered User
Posts: 964
Joined: Fri Dec 18, 2009 3:55 pm

Re: [RFC] [API] API functions accept arrays as arguments

Post by brunoais » Sun Jul 29, 2012 9:24 pm

callumacrae wrote: Could you tell me what any of them do without consulting the documentation?
Yes.

User avatar
naderman
Consultant
Posts: 1727
Joined: Sun Jan 11, 2004 2:11 am
Location: Karlsruhe, Germany
Contact:

Re: [RFC] [API] API functions accept arrays as arguments

Post by naderman » Sun Jul 29, 2012 10:11 pm

Get an IDE that reads these for you. They should be replaced with proper object oriented code anyway, which suffers less from this problem. I'm sorry but these are really not a reason to throw PHP's function parameter feature out the window. By doing this you lose any IDE support, you lose any possibility to automatically detect errors in passed parameters. You lost proper documentation, you lose built in type hinting. It's a bad idea, we won't be doing this.

Post Reply