Doctrine Common
  1. Doctrine Common
  2. DCOM-194

Creating Proxy class failure for own __get method

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 2.4
    • Fix Version/s: 2.4
    • Component/s: None
    • Labels:
    • Environment:
      using Nette framework ( http://nette.org ), PHP 5.4

      Description

      Nette framework (http://nette.org) has got own Nette\Object as a base of other objects. It also rewrite the default __get method in PHP object but it uses definition with pointer:

      public function &__get($name)
      

      Doctrine Common creates Proxy classes with __get method too but not with reference. It causes an error using strict warning:

      Declaration of Proxy\__CG__\MyEntityObject::__get() should be compatible with & Nette\Object::__get($name)
      

      The problem is in ProxyGenerator. Locally I've patched it in my Doctrine repository clone but don't know how to resolve it globally.

        Activity

        Show
        Marco Pivetta added a comment - Merged at https://github.com/doctrine/common/commit/d658ec7a03f6475eff0dd1eb940bdedd862e4b96
        Hide
        Marco Pivetta added a comment -

        Cleaned and re-submitted at https://github.com/doctrine/common/pull/281

        Please review and then I'll merge.

        Show
        Marco Pivetta added a comment - Cleaned and re-submitted at https://github.com/doctrine/common/pull/281 Please review and then I'll merge.
        Hide
        Jan Pecek added a comment -

        Michael Moravec: Yes, this is ok. Now, proxy classes are generated well.

        Show
        Jan Pecek added a comment - Michael Moravec: Yes, this is ok. Now, proxy classes are generated well.
        Hide
        Michael Moravec added a comment - - edited

        Hello, I've patched ProxyGenerator::generateMagicGet method to support reference, see Github PR #278.
        Jan Pecek, could you confirm it fixes the problem?

        Show
        Michael Moravec added a comment - - edited Hello, I've patched ProxyGenerator::generateMagicGet method to support reference, see Github PR #278 . Jan Pecek, could you confirm it fixes the problem?
        Hide
        Marco Pivetta added a comment -

        Christophe Coevoet I think I already check proxied methods, but didn't apply that logic for magic methods.

        edit: indeed, there's a test for that: https://github.com/doctrine/common/blob/2.4.0-RC3/tests/Doctrine/Tests/Common/Proxy/LazyLoadableObject.php#L101-L106

        Show
        Marco Pivetta added a comment - Christophe Coevoet I think I already check proxied methods, but didn't apply that logic for magic methods. edit: indeed, there's a test for that: https://github.com/doctrine/common/blob/2.4.0-RC3/tests/Doctrine/Tests/Common/Proxy/LazyLoadableObject.php#L101-L106
        Hide
        Christophe Coevoet added a comment -

        This should probably be checked for all proxied methods, not only for magic ones

        Show
        Christophe Coevoet added a comment - This should probably be checked for all proxied methods, not only for magic ones
        Hide
        Marco Pivetta added a comment -
        Show
        Marco Pivetta added a comment - https://github.com/doctrine/common/blob/2.4.0-RC2/lib/Doctrine/Common/Proxy/ProxyGenerator.php#L386-L403 could be patched to verify if the method is byref/byval.

          People

          • Assignee:
            Marco Pivetta
            Reporter:
            Jan Pecek
          • Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: