Skip to content
Merged
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions en/contributing/cakephp-coding-conventions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,17 @@ underscore character, for example::

define('LONG_NAMED_CONSTANT', 2);

Enums
-----

Enum cases are defined in ``CamelCase`` style::

enum ArticleStatus: string
{
case Published = 'Y';
case NotPublishedYet = 'N';
}

Careful when using empty()/isset()
==================================

Expand Down
4 changes: 4 additions & 0 deletions en/intro/conventions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ Entity class names are singular CamelCased and have no suffix. ``User``,
matching the ``users``, ``menu_links`` and ``user_favorite_pages``
tables respectively.

Enum class names should use a ``{Entity}{Column}`` convention, and enum cases
should use CamelCased names.


View Conventions
================

Expand Down
10 changes: 8 additions & 2 deletions en/orm/database-basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -479,10 +479,16 @@ Where ``ArticleStatus`` contains something like::

enum ArticleStatus: string
{
case PUBLISHED = 'Y';
case UNPUBLISHED = 'N';
case Published = 'Y';
case Unpublished = 'N';
}

CakePHP recommends a few conventions for enums:

- Enum classnames should follow ``{Entity}{ColumnName}`` style to enable
detection while running bake and to aid with project consistency.
- Enum cases should use CamelCase style.

.. _adding-custom-database-types:

Adding Custom Types
Expand Down