Skip to content

Commit 1495adb

Browse files
committed
ClassType: constants are 'public' by default
1 parent 1e4721d commit 1495adb

File tree

9 files changed

+12
-12
lines changed

9 files changed

+12
-12
lines changed

src/PhpGenerator/ClassType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ public function getConstants(): array
421421

422422
public function addConstant(string $name, $value): Constant
423423
{
424-
return $this->consts[$name] = (new Constant($name))->setValue($value);
424+
return $this->consts[$name] = (new Constant($name))->setValue($value)->setPublic();
425425
}
426426

427427

tests/PhpGenerator/Printer.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ $class->addConstant('FORCE_ARRAY', new Literal('Nette\Utils\Json::FORCE_ARRAY'))
2727
->addComment('Commented');
2828

2929
$class->addConstant('MULTILINE_LONG', ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6]);
30-
$class->addConstant('SHORT', ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6]);
30+
$class->addConstant('SHORT', ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5]);
3131

3232
$class->addProperty('handle')
3333
->setVisibility('private')

tests/PhpGenerator/PsrPrinter.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ $class->addConstant('FORCE_ARRAY', new Literal('Nette\Utils\Json::FORCE_ARRAY'))
2626
->addComment('Commented');
2727

2828
$class->addConstant('MULTILINE_LONG', ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6]);
29-
$class->addConstant('SHORT', ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6]);
29+
$class->addConstant('SHORT', ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5]);
3030

3131
$class->addProperty('handle')
3232
->setVisibility('private')

tests/PhpGenerator/expected/ClassType.attributes.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Example
99
/** Commented */
1010
#[ExampleAttribute]
1111
#[WithArguments(true)]
12-
const FOO = 123;
12+
public const FOO = 123;
1313

1414
/** @var resource */
1515
#[ExampleAttribute]

tests/PhpGenerator/expected/ClassType.enum.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ enum Suit
1616
case Hearts;
1717
case Spades;
1818

19-
const ACTIVE = false;
19+
public const ACTIVE = false;
2020

2121
public function foo()
2222
{

tests/PhpGenerator/expected/ClassType.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ abstract class Example extends ParentClass implements IExample, IOne
1212
}
1313

1414
const ROLE = 'admin';
15-
final const ACTIVE = false;
15+
final public const ACTIVE = false;
1616

1717
/** Commented */
1818
private const FORCE_ARRAY = Nette\Utils\Json::FORCE_ARRAY;

tests/PhpGenerator/expected/Printer.class-alt.expect

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ final class Example extends ParentClass implements IExample
1212
/** Commented */
1313
private const FORCE_ARRAY = Nette\Utils\Json::FORCE_ARRAY;
1414

15-
const MULTILINE_LONG = [
15+
public const MULTILINE_LONG = [
1616
'aaaaaaaa' => 1,
1717
'bbbbbbbb' => 2,
1818
'cccccccc' => 3,
@@ -21,7 +21,7 @@ final class Example extends ParentClass implements IExample
2121
'ffffffff' => 6,
2222
];
2323

24-
const SHORT = ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6];
24+
public const SHORT = ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5];
2525

2626
/** @var resource orignal file handle */
2727
private $handle;

tests/PhpGenerator/expected/Printer.class.expect

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ final class Example extends ParentClass implements IExample
1212
/** Commented */
1313
private const FORCE_ARRAY = Nette\Utils\Json::FORCE_ARRAY;
1414

15-
const MULTILINE_LONG = [
15+
public const MULTILINE_LONG = [
1616
'aaaaaaaa' => 1,
1717
'bbbbbbbb' => 2,
1818
'cccccccc' => 3,
@@ -21,7 +21,7 @@ final class Example extends ParentClass implements IExample
2121
'ffffffff' => 6,
2222
];
2323

24-
const SHORT = ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6];
24+
public const SHORT = ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5];
2525

2626
/** @var resource orignal file handle */
2727
private $handle;

tests/PhpGenerator/expected/PsrPrinter.class.expect

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ final class Example extends ParentClass implements IExample
1212
/** Commented */
1313
private const FORCE_ARRAY = Nette\Utils\Json::FORCE_ARRAY;
1414

15-
const MULTILINE_LONG = [
15+
public const MULTILINE_LONG = [
1616
'aaaaaaaa' => 1,
1717
'bbbbbbbb' => 2,
1818
'cccccccc' => 3,
@@ -21,7 +21,7 @@ final class Example extends ParentClass implements IExample
2121
'ffffffff' => 6,
2222
];
2323

24-
const SHORT = ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6];
24+
public const SHORT = ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5];
2525

2626
/** @var resource orignal file handle */
2727
private $handle;

0 commit comments

Comments
 (0)