Skip to content

Commit d31782f

Browse files
committed
Type: constants are PascalCase
1 parent 7100868 commit d31782f

File tree

4 files changed

+42
-23
lines changed

4 files changed

+42
-23
lines changed

src/PhpGenerator/Type.php

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,41 @@
1616
class Type
1717
{
1818
public const
19-
STRING = 'string',
20-
INT = 'int',
21-
FLOAT = 'float',
22-
BOOL = 'bool',
23-
ARRAY = 'array',
24-
OBJECT = 'object',
25-
CALLABLE = 'callable',
26-
ITERABLE = 'iterable',
27-
VOID = 'void',
28-
NEVER = 'never',
29-
MIXED = 'mixed',
30-
FALSE = 'false',
31-
NULL = 'null',
32-
SELF = 'self',
33-
PARENT = 'parent',
34-
STATIC = 'static';
19+
String = 'string',
20+
Int = 'int',
21+
Float = 'float',
22+
Bool = 'bool',
23+
Array = 'array',
24+
Object = 'object',
25+
Callable = 'callable',
26+
Iterable = 'iterable',
27+
Void = 'void',
28+
Never = 'never',
29+
Mixed = 'mixed',
30+
False = 'false',
31+
Null = 'null',
32+
Self = 'self',
33+
Parent = 'parent',
34+
Static = 'static';
35+
36+
/** @deprecated */
37+
public const
38+
STRING = self::String,
39+
INT = self::Int,
40+
FLOAT = self::Float,
41+
BOOL = self::Bool,
42+
ARRAY = self::Array,
43+
OBJECT = self::Object,
44+
CALLABLE = self::Callable,
45+
ITERABLE = self::Iterable,
46+
VOID = self::Void,
47+
NEVER = self::Never,
48+
MIXED = self::Mixed,
49+
FALSE = self::False,
50+
NULL = self::Null,
51+
SELF = self::Self,
52+
PARENT = self::Parent,
53+
STATIC = self::Static;
3554

3655

3756
public static function nullable(string $type, bool $state = true): string

tests/PhpGenerator/ClassType.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,16 @@ $class->addProperty('order')
5858
->setValue(new Literal('RecursiveIteratorIterator::SELF_FIRST'));
5959

6060
$class->addProperty('typed1')
61-
->setType(Type::ARRAY)
61+
->setType(Type::Array)
6262
->setReadOnly();
6363

6464
$class->addProperty('typed2')
65-
->setType(Type::ARRAY)
65+
->setType(Type::Array)
6666
->setNullable()
6767
->setInitialized();
6868

6969
$class->addProperty('typed3')
70-
->setType(Type::ARRAY)
70+
->setType(Type::Array)
7171
->setValue(null);
7272

7373
$p = $class->addProperty('sections', ['first' => true])
@@ -126,7 +126,7 @@ $method->addParameter('item');
126126

127127
$method->addParameter('res', null)
128128
->setReference(true)
129-
->setType(Type::union(Type::ARRAY, 'null'));
129+
->setType(Type::union(Type::Array, 'null'));
130130

131131
$method->addParameter('bar', null)
132132
->setType('stdClass|string')

tests/PhpGenerator/Method.scalarParameters.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ Assert::same('float', $method->getParameters()['d']->getType());
3939

4040
$method = (new Method('create'))
4141
->setBody('return null;');
42-
$method->addParameter('a')->setType(Type::STRING);
43-
$method->addParameter('b')->setType(Type::BOOL);
42+
$method->addParameter('a')->setType(Type::String);
43+
$method->addParameter('b')->setType(Type::Bool);
4444

4545
same(
4646
'function create(string $a, bool $b)

tests/PhpGenerator/Type.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use Tester\Assert;
88
require __DIR__ . '/../bootstrap.php';
99

1010

11-
Assert::same('A|string', Type::union(A::class, Type::STRING));
11+
Assert::same('A|string', Type::union(A::class, Type::String));
1212

1313
Assert::same('?A', Type::nullable(A::class));
1414
Assert::same('?A', Type::nullable(A::class, true));

0 commit comments

Comments
 (0)