Skip to content

Commit 46f5855

Browse files
committed
move $types to neon
1 parent 478b0e9 commit 46f5855

File tree

2 files changed

+28
-22
lines changed

2 files changed

+28
-22
lines changed

bin/generate.php

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -228,33 +228,14 @@ private function returnType(Type $type): string
228228

229229
}
230230

231-
$types = [
232-
'array',
233-
'array|null',
234-
'object',
235-
'object|null',
236-
'string',
237-
'string|null',
238-
'int',
239-
'int|null',
240-
'float',
241-
'float|null',
242-
'int|float',
243-
'int|float|null',
244-
'numeric',
245-
'numericInt',
246-
'numericInt|null',
247-
'numericFloat',
248-
'numericFloat|null',
249-
];
250-
251231
$data = (new Processor())->process(Expect::structure([
252232
'types' => Expect::arrayOf(Expect::structure([
253233
'assertions' => Expect::anyOf(Expect::string(), Expect::arrayOf('string'))->castTo('array')->default([]),
254234
'returns' => Expect::anyOf(Expect::string(), Expect::arrayOf('string'))->castTo('array')->default([]),
255235
'prolog' => Expect::string()->default(null),
256236
'epilog' => Expect::string()->default(null),
257237
])),
238+
'generate' => Expect::arrayOf(Expect::string()),
258239
]), Neon::decode(FileSystem::read(__DIR__ . '/methods.neon')));
259240

260241
$generator = new TypeAssertionGenerator(
@@ -265,5 +246,5 @@ private function returnType(Type $type): string
265246
$data->types,
266247
);
267248

268-
FileSystem::write(__DIR__ . '/../src/Mixins/TypeAssertTrait.php', $generator->run($types));
269-
FileSystem::write(__DIR__ . '/../src/Mixins/ArrayTypeAssertTrait.php', $generator->runArray($types));
249+
FileSystem::write(__DIR__ . '/../src/Mixins/TypeAssertTrait.php', $generator->run($data->generate));
250+
FileSystem::write(__DIR__ . '/../src/Mixins/ArrayTypeAssertTrait.php', $generator->runArray($data->generate));

bin/methods.neon

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ types:
99
assertions: '!is_object($value)'
1010
string:
1111
assertions: '!is_string($value)'
12+
scalar:
13+
returns: [int, float, string, bool]
14+
assertions: '!is_scalar($value)'
1215
null:
1316
assertions: '$value !== null'
1417

@@ -36,3 +39,25 @@ types:
3639
$value = (int) preg_replace('#\\.0*$#D', '', $value);
3740
}
3841
"""
42+
43+
generate:
44+
- array
45+
- array|null
46+
- object
47+
- object|null
48+
- string
49+
- string|null
50+
- int
51+
- int|null
52+
- float
53+
- float|null
54+
- int|float
55+
- int|float|null
56+
- scalar
57+
- scalar|null
58+
## special
59+
- numeric
60+
- numericInt
61+
- numericInt|null
62+
- numericFloat
63+
- numericFloat|null

0 commit comments

Comments
 (0)