Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 076f2b89b7
Fetching contributors…

Cannot retrieve contributors at this time

file 36 lines (31 sloc) 0.917 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
<?php

namespace MovieApp {
    class AbstractLister {
        public $finder;
        public function setFinder(Finder $finder){
            $this->finder = $finder;
        }
    }
    class Lister extends AbstractLister {}
    class Finder {
    }
}

namespace {
    // bootstrap
    include 'zf2bootstrap' . ((stream_resolve_include_path('zf2bootstrap.php')) ? '.php' : '.dist.php');

    $di = new Zend\Di\Di;
    $di->configure(new Zend\Di\Configuration(array(
        'definition' => array(
            'class' => array(
                'MovieApp\AbstractLister' => array(
                    'setFinder' => array('required' => true)
                )
            )
        )
    )));
    $lister = $di->get('MovieApp\Lister');
    
    // expression to test
    $works = ($lister->finder instanceof MovieApp\Finder);

    // display result
    echo (($works) ? 'It works!' : 'It DOES NOT work!') . PHP_EOL;
}
Something went wrong with that request. Please try again.