1 | <?php |
||
21 | final class ApiSpecification implements ArrayAccess |
||
22 | { |
||
23 | public const VISIBILITY_PUBLIC = 1; |
||
24 | public const VISIBILITY_PROTECTED = 2; |
||
25 | public const VISIBILITY_PRIVATE = 4; |
||
26 | public const VISIBILITY_INTERNAL = 8; |
||
27 | public const VISIBILITY_API = 16; |
||
28 | |||
29 | /** @var int by default ignore internal visibility but show others */ |
||
30 | public const VISIBILITY_DEFAULT = 7; |
||
31 | |||
32 | /** @var array{dsn: Dsn, paths: array<Path>} */ |
||
33 | private $source; |
||
34 | |||
35 | /** @var string */ |
||
36 | private $output; |
||
37 | |||
38 | /** @var array{paths: array<Path>} */ |
||
39 | private $ignore; |
||
40 | |||
41 | /** @var non-empty-list<string> */ |
||
42 | private $extensions; |
||
43 | |||
44 | /** @var array<string> */ |
||
45 | private $visibility; |
||
46 | |||
47 | /** @var string */ |
||
48 | private $defaultPackageName; |
||
49 | |||
50 | /** @var bool */ |
||
51 | private $includeSource; |
||
52 | |||
53 | /** @var array<string> */ |
||
54 | private $markers; |
||
55 | |||
56 | /** @var array<string> */ |
||
57 | private $ignoreTags; |
||
58 | |||
59 | /** @var array{dsn: Dsn, paths: list<string>}|null */ |
||
60 | private $examples; |
||
61 | |||
62 | /** @var string */ |
||
63 | private $encoding; |
||
64 | |||
65 | /** @var bool */ |
||
66 | private $validate; |
||
67 | |||
68 | /** |
||
69 | * @param array{dsn: Dsn, paths: array<Path>} $source |
||
70 | * @param array{paths: array<Path>} $ignore |
||
71 | * @param non-empty-list<string> $extensions |
||
|
|||
72 | * @param array<string> $visibility |
||
73 | * @param array<string> $markers |
||
74 | * @param array<string> $ignoreTags |
||
75 | * @param array{dsn: Dsn, paths: list<string>}|null $examples |
||
76 | */ |
||
77 | private function __construct( |
||
104 | |||
105 | //phpcs:disable Generic.Files.LineLength.TooLong |
||
106 | /** |
||
107 | * @param array{ignore-tags: array<string>, extensions: non-empty-array<string>, markers: non-empty-array<string>, visibility: non-empty-array<string>, source: array{dsn: Dsn, paths: array}, ignore: array{paths: array}, encoding: string, output: string, default-package-name: string, examples: array{dsn: Dsn, paths: array}, include-source: bool, validate: bool} $api |
||
108 | */ |
||
109 | //phpcs:enable Generic.Files.LineLength.TooLong |
||
110 | public static function createFromArray(array $api) : self |
||
127 | |||
128 | public static function createDefault() : ApiSpecification |
||
150 | |||
151 | /** |
||
152 | * @param array{dsn: Dsn, paths: array<Path>} $source |
||
153 | */ |
||
154 | public function withSource(array $source) : self |
||
161 | |||
162 | /** |
||
163 | * @param array{paths: non-empty-array<Path>} $ignore |
||
164 | */ |
||
165 | public function setIgnore(array $ignore) : void |
||
169 | |||
170 | /** @param string $offset */ |
||
171 | public function offsetExists($offset) : bool |
||
177 | |||
178 | /** |
||
179 | * @param string $offset |
||
180 | * |
||
181 | * @return mixed |
||
182 | */ |
||
183 | public function offsetGet($offset) |
||
192 | |||
193 | /** |
||
194 | * @param string $offset |
||
195 | * @param mixed $value |
||
196 | */ |
||
197 | public function offsetSet($offset, $value) : void |
||
206 | |||
207 | /** @param string $offset */ |
||
208 | public function offsetUnset($offset) : void |
||
217 | |||
218 | private function normalizePropertyName(string $offset) : string |
||
222 | |||
223 | /** @return string[] */ |
||
224 | public function getIgnoredTags() : array |
||
228 | |||
229 | public function calculateVisiblity() : int |
||
230 | { |
||
231 | $visibility = 0; |
||
232 | |||
233 | foreach ($this->visibility as $item) { |
||
234 | switch ($item) { |
||
235 | case 'api': |
||
236 | $visibility |= self::VISIBILITY_API; |
||
237 | break; |
||
238 | case 'public': |
||
239 | $visibility |= self::VISIBILITY_PUBLIC; |
||
240 | break; |
||
241 | case 'protected': |
||
242 | $visibility |= self::VISIBILITY_PROTECTED; |
||
243 | break; |
||
244 | case 'private': |
||
245 | $visibility |= self::VISIBILITY_PRIVATE; |
||
246 | break; |
||
247 | case 'internal': |
||
248 | $visibility |= self::VISIBILITY_INTERNAL; |
||
249 | break; |
||
250 | default: |
||
251 | throw new RuntimeException( |
||
252 | sprintf( |
||
253 | '%s is not a type of visibility, supported is: api, public, protected, private or internal', |
||
254 | $item |
||
255 | ) |
||
256 | ); |
||
257 | } |
||
258 | } |
||
259 | |||
260 | if ($visibility === self::VISIBILITY_INTERNAL) { |
||
261 | $visibility |= self::VISIBILITY_DEFAULT; |
||
262 | } |
||
263 | |||
264 | return $visibility; |
||
265 | } |
||
266 | |||
267 | /** |
||
268 | * Checks whether the Project supports the given visibility. |
||
269 | * |
||
270 | * @see Settings for a list of the available VISIBILITY_* constants. |
||
271 | * |
||
272 | * @param int $visibility One of the VISIBILITY_* constants of the Settings class. |
||
273 | */ |
||
274 | public function isVisibilityAllowed(int $visibility) : bool |
||
280 | } |
||
281 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.