1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright (c) 2011-present Mediasift Ltd |
5
|
|
|
* Copyright (c) 2015-present Ganbaro Digital Ltd |
6
|
|
|
* All rights reserved. |
7
|
|
|
* |
8
|
|
|
* Redistribution and use in source and binary forms, with or without |
9
|
|
|
* modification, are permitted provided that the following conditions |
10
|
|
|
* are met: |
11
|
|
|
* |
12
|
|
|
* * Redistributions of source code must retain the above copyright |
13
|
|
|
* notice, this list of conditions and the following disclaimer. |
14
|
|
|
* |
15
|
|
|
* * Redistributions in binary form must reproduce the above copyright |
16
|
|
|
* notice, this list of conditions and the following disclaimer in |
17
|
|
|
* the documentation and/or other materials provided with the |
18
|
|
|
* distribution. |
19
|
|
|
* |
20
|
|
|
* * Neither the names of the copyright holders nor the names of his |
21
|
|
|
* contributors may be used to endorse or promote products derived |
22
|
|
|
* from this software without specific prior written permission. |
23
|
|
|
* |
24
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
25
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
26
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
27
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
28
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
29
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
30
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
31
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
32
|
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
33
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
34
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
35
|
|
|
* POSSIBILITY OF SUCH DAMAGE. |
36
|
|
|
* |
37
|
|
|
* @category Libraries |
38
|
|
|
* @package Storyplayer/TestEnvironments |
39
|
|
|
* @author Stuart Herbert <[email protected]> |
40
|
|
|
* @copyright 2011-present Mediasift Ltd www.datasift.com |
41
|
|
|
* @copyright 2015-present Ganbaro Digital Ltd www.ganbarodigital.com |
42
|
|
|
* @license http://www.opensource.org/licenses/bsd-license.php BSD License |
43
|
|
|
* @link http://datasift.github.io/storyplayer |
44
|
|
|
*/ |
45
|
|
|
|
46
|
|
|
namespace Storyplayer\SPv3\TestEnvironments; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* group adapter for hosts managed by vagrant |
50
|
|
|
* |
51
|
|
|
* @category Libraries |
52
|
|
|
* @package Storyplayer/TestEnvironments |
53
|
|
|
* @author Stuart Herbert <[email protected]> |
54
|
|
|
* @copyright 2011-present Mediasift Ltd www.datasift.com |
55
|
|
|
* @copyright 2015-present Ganbaro Digital Ltd www.ganbarodigital.com |
56
|
|
|
* @license http://www.opensource.org/licenses/bsd-license.php BSD License |
57
|
|
|
* @link http://datasift.github.io/storyplayer |
58
|
|
|
*/ |
59
|
|
|
|
60
|
|
|
class Vagrant_GroupAdapter implements GroupAdapter |
61
|
|
|
{ |
62
|
|
|
public function __construct() |
63
|
|
|
{ |
64
|
|
|
$this->determineBaseFolder(); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
// ================================================================== |
68
|
|
|
// |
69
|
|
|
// Base folder support goes here |
70
|
|
|
// |
71
|
|
|
// ------------------------------------------------------------------ |
72
|
|
|
|
73
|
|
|
protected $baseFolder; |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* automagically work out where our test environment's files and |
77
|
|
|
* such like are |
78
|
|
|
* |
79
|
|
|
* @return void |
80
|
|
|
*/ |
81
|
|
|
protected function determineBaseFolder() |
82
|
|
|
{ |
83
|
|
|
// where should we be looking? |
84
|
|
|
// |
85
|
|
|
// first match wins! |
86
|
|
|
$candidates = [ |
87
|
|
|
dirname(debug_backtrace()[1]['file']), |
88
|
|
|
getcwd() |
89
|
|
|
]; |
90
|
|
|
|
91
|
|
|
foreach ($candidates as $folder) { |
92
|
|
|
if (file_exists($folder . '/Vagrantfile')) { |
93
|
|
|
$this->baseFolder = str_replace(getcwd(), '.', $folder); |
94
|
|
|
|
95
|
|
|
// all done |
96
|
|
|
return; |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
// if we get here, then we do not know where the Vagrantfile |
101
|
|
|
// is, and it is time to bail |
102
|
|
|
throw new Vagrant_E4xx_NoVagrantFile($candidates); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* which folder should SPv3 be in when interacting with this group |
107
|
|
|
* of virtual machines? |
108
|
|
|
* |
109
|
|
|
* @return string |
110
|
|
|
*/ |
111
|
|
|
public function getBaseFolder() |
112
|
|
|
{ |
113
|
|
|
return $this->baseFolder; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
// ================================================================== |
117
|
|
|
// |
118
|
|
|
// Host support goes here |
119
|
|
|
// |
120
|
|
|
// ------------------------------------------------------------------ |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* how do we validate any host adapters used by hosts in this group? |
124
|
|
|
* |
125
|
|
|
* @return HostAdapterValidator |
126
|
|
|
*/ |
127
|
|
|
public function getHostAdapterValidator() |
128
|
|
|
{ |
129
|
|
|
return new Vagrant_HostAdapterValidator($this); |
|
|
|
|
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
// ================================================================== |
133
|
|
|
// |
134
|
|
|
// Stuff to support SPv3.0-style internals goes here |
135
|
|
|
// |
136
|
|
|
// Everything below here is technical debt, and the plan is to |
137
|
|
|
// gradually phase it all out over several SPv3 releases |
138
|
|
|
// |
139
|
|
|
// ------------------------------------------------------------------ |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* what type of group are we? |
143
|
|
|
* |
144
|
|
|
* this is the name of the class (without namespace) that our group |
145
|
|
|
* adapter uses |
146
|
|
|
* |
147
|
|
|
* @return string |
148
|
|
|
*/ |
149
|
|
|
public function getType() |
150
|
|
|
{ |
151
|
|
|
return "LocalVagrantVms"; |
152
|
|
|
} |
153
|
|
|
} |
154
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.