Ticket #102 (closed defect: fixed)

Opened 6 months ago

Last modified 5 months ago

Implicit binding does not work if requested via Inject()

Reported by: mikey Assigned to: mikey
Priority: major Milestone: 0.4.0
Component: InversionOfControl Version: SVN-trunk
Keywords: Cc:

Description

Consider the following code:

class ShopPageElement extends stubAbstractPageElement implements stubXMLPageElement
{
    protected $shopEntityManager;

    /**
     * sets the entity manager for shops
     *
     * @param  ShopEntityManager  $shopEntityManager
     * @Inject()
     */
    public function setShopEntityManager(ShopEntityManager $shopEntityManager)
    {
        $this->shopEntityManager = $shopEntityManager;
    }

    // more methods...
}

The type hint ShopEntityManager denotes a concrete class which is already loaded. This should work like normal implicit binding. However this throws a stubBindingException with message Could not create instance of ShopEntityManager. No binding for type ShopEntityManager specified.

Change History

11/22/07 22:02:36 changed by schst

  • status changed from new to assigned.

12/13/07 16:02:20 changed by mikey

  • milestone changed from 0.4.0 to 0.5.0.

12/23/07 11:53:32 changed by mikey

  • owner changed from schst to mikey.
  • status changed from assigned to new.
  • milestone changed from 0.5.0 to 0.4.0.

The problem is the implementation of the stubInjection::handleInjections() method in conjunction with the stubInjection::hasBinding() method. When stubInjection::handleInjections() is applied on an existing object instance, it checks if a binding for a required injection exists. However, stubInjection::hasBinding() does not check for implicit bindings and therefore returns false, resulting in a thrown stubBindingException.

I'll provide a fix, as there is a todo on the binding handling anyway, which will be fixed with this as well.

12/23/07 11:53:38 changed by mikey

  • status changed from new to assigned.

12/23/07 12:01:23 changed by mikey

  • status changed from assigned to closed.
  • resolution set to fixed.

Fixed with changeset 1181.