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

        Jan Pecek created issue -
        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.
        Marco Pivetta made changes -
        Field Original Value New Value
        Labels nette proxy proxy
        Marco Pivetta made changes -
        Component/s Caching [ 10054 ]
        Marco Pivetta made changes -
        Assignee Benjamin Eberlei [ beberlei ] Marco Pivetta [ ocramius ]
        Marco Pivetta made changes -
        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.
        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:

        {code}
        public function &__get($name)
        {code}

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

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

        The problem is in ProxyGenerator. Locally I've patched it in my Doctrine repository clone but don't know how to resolve it globally.
        Marco Pivetta made changes -
        Priority Minor [ 4 ] Critical [ 2 ]
        Marco Pivetta made changes -
        Environment using Nette framework (http://nette.org), PHP 5.4 using Nette framework ( http://nette.org ), PHP 5.4
        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 -

        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
        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
        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
        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.
        Show
        Marco Pivetta added a comment - Merged at https://github.com/doctrine/common/commit/d658ec7a03f6475eff0dd1eb940bdedd862e4b96
        Marco Pivetta made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Benjamin Eberlei made changes -
        Fix Version/s 2.4 [ 10327 ]

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DCOM-194, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

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

            Dates

            • Created:
              Updated:
              Resolved: