forked from phpDocumentor/Reflection
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.file.php
More file actions
275 lines (230 loc) · 5.97 KB
/
example.file.php
File metadata and controls
275 lines (230 loc) · 5.97 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
<?php
// phpcs:ignoreFile
/**
* Summary of the File DocBlock.
*
* Description of the File.
*
* @package Luigi\Pizza
* @author Mike van Riel <me@mikevanriel.com>
*/
namespace Luigi\Pizza
{
/**
* The high VAT percentage.
*
* This describes the VAT percentage for all non-food items.
*
* @var integer
*/
const VAT_HIGH = 21;
/**
* The low VAT percentage.
*
* This describes the VAT percentage for all non-food items.
*
* @var integer
*/
define('Luigi\Pizza\VAT_LOW', 6);
/**
* @var integer SIZE_5CM A 5 centimeter pizza size.
* @var integer SIZE_10CM A 10 centimeter pizza size.
* @var integer SIZE_15CM A 15 centimeter pizza size.
* @var integer SIZE_20CM A 20 centimeter pizza size.
* @var integer DEFAULT_SIZE The default Pizza size if you don't provide your own.
*/
const SIZE_5CM = 5, SIZE_10CM = 10, SIZE_15CM = 15, SIZE_20CM = 20, DEFAULT_SIZE = SIZE_20CM;
trait ExampleNestedTrait
{
private function exampleTraitMethod()
{
}
}
/**
* A single item with a value
*
* Represents something with a price.
*/
trait HasPrice
{
use ExampleNestedTrait;
private $temporaryPrice = 1;
public function getPrice()
{
return $this->price;
}
}
/**
* Any class implementing this interface has an associated price.
*
* Using this interface we can easily add the price of all components in a pizza by checking for this interface and
* adding the prices together for all components.
*/
interface Valued
{
const BASE_PRICE = 1;
function getPrice();
}
interface Series
{
}
interface Style extends Valued
{
}
interface Sauce extends Valued
{
}
interface Topping extends Valued, \Serializable
{
}
abstract class PizzaComponentFactory implements \Traversable, Valued
{
public function add()
{
}
/**
* Calculates the price for this specific component.
*
* @param float[] $...additionalPrices Additional costs may be passed
*
* @return float
*/
abstract protected function calculatePrice();
}
final class StyleFactory extends PizzaComponentFactory
{
public function getPrice()
{
}
protected function calculatePrice()
{
}
}
final class SauceFactory extends PizzaComponentFactory
{
public function getPrice()
{
}
protected function calculatePrice()
{
}
}
final class ToppingFactory extends PizzaComponentFactory
{
public function getPrice()
{
}
protected function calculatePrice()
{
}
}
final class ItalianStyle implements Style
{
use HasPrice;
private $price = 2.0;
}
final class AmericanStyle implements Style
{
use HasPrice;
private $price = 1.5;
}
final class TomatoSauce implements Sauce
{
use HasPrice;
private $price = 1.5;
}
final class CheeseTopping implements Topping
{
use HasPrice;
private $price = 1.5;
public function serialize()
{
}
public function unserialize($serialized)
{
}
}
}
namespace Luigi
{
/**
* Class representing a single Pizza.
*
* This is Luigi's famous Pizza.
*
* @package Luigi\Pizza
*/
class Pizza implements Pizza\Valued
{
/**
* The packaging method used to transport the pizza.
*/
const PACKAGING = 'box';
const
/** @var string DELIVERY designates that the delivery method is to deliver the pizza to the customer. */
DELIVERY = 'delivery',
/** @var string PICKUP designates that the delivery method is that the customer picks the pizza up. */
PICKUP = 'pickup';
/** @var static contains the active instance for this Pizza. */
static private $instance;
/**
* @var Pizza\Style $style
* @var Pizza\Sauce|null $sauce
* @var Pizza\Topping[] $toppings
*/
private $style, $sauce, $toppings;
/**
* The size of the pizza in centimeters, defaults to 20cm.
*
* @var int
*/
public $size = \Luigi\Pizza\SIZE_20CM;
var $legacy; // don't use this anymore!
protected
/** @var string $packaging The type of packaging for this Pizza */
$packaging = self::PACKAGING,
/** @var string $deliveryMethod Is the customer picking this pizza up or must it be delivered? */
$deliveryMethod;
private function __construct(Pizza\Style $style)
{
$this->style = $style;
}
/**
* Creates a new instance of a Pizza.
*
* This method can be used to instantiate a new object of this class which can then be retrieved using
* {@see self::getInstance()}.
*
* @param Pizza\Style $style
*
* @see self::getInstance to retrieve the pizza object.
*
* @return void
*/
public static function createInstance(Pizza\Style $style)
{
self::$instance = new static($style);
}
/**
* @return self
*/
static function getInstance()
{
return self::$instance;
}
final public function setSauce(Pizza\Sauce $sauce)
{
$this->sauce = $sauce;
}
final public function addTopping(Pizza\Topping $topping)
{
$this->toppings[] = $topping;
}
public function setSize(&$size = \Luigi\Pizza\SIZE_20CM)
{
}
public function getPrice()
{
}
}
}