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
  • Offline
  • 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.087 seconds

Hi All just wanted to add one more "thank you" voice to all those who discovered the value of this amazing application. The website I was working on went to production few days ago and I do not want to even try to imagine what would it take to build it without j-cook. So - endless thanks keep it running and evolving I believe it deserves to be the core tool for any joomla application! Thanks!
Michael (bmk028 - Forum)  

Get Started