create-berna-stencil 2.0.13 → 2.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/README.md +1 -1
  2. package/_tools/res/templates/template.njk +1 -1
  3. package/bin/create.js +46 -39
  4. package/package.json +1 -1
  5. package/src/backend/_core/vendor/composer/autoload_static.php +10 -10
  6. package/src/backend/_core/vendor/composer/installed.json +6 -6
  7. package/src/backend/_core/vendor/composer/installed.php +2 -2
  8. package/src/backend/_core/vendor/graham-campbell/result-type/LICENSE +21 -21
  9. package/src/backend/_core/vendor/graham-campbell/result-type/composer.json +33 -33
  10. package/src/backend/_core/vendor/graham-campbell/result-type/src/Error.php +121 -121
  11. package/src/backend/_core/vendor/graham-campbell/result-type/src/Result.php +69 -69
  12. package/src/backend/_core/vendor/graham-campbell/result-type/src/Success.php +120 -120
  13. package/src/backend/_core/vendor/phpoption/phpoption/LICENSE +200 -200
  14. package/src/backend/_core/vendor/phpoption/phpoption/composer.json +50 -50
  15. package/src/backend/_core/vendor/phpoption/phpoption/src/PhpOption/LazyOption.php +175 -175
  16. package/src/backend/_core/vendor/phpoption/phpoption/src/PhpOption/None.php +136 -136
  17. package/src/backend/_core/vendor/phpoption/phpoption/src/PhpOption/Option.php +434 -434
  18. package/src/backend/_core/vendor/phpoption/phpoption/src/PhpOption/Some.php +169 -169
  19. package/src/backend/_core/vendor/symfony/polyfill-ctype/Ctype.php +232 -232
  20. package/src/backend/_core/vendor/symfony/polyfill-ctype/LICENSE +19 -19
  21. package/src/backend/_core/vendor/symfony/polyfill-ctype/README.md +12 -12
  22. package/src/backend/_core/vendor/symfony/polyfill-ctype/bootstrap.php +50 -50
  23. package/src/backend/_core/vendor/symfony/polyfill-ctype/bootstrap80.php +46 -46
  24. package/src/backend/_core/vendor/symfony/polyfill-ctype/composer.json +38 -38
  25. package/src/backend/_core/vendor/symfony/polyfill-mbstring/LICENSE +19 -19
  26. package/src/backend/_core/vendor/symfony/polyfill-mbstring/Mbstring.php +1077 -1077
  27. package/src/backend/_core/vendor/symfony/polyfill-mbstring/README.md +13 -13
  28. package/src/backend/_core/vendor/symfony/polyfill-mbstring/Resources/unidata/caseFolding.php +119 -119
  29. package/src/backend/_core/vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php +1397 -1397
  30. package/src/backend/_core/vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.php +5 -5
  31. package/src/backend/_core/vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.php +1489 -1489
  32. package/src/backend/_core/vendor/symfony/polyfill-mbstring/bootstrap.php +171 -171
  33. package/src/backend/_core/vendor/symfony/polyfill-mbstring/bootstrap80.php +167 -167
  34. package/src/backend/_core/vendor/symfony/polyfill-mbstring/composer.json +39 -39
  35. package/src/backend/_core/vendor/symfony/polyfill-php80/LICENSE +19 -19
  36. package/src/backend/_core/vendor/symfony/polyfill-php80/Php80.php +115 -115
  37. package/src/backend/_core/vendor/symfony/polyfill-php80/PhpToken.php +106 -106
  38. package/src/backend/_core/vendor/symfony/polyfill-php80/README.md +25 -25
  39. package/src/backend/_core/vendor/symfony/polyfill-php80/Resources/stubs/Attribute.php +31 -31
  40. package/src/backend/_core/vendor/symfony/polyfill-php80/Resources/stubs/PhpToken.php +16 -16
  41. package/src/backend/_core/vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php +20 -20
  42. package/src/backend/_core/vendor/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php +16 -16
  43. package/src/backend/_core/vendor/symfony/polyfill-php80/Resources/stubs/ValueError.php +16 -16
  44. package/src/backend/_core/vendor/symfony/polyfill-php80/bootstrap.php +42 -42
  45. package/src/backend/_core/vendor/symfony/polyfill-php80/composer.json +37 -37
  46. package/src/backend/_core/vendor/vlucas/phpdotenv/LICENSE +30 -30
  47. package/src/backend/_core/vendor/vlucas/phpdotenv/composer.json +60 -60
  48. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Dotenv.php +267 -267
  49. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Exception/ExceptionInterface.php +12 -12
  50. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Exception/InvalidEncodingException.php +12 -12
  51. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Exception/InvalidFileException.php +12 -12
  52. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Exception/InvalidPathException.php +12 -12
  53. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Exception/ValidationException.php +12 -12
  54. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Loader/Loader.php +48 -48
  55. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Loader/LoaderInterface.php +20 -20
  56. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Loader/Resolver.php +65 -65
  57. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Parser/Entry.php +59 -59
  58. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Parser/EntryParser.php +299 -299
  59. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Parser/Lexer.php +58 -58
  60. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Parser/Lines.php +127 -127
  61. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Parser/Parser.php +53 -53
  62. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Parser/ParserInterface.php +19 -19
  63. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Parser/Value.php +88 -88
  64. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/AdapterInterface.php +15 -15
  65. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/ApacheAdapter.php +89 -89
  66. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/ArrayAdapter.php +80 -80
  67. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/EnvConstAdapter.php +88 -88
  68. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/GuardedWriter.php +85 -85
  69. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/ImmutableWriter.php +110 -110
  70. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/MultiReader.php +48 -48
  71. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/MultiWriter.php +64 -64
  72. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/PutenvAdapter.php +91 -91
  73. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/ReaderInterface.php +17 -17
  74. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/ReplacingWriter.php +104 -104
  75. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/ServerConstAdapter.php +88 -88
  76. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/WriterInterface.php +27 -27
  77. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/AdapterRepository.php +107 -107
  78. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/RepositoryBuilder.php +272 -272
  79. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/RepositoryInterface.php +51 -51
  80. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Store/File/Paths.php +44 -44
  81. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Store/File/Reader.php +81 -81
  82. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Store/FileStore.php +72 -72
  83. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Store/StoreBuilder.php +141 -141
  84. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Store/StoreInterface.php +17 -17
  85. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Store/StringStore.php +37 -37
  86. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Util/Regex.php +112 -112
  87. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Util/Str.php +108 -108
  88. package/src/backend/_core/vendor/vlucas/phpdotenv/src/Validator.php +207 -207
  89. package/src/backend/_core/vendor/graham-campbell/result-type/.gitattributes +0 -9
  90. package/src/backend/_core/vendor/graham-campbell/result-type/.github/CODE_OF_CONDUCT.md +0 -132
  91. package/src/backend/_core/vendor/graham-campbell/result-type/.github/CONTRIBUTING.md +0 -31
  92. package/src/backend/_core/vendor/graham-campbell/result-type/.github/FUNDING.yml +0 -2
  93. package/src/backend/_core/vendor/graham-campbell/result-type/.github/SECURITY.md +0 -14
  94. package/src/backend/_core/vendor/graham-campbell/result-type/.github/workflows/stale.yml +0 -11
  95. package/src/backend/_core/vendor/graham-campbell/result-type/.github/workflows/tests.yml +0 -40
  96. package/src/backend/_core/vendor/graham-campbell/result-type/CHANGELOG.md +0 -53
  97. package/src/backend/_core/vendor/graham-campbell/result-type/README.md +0 -42
  98. package/src/backend/_core/vendor/graham-campbell/result-type/phpunit.xml.dist +0 -13
  99. package/src/backend/_core/vendor/graham-campbell/result-type/tests/ResultTest.php +0 -95
  100. package/src/backend/_core/vendor/phpoption/phpoption/.gitattributes +0 -13
  101. package/src/backend/_core/vendor/phpoption/phpoption/.github/CODE_OF_CONDUCT.md +0 -132
  102. package/src/backend/_core/vendor/phpoption/phpoption/.github/CONTRIBUTING.md +0 -30
  103. package/src/backend/_core/vendor/phpoption/phpoption/.github/FUNDING.yml +0 -2
  104. package/src/backend/_core/vendor/phpoption/phpoption/.github/SECURITY.md +0 -14
  105. package/src/backend/_core/vendor/phpoption/phpoption/.github/workflows/static.yml +0 -40
  106. package/src/backend/_core/vendor/phpoption/phpoption/.github/workflows/tests.yml +0 -40
  107. package/src/backend/_core/vendor/phpoption/phpoption/Makefile +0 -17
  108. package/src/backend/_core/vendor/phpoption/phpoption/README.md +0 -201
  109. package/src/backend/_core/vendor/phpoption/phpoption/phpstan-baseline.neon +0 -44
  110. package/src/backend/_core/vendor/phpoption/phpoption/phpstan.neon.dist +0 -7
  111. package/src/backend/_core/vendor/phpoption/phpoption/phpunit.xml.dist +0 -13
  112. package/src/backend/_core/vendor/phpoption/phpoption/tests/PhpOption/Tests/EnsureTest.php +0 -72
  113. package/src/backend/_core/vendor/phpoption/phpoption/tests/PhpOption/Tests/LazyOptionTest.php +0 -357
  114. package/src/backend/_core/vendor/phpoption/phpoption/tests/PhpOption/Tests/NoneTest.php +0 -153
  115. package/src/backend/_core/vendor/phpoption/phpoption/tests/PhpOption/Tests/OptionTest.php +0 -166
  116. package/src/backend/_core/vendor/phpoption/phpoption/tests/PhpOption/Tests/SomeTest.php +0 -194
  117. package/src/backend/_core/vendor/phpoption/phpoption/tests/bootstrap.php +0 -8
  118. package/src/backend/_core/vendor/phpoption/phpoption/vendor-bin/phpstan/composer.json +0 -8
  119. package/src/backend/_core/vendor/vlucas/phpdotenv/.editorconfig +0 -15
  120. package/src/backend/_core/vendor/vlucas/phpdotenv/.gitattributes +0 -15
  121. package/src/backend/_core/vendor/vlucas/phpdotenv/.github/CODE_OF_CONDUCT.md +0 -132
  122. package/src/backend/_core/vendor/vlucas/phpdotenv/.github/CONTRIBUTING.md +0 -30
  123. package/src/backend/_core/vendor/vlucas/phpdotenv/.github/FUNDING.yml +0 -2
  124. package/src/backend/_core/vendor/vlucas/phpdotenv/.github/SECURITY.md +0 -14
  125. package/src/backend/_core/vendor/vlucas/phpdotenv/.github/workflows/static.yml +0 -40
  126. package/src/backend/_core/vendor/vlucas/phpdotenv/.github/workflows/tests.yml +0 -70
  127. package/src/backend/_core/vendor/vlucas/phpdotenv/Makefile +0 -17
  128. package/src/backend/_core/vendor/vlucas/phpdotenv/README.md +0 -370
  129. package/src/backend/_core/vendor/vlucas/phpdotenv/UPGRADING.md +0 -196
  130. package/src/backend/_core/vendor/vlucas/phpdotenv/phpstan-baseline.neon +0 -157
  131. package/src/backend/_core/vendor/vlucas/phpdotenv/phpstan.neon.dist +0 -7
  132. package/src/backend/_core/vendor/vlucas/phpdotenv/phpunit.xml.dist +0 -13
  133. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/DotenvTest.php +0 -387
  134. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Loader/LoaderTest.php +0 -86
  135. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/EntryParserTest.php +0 -234
  136. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/LexerTest.php +0 -40
  137. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/LinesTest.php +0 -53
  138. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/ParserTest.php +0 -98
  139. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/ArrayAdapterTest.php +0 -57
  140. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/EnvConstAdapterTest.php +0 -75
  141. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/PutenvAdapterTest.php +0 -52
  142. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/ServerConstAdapterTest.php +0 -75
  143. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/RepositoryTest.php +0 -305
  144. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Store/StoreTest.php +0 -141
  145. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/ValidatorTest.php +0 -479
  146. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/.env +0 -5
  147. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/assertions.env +0 -18
  148. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/booleans.env +0 -33
  149. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/commented.env +0 -15
  150. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/empty.env +0 -1
  151. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/example.env +0 -1
  152. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/exported.env +0 -7
  153. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/immutable.env +0 -1
  154. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/integers.env +0 -17
  155. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/large.env +0 -2
  156. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/multibyte.env +0 -3
  157. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/multiline.env +0 -14
  158. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/multiple.env +0 -4
  159. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/mutable.env +0 -1
  160. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/nested.env +0 -15
  161. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/quoted.env +0 -11
  162. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/specialchars.env +0 -8
  163. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/unicodevarnames.env +0 -2
  164. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/utf8-with-bom-encoding.env +0 -3
  165. package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/windows.env +0 -1
  166. package/src/backend/_core/vendor/vlucas/phpdotenv/vendor-bin/phpstan/composer.json +0 -15
  167. package/src/backend/config.php +0 -19
