Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Pass by reference needed 15 Jun 2016 06:06 #14066

  • vlemos
  • vlemos's Avatar Topic Author
  • Away
  • Elite Member
  • Elite Member
  • Posts: 295
  • Thank you received: 41
$item was passed in by reference; should it not be passed by reference here as well?
public function populateObjects(&$item)
	{
		if (!empty($item->params) && is_string($item->params))
		{
			$registry = new JRegistry;
			$registry->loadString($item->params);
			$item->params = $registry->toObject();
		}
	
		parent::populateObjects($item);
	}
parent::populateObjects(&$item);

Please Log in or Create an account to join the conversation.

Pass by reference needed 15 Jun 2016 08:20 #14069

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
If you do that, PHP5 will throw a big error.

No, it is deprecated and finished this this when you use the '&' in the call. Only for arrays, and only for declarations of the parameters of the function.
All objects are pointer, so only simple vars and arrays need that. but only in the parameters declaration.

Even here in our case, I am not sure if it is required in the declaration. It is just a coding style for the coder to remember it is a OUTPUT parameter.
But when $item is an object, you can be sure it will be working even without '&' because it is systematically a pointer.
Coding is now a piece of cake
The following user(s) said Thank You: vlemos

Please Log in or Create an account to join the conversation.

Last edit: by admin.
  • Page:
  • 1
Time to create page: 0.185 seconds

Amazing Tool !
And only tool I know that allows complete Scaffolding in terms of component creation. It really saves loads of time (actually much more than that). Simple architecture enables quick and painless changes at any time. Code is clean and consintent. It's just... what's the word... neat! :) Great work! You should definetely try this one!

pi_wo (JED)
         

Get Started