Skip to content

Commit ca4a819

Browse files
authored
Merge pull request #63 from myclabs/mnapoli-patch-1
Recommend using private constants
2 parents 4560a12 + cedc9f7 commit ca4a819

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

README.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ use MyCLabs\Enum\Enum;
3333
*/
3434
class Action extends Enum
3535
{
36-
const VIEW = 'view';
37-
const EDIT = 'edit';
36+
private const VIEW = 'view';
37+
private const EDIT = 'edit';
3838
}
3939
```
4040

41+
Note the `private` keyword requires PHP > 7.1, you can omit it on PHP 7.0.
4142

4243
## Usage
4344

@@ -80,8 +81,8 @@ Static methods:
8081
```php
8182
class Action extends Enum
8283
{
83-
const VIEW = 'view';
84-
const EDIT = 'edit';
84+
private const VIEW = 'view';
85+
private const EDIT = 'edit';
8586
}
8687

8788
// Static method:
@@ -96,7 +97,7 @@ If you care about IDE autocompletion, you can either implement the static method
9697
```php
9798
class Action extends Enum
9899
{
99-
const VIEW = 'view';
100+
private const VIEW = 'view';
100101

101102
/**
102103
* @return Action
@@ -116,8 +117,8 @@ or you can use phpdoc (this is supported in PhpStorm for example):
116117
*/
117118
class Action extends Enum
118119
{
119-
const VIEW = 'view';
120-
const EDIT = 'edit';
120+
private const VIEW = 'view';
121+
private const EDIT = 'edit';
121122
}
122123
```
123124

0 commit comments

Comments
 (0)