Skip to content

Recommend using private constants #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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