-
Notifications
You must be signed in to change notification settings - Fork 22
/
example-19.php
54 lines (44 loc) · 1.22 KB
/
example-19.php
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace MovieApp {
class Lister1 {
public $finder;
public function __construct(Finder $finder){
$this->finder = $finder;
}
}
class Lister2 {
public $finder;
public function __construct(Finder $finder){
$this->finder = $finder;
}
}
class Finder {
public $source;
public function __construct(Source $source) {
$this->source = $source;
}
}
class Source {
}
}
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(
'instance' => array(
'MovieApp\Finder' => array(
'shared' => false
)
)
)));
$lister1 = $di->get('MovieApp\Lister1');
$lister2 = $di->get('MovieApp\Lister2');
// expression to test
$works = ($lister1->finder instanceof MovieApp\Finder
&& $lister1->finder !== $lister2->finder
&& $lister1->finder->source === $lister2->finder->source
);
// display result
echo (($works) ? 'It works!' : 'It DOES NOT work!') . PHP_EOL;
}