1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
4
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
5
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
6
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
7
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
8
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
9
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
10
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
11
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
12
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
13
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
14
|
|
|
* |
15
|
|
|
* This software consists of voluntary contributions made by many individuals |
16
|
|
|
* and is licensed under the MIT license. For more information, see |
17
|
|
|
* <https://github.com/baleen/migrations>. |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
namespace Baleen\Migrations\Service\Runner\Event\Migration; |
21
|
|
|
|
22
|
|
|
use Baleen\Migrations\Migration\OptionsInterface; |
23
|
|
|
use Baleen\Migrations\Shared\Event\AbstractDomainEvent; |
24
|
|
|
use Baleen\Migrations\Shared\Event\Context\CollectionContext; |
25
|
|
|
use Baleen\Migrations\Shared\Event\Context\CollectionContextInterface; |
26
|
|
|
use Baleen\Migrations\Shared\Event\Progress; |
27
|
|
|
use Baleen\Migrations\Version\VersionInterface; |
28
|
|
|
use DateTime; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Class MigrationEvent. |
32
|
|
|
* |
33
|
|
|
* @author Gabriel Somoza <[email protected]> |
34
|
|
|
*/ |
35
|
|
|
class MigrationEvent extends AbstractDomainEvent |
36
|
|
|
{ |
37
|
|
|
/** @var OptionsInterface */ |
38
|
|
|
private $options; |
39
|
|
|
|
40
|
|
|
/** @var VersionInterface */ |
41
|
|
|
private $target; |
42
|
|
|
|
43
|
|
|
/** @var CollectionContextInterface */ |
44
|
|
|
private $context; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* MigrationEvent constructor. |
48
|
|
|
* |
49
|
|
|
* @param VersionInterface $target |
50
|
|
|
* @param OptionsInterface $options |
51
|
|
|
* @param CollectionContextInterface $context |
|
|
|
|
52
|
|
|
* @param DateTime $occurredOn |
|
|
|
|
53
|
|
|
*/ |
54
|
19 |
|
public function __construct( |
55
|
|
|
VersionInterface $target, |
56
|
|
|
OptionsInterface $options, |
57
|
|
|
CollectionContextInterface $context = null, |
58
|
|
|
DateTime $occurredOn = null |
59
|
|
|
) { |
60
|
19 |
|
if (null === $context) { |
61
|
1 |
|
$context = new CollectionContext(new Progress(1, 1)); |
62
|
1 |
|
} |
63
|
19 |
|
$this->context = $context; |
64
|
|
|
|
65
|
19 |
|
$this->options = $options; |
66
|
19 |
|
$this->target = $target; |
67
|
|
|
|
68
|
19 |
|
parent::__construct($occurredOn); |
69
|
19 |
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return OptionsInterface |
73
|
|
|
*/ |
74
|
2 |
|
public function getOptions() |
75
|
|
|
{ |
76
|
2 |
|
return $this->options; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Returns the Version that's being migrated. |
81
|
|
|
* |
82
|
|
|
* NOTE: Do not confuse this method with version() |
83
|
|
|
* |
84
|
|
|
* @return VersionInterface |
85
|
|
|
*/ |
86
|
2 |
|
public function getTarget() |
87
|
|
|
{ |
88
|
2 |
|
return $this->target; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @return CollectionContextInterface |
93
|
|
|
*/ |
94
|
15 |
|
public function getContext() |
95
|
|
|
{ |
96
|
15 |
|
return $this->context; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @inheritdoc |
101
|
|
|
*/ |
102
|
1 |
|
protected function getAdditionalPayload() |
103
|
|
|
{ |
104
|
|
|
return [ |
105
|
1 |
|
'target' => $this->getTarget(), |
106
|
1 |
|
'options' => $this->getOptions(), |
107
|
1 |
|
'context' => $this->getContext(), |
108
|
1 |
|
]; |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
|
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.