Skip to content

Commit

Permalink
Recommend using private constants
Browse files Browse the repository at this point in the history
  • Loading branch information
mnapoli authored Jan 10, 2018
1 parent 955f570 commit cedc9f7
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ use MyCLabs\Enum\Enum;
*/
class Action extends Enum
{
const VIEW = 'view';
const EDIT = 'edit';
private const VIEW = 'view';
private const EDIT = 'edit';
}
```

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

## Usage

Expand Down Expand Up @@ -80,8 +81,8 @@ Static methods:
```php
class Action extends Enum
{
const VIEW = 'view';
const EDIT = 'edit';
private const VIEW = 'view';
private const EDIT = 'edit';
}

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

/**
* @return Action
Expand All @@ -116,8 +117,8 @@ or you can use phpdoc (this is supported in PhpStorm for example):
*/
class Action extends Enum
{
const VIEW = 'view';
const EDIT = 'edit';
private const VIEW = 'view';
private const EDIT = 'edit';
}
```

Expand Down

0 comments on commit cedc9f7

Please sign in to comment.