Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0
    • Fix Version/s: 2.0.0
    • Component/s: Code
    • Labels:
      None

      Description

      According to this:
      http://www.php.net/manual/en/language.oop5.references.php

      PHP treats variable passing like in Java now. This would mean that only object identifiers are passed around, not the object copied. Having that beeing that, we can remove the incosistent & references from the code.

        Activity

        Hide
        Knut Urdalen added a comment -

        Just a note from me: Normally it's fine to remove all references, and if working with object handles it's not a problem. However if you potentially can have large amount of data as plain PHP arrays, you mostly do better by using "Pass by Reference" to not copy the whole data structure around and consume less memory. I think we should be aware of these things in a lightweight logging framework.

        For the record:

        Show
        Knut Urdalen added a comment - Just a note from me: Normally it's fine to remove all references, and if working with object handles it's not a problem. However if you potentially can have large amount of data as plain PHP arrays, you mostly do better by using "Pass by Reference" to not copy the whole data structure around and consume less memory. I think we should be aware of these things in a lightweight logging framework. For the record: References Explained: http://www.php.net/manual/en/language.references.php Passing by Reference: http://www.php.net/manual/en/language.references.pass.php
        Hide
        Christian Grobmeier added a comment -

        As of PHP5, not the whole object structure is copied when using an object as method param.

        "As of PHP5, an object variable doesn't contain the object itself as value anymore. It only contains an object identifier which allows object accessors to find the actual object"

        Its just creating a new object identifier (without recreating the object) of you pass an object in a method.

        This is quite the same way as java does it. Considering that "passing by reference" in the PHP4 way isn't brought into PHP as standard behaviour but more as an add on and considering that I got sometimes bus errors with different PHP compilations I think its worth not to use references any more for objects.

        As for the array passing I agree, this looks like still like the best solution since arrays are not objects. But for objects, I think removing references are fine.

        Looking in Log4PHP I cannot find much array-reference passings. Speaking of bus errors, they occured only with objects, not on arrays.

        Thanks for having a look at this too!

        Show
        Christian Grobmeier added a comment - As of PHP5, not the whole object structure is copied when using an object as method param. "As of PHP5, an object variable doesn't contain the object itself as value anymore. It only contains an object identifier which allows object accessors to find the actual object" Its just creating a new object identifier (without recreating the object) of you pass an object in a method. This is quite the same way as java does it. Considering that "passing by reference" in the PHP4 way isn't brought into PHP as standard behaviour but more as an add on and considering that I got sometimes bus errors with different PHP compilations I think its worth not to use references any more for objects. As for the array passing I agree, this looks like still like the best solution since arrays are not objects. But for objects, I think removing references are fine. Looking in Log4PHP I cannot find much array-reference passings. Speaking of bus errors, they occured only with objects, not on arrays. Thanks for having a look at this too!
        Hide
        Christian Grobmeier added a comment -

        References removed.
        For the record: Strings are not treated as objects. References for string(buffer) passing are necessary until the methods are refactored.

        Show
        Christian Grobmeier added a comment - References removed. For the record: Strings are not treated as objects. References for string(buffer) passing are necessary until the methods are refactored.

          People

          • Assignee:
            Unassigned
            Reporter:
            Christian Grobmeier
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development