Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

removed "by reference" parameter (object are always passed by reference) #13

Merged
merged 1 commit into from

2 participants

@xavierbriand

No description provided.

@chanmix51 chanmix51 merged commit 86acb15 into chanmix51:master
@chanmix51
Owner

Ah ... it seemed so obvious I did not launch test suit but I should have had. Objects are passed by reference but the & sign tracks the variable AS reference not what the data DOES reference.

<?php

class A {
  public $plop;
 }

 function checkA(A $instance) 
 {
     if ($instance->plop !== false) {
         $instance = new A();
     }

     $instance->plop = 1000;
 }

 $a = new A();
 $a->plop = true;

 checkA($a);

 var_dump($a);

Test the checkA function with and without & they do not have the same effect :p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  Pomm/Object/BaseObjectMap.php
View
2  Pomm/Object/BaseObjectMap.php
@@ -382,7 +382,7 @@ public function deleteByPk(Array $pk)
* @param BaseObject $object
* @access public
*/
- public function saveOne(BaseObject &$object)
+ public function saveOne(BaseObject $object)
{
$this->checkObject($object, sprintf('"%s" class does not know how to save "%s" objects.', get_class($this), get_class($object)));
Something went wrong with that request. Please try again.