@@ -1,153 +0,0 @@
1
- <?php
2
-
3
- namespace PhpOption\Tests;
4
-
5
- use PhpOption\None;
6
- use PhpOption\Some;
7
- use PHPUnit\Framework\TestCase;
8
-
9
- class NoneTest extends TestCase
10
- {
11
- public function testGet(): void
12
- {
13
- if (method_exists($this, 'expectException')) {
14
- $this->expectException('RuntimeException');
15
- } else {
16
- $this->setExpectedException('RuntimeException');
17
- }
18
-
19
- $none = None::create();
20
- $none->get();
21
- }
22
-
23
- public function testGetOrElse(): void
24
- {
25
- $none = None::create();
26
- self::assertSame('foo', $none->getOrElse('foo'));
27
- }
28
-
29
- public function testGetOrCall(): void
30
- {
31
- $none = None::create();
32
- self::assertSame('foo', $none->getOrCall(function () {
33
- return 'foo';
34
- }));
35
- }
36
-
37
- public function testGetOrThrow(): void
38
- {
39
- if (method_exists($this, 'expectException')) {
40
- $this->expectException('RuntimeException');
41
- $this->expectExceptionMessage('Not Found!');
42
- } else {
43
- $this->setExpectedException('RuntimeException', 'Not Found!');
44
- }
45
-
46
- None::create()->getOrThrow(new \RuntimeException('Not Found!'));
47
- }
48
-
49
- public function testIsEmpty(): void
50
- {
51
- $none = None::create();
52
- self::assertTrue($none->isEmpty());
53
- }
54
-
55
- public function testOrElse(): void
56
- {
57
- $option = Some::create('foo');
58
- self::assertSame($option, None::create()->orElse($option));
59
- }
60
-
61
- public function testifDefined(): void
62
- {
63
- $none = None::create();
64
-
65
- self::assertNull($none->ifDefined(function () {
66
- throw new \LogicException('Should never be called.');
67
- }));
68
- }
69
-
70
- public function testForAll(): void
71
- {
72
- $none = None::create();
73
-
74
- self::assertSame($none, $none->forAll(function () {
75
- throw new \LogicException('Should never be called.');
76
- }));
77
- }
78
-
79
- public function testMap(): void
80
- {
81
- $none = None::create();
82
-
83
- self::assertSame($none, $none->map(function () {
84
- throw new \LogicException('Should not be called.');
85
- }));
86
- }
87
-
88
- public function testFlatMap(): void
89
- {
90
- $none = None::create();
91
-
92
- self::assertSame($none, $none->flatMap(function () {
93
- throw new \LogicException('Should not be called.');
94
- }));
95
- }
96
-
97
- public function testFilter(): void
98
- {
99
- $none = None::create();
100
-
101
- self::assertSame($none, $none->filter(function () {
102
- throw new \LogicException('Should not be called.');
103
- }));
104
- }
105
-
106
- public function testFilterNot(): void
107
- {
108
- $none = None::create();
109
-
110
- self::assertSame($none, $none->filterNot(function () {
111
- throw new \LogicException('Should not be called.');
112
- }));
113
- }
114
-
115
- public function testSelect(): void
116
- {
117
- $none = None::create();
118
-
119
- self::assertSame($none, $none->select(null));
120
- }
121
-
122
- public function testReject(): void
123
- {
124
- $none = None::create();
125
-
126
- self::assertSame($none, $none->reject(null));
127
- }
128
-
129
- public function testForeach(): void
130
- {
131
- $none = None::create();
132
-
133
- $called = 0;
134
- foreach ($none as $value) {
135
- $called++;
136
- }
137
-
138
- self::assertSame(0, $called);
139
- }
140
-
141
- public function testFoldLeftRight(): void
142
- {
143
- $none = None::create();
144
-
145
- self::assertSame(1, $none->foldLeft(1, function () {
146
- $this->fail();
147
- }));
148
-
149
- self::assertSame(1, $none->foldRight(1, function () {
150
- $this->fail();
151
- }));
152
- }
153
- }
@@ -1,166 +0,0 @@
1
- <?php
2
-
3
- namespace PhpOption\Tests;
4
-
5
- use ArrayAccess;
6
- use LogicException;
7
- use PhpOption\LazyOption;
8
- use PhpOption\None;
9
- use PhpOption\Option;
10
- use PhpOption\Some;
11
- use PHPUnit\Framework\TestCase;
12
-
13
- class OptionTest extends TestCase
14
- {
15
- public function testfromValueWithDefaultNoneValue(): void
16
- {
17
- self::assertInstanceOf(None::class, Option::fromValue(null));
18
- self::assertInstanceOf(Some::class, Option::fromValue('value'));
19
- }
20
-
21
- public function testFromValueWithFalseNoneValue(): void
22
- {
23
- self::assertInstanceOf(None::class, Option::fromValue(false, false));
24
- self::assertInstanceOf(Some::class, Option::fromValue('value', false));
25
- self::assertInstanceOf(Some::class, Option::fromValue(null, false));
26
- }
27
-
28
- public function testFromArraysValue(): void
29
- {
30
- self::assertEquals(None::create(), Option::fromArraysValue('foo', 'bar'));
31
- self::assertEquals(None::create(), Option::fromArraysValue(null, 'bar'));
32
- self::assertEquals(None::create(), Option::fromArraysValue(['foo' => 'bar'], 'baz'));
33
- self::assertEquals(None::create(), Option::fromArraysValue(['foo' => null], 'foo'));
34
- self::assertEquals(None::create(), Option::fromArraysValue(['foo' => 'bar'], null));
35
- self::assertEquals(new Some('foo'), Option::fromArraysValue(['foo' => 'foo'], 'foo'));
36
- self::assertEquals(new Some('foo'), Option::fromArraysValue([13 => 'foo'], 13));
37
-
38
- $object = new SomeArrayObject();
39
- $object['foo'] = 'foo';
40
- self::assertEquals(new Some('foo'), Option::fromArraysValue($object, 'foo'));
41
-
42
- $object = new SomeArrayObject();
43
- $object[13] = 'foo';
44
- self::assertEquals(new Some('foo'), Option::fromArraysValue($object, 13));
45
- }
46
-
47
- public function testFromReturn(): void
48
- {
49
- $null = function () {
50
- };
51
- $false = function () {
52
- return false;
53
- };
54
- $some = function () {
55
- return 'foo';
56
- };
57
-
58
- self::assertTrue(Option::fromReturn($null)->isEmpty());
59
- self::assertFalse(Option::fromReturn($false)->isEmpty());
60
- self::assertTrue(Option::fromReturn($false, [], false)->isEmpty());
61
- self::assertTrue(Option::fromReturn($some)->isDefined());
62
- self::assertFalse(Option::fromReturn($some, [], 'foo')->isDefined());
63
- }
64
-
65
- public function testOrElse(): void
66
- {
67
- $a = new Some('a');
68
- $b = new Some('b');
69
-
70
- self::assertSame('a', $a->orElse($b)->get());
71
- }
72
-
73
- public function testOrElseWithNoneAsFirst(): void
74
- {
75
- $a = None::create();
76
- $b = new Some('b');
77
-
78
- self::assertSame('b', $a->orElse($b)->get());
79
- }
80
-
81
- public function testOrElseWithLazyOptions(): void
82
- {
83
- $throws = function () {
84
- throw new LogicException('Should never be called.');
85
- };
86
-
87
- $a = new Some('a');
88
- $b = new LazyOption($throws);
89
-
90
- self::assertSame('a', $a->orElse($b)->get());
91
- }
92
-
93
- public function testOrElseWithMultipleAlternatives(): void
94
- {
95
- $throws = new LazyOption(function () {
96
- throw new LogicException('Should never be called.');
97
- });
98
- $returns = new LazyOption(function () {
99
- return new Some('foo');
100
- });
101
-
102
- $a = None::create();
103
-
104
- self::assertSame('foo', $a->orElse($returns)->orElse($throws)->get());
105
- }
106
-
107
- public function testLift(): void
108
- {
109
- $f = function ($a, $b) {
110
- return $a + $b;
111
- };
112
-
113
- $fL = Option::lift($f);
114
-
115
- $a = new Some(1);
116
- $b = new Some(5);
117
- $n = None::create();
118
-
119
- self::assertSame(6, $fL($a, $b)->get());
120
- self::assertSame(6, $fL($b, $a)->get());
121
- self::assertSame($n, $fL($a, $n));
122
- self::assertSame($n, $fL($n, $a));
123
- self::assertSame($n, $fL($n, $n));
124
- }
125
-
126
- public function testLiftDegenerate(): void
127
- {
128
- $f = function () {
129
- };
130
-
131
- $fL1 = Option::lift($f);
132
- $fL2 = Option::lift($f, false);
133
-
134
- self::assertEquals(None::create(), $fL1());
135
- self::assertEquals(Some::create(null), $fL2());
136
- }
137
- }
138
-
139
- class SomeArrayObject implements ArrayAccess
140
- {
141
- private $data = [];
142
-
143
- #[\ReturnTypeWillChange]
144
- public function offsetExists($offset)
145
- {
146
- return isset($this->data[$offset]);
147
- }
148
-
149
- #[\ReturnTypeWillChange]
150
- public function offsetGet($offset)
151
- {
152
- return $this->data[$offset];
153
- }
154
-
155
- #[\ReturnTypeWillChange]
156
- public function offsetSet($offset, $value)
157
- {
158
- $this->data[$offset] = $value;
159
- }
160
-
161
- #[\ReturnTypeWillChange]
162
- public function offsetUnset($offset)
163
- {
164
- unset($this->data[$offset]);
165
- }
166
- }
@@ -1,194 +0,0 @@
1
- <?php
2
-
3
- namespace PhpOption\Tests;
4
-
5
- use PhpOption\None;
6
- use PhpOption\Option;
7
- use PhpOption\Some;
8
- use PHPUnit\Framework\TestCase;
9
-
10
- class SomeTest extends TestCase
11
- {
12
- public function testGet(): void
13
- {
14
- $some = new Some('foo');
15
- self::assertSame('foo', $some->get());
16
- self::assertSame('foo', $some->getOrElse(null));
17
- self::assertSame('foo', $some->getOrCall('does_not_exist'));
18
- self::assertSame('foo', $some->getOrThrow(new \RuntimeException('Not found')));
19
- self::assertFalse($some->isEmpty());
20
- }
21
-
22
- public function testCreate(): void
23
- {
24
- $some = Some::create('foo');
25
- self::assertSame('foo', $some->get());
26
- self::assertSame('foo', $some->getOrElse(null));
27
- self::assertSame('foo', $some->getOrCall('does_not_exist'));
28
- self::assertSame('foo', $some->getOrThrow(new \RuntimeException('Not found')));
29
- self::assertFalse($some->isEmpty());
30
- }
31
-
32
- public function testOrElse(): void
33
- {
34
- $some = Some::create('foo');
35
- self::assertSame($some, $some->orElse(None::create()));
36
- self::assertSame($some, $some->orElse(Some::create('bar')));
37
- }
38
-
39
- public function testifDefined(): void
40
- {
41
- $called = false;
42
- $self = $this;
43
- $some = new Some('foo');
44
- $some->ifDefined(function ($v) use (&$called, $self) {
45
- $called = true;
46
- $self->assertSame('foo', $v);
47
- });
48
- self::assertTrue($called);
49
- }
50
-
51
- public function testForAll(): void
52
- {
53
- $called = false;
54
- $self = $this;
55
- $some = new Some('foo');
56
- self::assertSame($some, $some->forAll(function ($v) use (&$called, $self) {
57
- $called = true;
58
- $self->assertSame('foo', $v);
59
- }));
60
- self::assertTrue($called);
61
- }
62
-
63
- public function testMap(): void
64
- {
65
- $some = new Some('foo');
66
- self::assertSame('o', $some->map(function ($v) {
67
- return substr($v, 1, 1);
68
- })->get());
69
- }
70
-
71
- public function testFlatMap(): void
72
- {
73
- $repo = new Repository(['foo']);
74
-
75
- self::assertSame(['name' => 'foo'], $repo->getLastRegisteredUsername()
76
- ->flatMap([$repo, 'getUser'])
77
- ->getOrCall([$repo, 'getDefaultUser']));
78
- }
79
-
80
- public function testFilter(): void
81
- {
82
- $some = new Some('foo');
83
-
84
- self::assertInstanceOf(None::class, $some->filter(function ($v) {
85
- return 0 === strlen($v);
86
- }));
87
- self::assertSame($some, $some->filter(function ($v) {
88
- return strlen($v) > 0;
89
- }));
90
- }
91
-
92
- public function testFilterNot(): void
93
- {
94
- $some = new Some('foo');
95
-
96
- self::assertInstanceOf(None::class, $some->filterNot(function ($v) {
97
- return strlen($v) > 0;
98
- }));
99
- self::assertSame($some, $some->filterNot(function ($v) {
100
- return strlen($v) === 0;
101
- }));
102
- }
103
-
104
- public function testSelect(): void
105
- {
106
- $some = new Some('foo');
107
-
108
- self::assertSame($some, $some->select('foo'));
109
- self::assertInstanceOf(None::class, $some->select('bar'));
110
- self::assertInstanceOf(None::class, $some->select(true));
111
- }
112
-
113
- public function testReject(): void
114
- {
115
- $some = new Some('foo');
116
-
117
- self::assertSame($some, $some->reject(null));
118
- self::assertSame($some, $some->reject(true));
119
- self::assertInstanceOf(None::class, $some->reject('foo'));
120
- }
121
-
122
- public function testFoldLeftRight(): void
123
- {
124
- $some = new Some(5);
125
-
126
- $testObj = $this;
127
- self::assertSame(6, $some->foldLeft(1, function ($a, $b) use ($testObj) {
128
- $testObj->assertSame(1, $a);
129
- $testObj->assertSame(5, $b);
130
-
131
- return $a + $b;
132
- }));
133
-
134
- self::assertSame(6, $some->foldRight(1, function ($a, $b) use ($testObj) {
135
- $testObj->assertSame(1, $b);
136
- $testObj->assertSame(5, $a);
137
-
138
- return $a + $b;
139
- }));
140
- }
141
-
142
- public function testForeach(): void
143
- {
144
- $some = new Some('foo');
145
-
146
- $called = 0;
147
- $extractedValue = null;
148
- foreach ($some as $value) {
149
- $extractedValue = $value;
150
- $called++;
151
- }
152
-
153
- self::assertSame('foo', $extractedValue);
154
- self::assertSame(1, $called);
155
- }
156
- }
157
-
158
- // For the interested reader of these tests, we have gone some great lengths
159
- // to come up with a non-contrived example that might also be used in the
160
- // real-world, and not only for testing purposes :)
161
- class Repository
162
- {
163
- private $users;
164
-
165
- public function __construct(array $users = [])
166
- {
167
- $this->users = $users;
168
- }
169
-
170
- // A fast ID lookup, probably cached, sometimes we might not need the entire user.
171
- public function getLastRegisteredUsername(): Option
172
- {
173
- if (empty($this->users)) {
174
- return None::create();
175
- }
176
-
177
- return new Some(end($this->users));
178
- }
179
-
180
- // Returns a user object (we will live with an array here).
181
- public function getUser($name): Option
182
- {
183
- if (in_array($name, $this->users, true)) {
184
- return new Some(['name' => $name]);
185
- }
186
-
187
- return None::create();
188
- }
189
-
190
- public function getDefaultUser(): array
191
- {
192
- return ['name' => 'muhuhu'];
193
- }
194
- }
@@ -1,8 +0,0 @@
1
- <?php
2
-
3
- if (!is_file($autoloadFile = __DIR__.'/../vendor/autoload.php')) {
4
- echo 'Could not find "vendor/autoload.php". Did you forget to run "composer install --dev"?'.PHP_EOL;
5
- exit(1);
6
- }
7
-
8
- require_once $autoloadFile;
@@ -1,8 +0,0 @@
1
- {
2
- "require": {
3
- "phpstan/phpstan": "2.1.33"
4
- },
5
- "config": {
6
- "preferred-install": "dist"
7
- }
8
- }
@@ -1,15 +0,0 @@
1
- root = true
2
-
3
- [*]
4
- charset = utf-8
5
- end_of_line = lf
6
- insert_final_newline = true
7
- indent_style = space
8
- indent_size = 4
9
- trim_trailing_whitespace = true
10
-
11
- [*.md]
12
- trim_trailing_whitespace = false
13
-
14
- [*.{yml,yaml}]
15
- indent_size = 2
@@ -1,15 +0,0 @@
1
- * text=auto
2
-
3
- /tests export-ignore
4
- /.editorconfig export-ignore
5
- /.gitattributes export-ignore
6
- /.github export-ignore
7
- /.gitignore export-ignore
8
- /.github export-ignore
9
- /Makefile export-ignore
10
- /phpstan-baseline.neon export-ignore
11
- /phpstan.neon.dist export-ignore
12
- /phpunit.xml.dist export-ignore
13
- /README.md export-ignore
14
- /UPGRADING.md export-ignore
15
- /vendor-bin export-ignore
@@ -1,132 +0,0 @@
1
- # CONTRIBUTOR COVENANT CODE OF CONDUCT
2
-
3
- ## Our Pledge
4
-
5
- We as members, contributors, and leaders pledge to make participation in our
6
- community a harassment-free experience for everyone, regardless of age, body
7
- size, visible or invisible disability, ethnicity, sex characteristics, gender
8
- identity and expression, level of experience, education, socio-economic status,
9
- nationality, personal appearance, race, caste, color, religion, or sexual identity
10
- and orientation.
11
-
12
- We pledge to act and interact in ways that contribute to an open, welcoming,
13
- diverse, inclusive, and healthy community.
14
-
15
- ## Our Standards
16
-
17
- Examples of behavior that contributes to a positive environment for our
18
- community include:
19
-
20
- * Demonstrating empathy and kindness toward other people
21
- * Being respectful of differing opinions, viewpoints, and experiences
22
- * Giving and gracefully accepting constructive feedback
23
- * Accepting responsibility and apologizing to those affected by our mistakes,
24
- and learning from the experience
25
- * Focusing on what is best not just for us as individuals, but for the
26
- overall community
27
-
28
- Examples of unacceptable behavior include:
29
-
30
- * The use of sexualized language or imagery, and sexual attention or
31
- advances of any kind
32
- * Trolling, insulting or derogatory comments, and personal or political attacks
33
- * Public or private harassment
34
- * Publishing others' private information, such as a physical or email
35
- address, without their explicit permission
36
- * Other conduct which could reasonably be considered inappropriate in a
37
- professional setting
38
-
39
- ## Enforcement Responsibilities
40
-
41
- Community leaders are responsible for clarifying and enforcing our standards of
42
- acceptable behavior and will take appropriate and fair corrective action in
43
- response to any behavior that they deem inappropriate, threatening, offensive,
44
- or harmful.
45
-
46
- Community leaders have the right and responsibility to remove, edit, or reject
47
- comments, commits, code, wiki edits, issues, and other contributions that are
48
- not aligned to this Code of Conduct, and will communicate reasons for moderation
49
- decisions when appropriate.
50
-
51
- ## Scope
52
-
53
- This Code of Conduct applies within all community spaces, and also applies when
54
- an individual is officially representing the community in public spaces.
55
- Examples of representing our community include using an official e-mail address,
56
- posting via an official social media account, or acting as an appointed
57
- representative at an online or offline event.
58
-
59
- ## Enforcement
60
-
61
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
- reported to the community leaders responsible for enforcement at
63
- hello@gjcampbell.co.uk.
64
- All complaints will be reviewed and investigated promptly and fairly.
65
-
66
- All community leaders are obligated to respect the privacy and security of the
67
- reporter of any incident.
68
-
69
- ## Enforcement Guidelines
70
-
71
- Community leaders will follow these Community Impact Guidelines in determining
72
- the consequences for any action they deem in violation of this Code of Conduct:
73
-
74
- ### 1. Correction
75
-
76
- **Community Impact**: Use of inappropriate language or other behavior deemed
77
- unprofessional or unwelcome in the community.
78
-
79
- **Consequence**: A private, written warning from community leaders, providing
80
- clarity around the nature of the violation and an explanation of why the
81
- behavior was inappropriate. A public apology may be requested.
82
-
83
- ### 2. Warning
84
-
85
- **Community Impact**: A violation through a single incident or series
86
- of actions.
87
-
88
- **Consequence**: A warning with consequences for continued behavior. No
89
- interaction with the people involved, including unsolicited interaction with
90
- those enforcing the Code of Conduct, for a specified period of time. This
91
- includes avoiding interactions in community spaces as well as external channels
92
- like social media. Violating these terms may lead to a temporary or
93
- permanent ban.
94
-
95
- ### 3. Temporary Ban
96
-
97
- **Community Impact**: A serious violation of community standards, including
98
- sustained inappropriate behavior.
99
-
100
- **Consequence**: A temporary ban from any sort of interaction or public
101
- communication with the community for a specified period of time. No public or
102
- private interaction with the people involved, including unsolicited interaction
103
- with those enforcing the Code of Conduct, is allowed during this period.
104
- Violating these terms may lead to a permanent ban.
105
-
106
- ### 4. Permanent Ban
107
-
108
- **Community Impact**: Demonstrating a pattern of violation of community
109
- standards, including sustained inappropriate behavior, harassment of an
110
- individual, or aggression toward or disparagement of classes of individuals.
111
-
112
- **Consequence**: A permanent ban from any sort of public interaction within
113
- the community.
114
-
115
- ## Attribution
116
-
117
- This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
- version 2.1, available at
119
- [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
-
121
- Community Impact Guidelines were inspired by
122
- [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
-
124
- For answers to common questions about this code of conduct, see the FAQ at
125
- [https://www.contributor-covenant.org/faq][FAQ]. Translations are available
126
- at [https://www.contributor-covenant.org/translations][translations].
127
-
128
- [homepage]: https://www.contributor-covenant.org
129
- [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
- [Mozilla CoC]: https://github.com/mozilla/diversity
131
- [FAQ]: https://www.contributor-covenant.org/faq
132
- [translations]: https://www.contributor-covenant.org/translations