-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathexample-class.php
101 lines (76 loc) · 1.91 KB
/
example-class.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
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
<?php
declare(strict_types = 1);
namespace Example;
use Throwable;
use function strlen as stringLength;
use Fancy\TestCase as TestCase;
use const PHP_RELEASE_VERSION as PHP_PATCH_VERSION;
use Doctrine\Sniffs\Spacing\ControlStructureSniff;
class ParentClass
{
}
/**
* Description
* @author Invalid
* @since 0.1
*/
class Example extends ParentClass implements \IteratorAggregate
{
private const VERSION = \PHP_VERSION - (PHP_MINOR_VERSION * 100) - PHP_PATCH_VERSION;
/** @var null|int */
private $foo;
/** @var string[] */
private $bar;
/** @var bool */
private $baz;
/** @var ControlStructureSniff|int|string|null */
private $baxBax;
public function __construct(int $foo = null, array $bar = [], bool $baz = false, $baxBax = 'unused')
{
$this->foo = $foo;
$this->bar = $bar;
$this->baz = $baz;
$this->baxBax = $baxBax;
parent::__construct();
}
/**
* Description
* @return int|null
*/
public function getFoo() : ? int
{
return $this->foo;
}
/**
* @return iterable
*/
public function getIterator() :array
{
assert($this->bar !== null);
return new \ArrayIterator($this->bar);
}
public function isBaz(): bool
{
list($foo, $bar, $baz) = $this->bar;
return $this->baz;
}
/**
* @throws InvalidArgumentException if this example cannot baz.
*/
public function mangleBar(int $length): void
{
if (!$this->baz) {
throw new \InvalidArgumentException();
}
$this->bar = (string) $this->baxBax ?? \substr($this->bar, stringLength($this->bar - $length));
}
public static function getMinorVersion(): int
{
$version = self::VERSION;
return $version;
}
public static function getTestCase(): TestCase
{
return new TestCase();
}
}