Skip to content

Commit d7d74ce

Browse files
authored
Merge pull request #8162 from cakephp/docs/add-method-headers-constants-functions
Add function headers to global constants and functions documentation
2 parents c8bcc0e + 697e9be commit d7d74ce

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

docs/en/core-libraries/global-constants-and-functions.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ require CAKE . 'functions.php';
2424
To your application's `config/bootstrap.php`. Doing this will load global
2525
aliases for *all* functions listed below.
2626

27+
### __()
28+
2729
`function` **__(string $string_id, [$formatArgs])**
2830

2931
This function handles localization in CakePHP applications. The
@@ -45,6 +47,8 @@ __('You have {unread} unread messages', ['unread' => $number]);
4547
> [Internationalization & Localization](../core-libraries/internationalization-and-localization) section for
4648
> more information.
4749
50+
### __d()
51+
4852
`function` **__d(string $domain, string $msg, mixed $args = null)**
4953

5054
Allows you to override the current domain for a single message lookup.
@@ -55,12 +59,16 @@ Useful when internationalizing a plugin:
5559
> [!NOTE]
5660
> Make sure to use the underscored version of the plugin name here as domain.
5761
62+
### __dn()
63+
5864
`function` **__dn(string $domain, string $singular, string $plural, integer $count, mixed $args = null)**
5965

6066
Allows you to override the current domain for a single plural message
6167
lookup. Returns correct plural form of message identified by `$singular`
6268
and `$plural` for count `$count` from domain `$domain`.
6369

70+
### __dx()
71+
6472
`function` **__dx(string $domain, string $context, string $msg, mixed $args = null)**
6573

6674
Allows you to override the current domain for a single message lookup. It
@@ -69,6 +77,8 @@ also allows you to specify a context.
6977
The context is a unique identifier for the translations string that makes it
7078
unique within the same domain.
7179

80+
### __dxn()
81+
7282
`function` **__dxn(string $domain, string $context, string $singular, string $plural, integer $count, mixed $args = null)**
7383

7484
Allows you to override the current domain for a single plural message
@@ -80,17 +90,23 @@ for plural messages dependent on the count.
8090
The context is a unique identifier for the translations string that makes it
8191
unique within the same domain.
8292

93+
### __n()
94+
8395
`function` **__n(string $singular, string $plural, integer $count, mixed $args = null)**
8496

8597
Returns correct plural form of message identified by `$singular` and
8698
`$plural` for count `$count`. Some languages have more than one form for
8799
plural messages dependent on the count.
88100

101+
### __x()
102+
89103
`function` **__x(string $context, string $msg, mixed $args = null)**
90104

91105
The context is a unique identifier for the translations string that makes it
92106
unique within the same domain.
93107

108+
### __xn()
109+
94110
`function` **__xn(string $context, string $singular, string $plural, integer $count, mixed $args = null)**
95111

96112
Returns correct plural form of message identified by `$singular` and
@@ -101,12 +117,16 @@ messages dependent on the count.
101117
The context is a unique identifier for the translations string that makes it
102118
unique within the same domain.
103119

120+
### collection()
121+
104122
`function` **collection(mixed $items)**
105123

106124
Convenience wrapper for instantiating a new `Cake\Collection\Collection`
107125
object, wrapping the passed argument. The `$items` parameter takes either
108126
a `Traversable` object or an array.
109127

128+
### debug()
129+
110130
`function` **debug(mixed $var, boolean $showHtml = null, $showFrom = true)**
111131

112132
If the core `$debug` variable is `true`, `$var` is printed out.
@@ -115,25 +135,33 @@ browser-friendly. If `$showFrom` is not set to `false`, the debug output
115135
will start with the line from which it was called. Also see
116136
[Debugging](../development/debugging)
117137

138+
### dd()
139+
118140
`function` **dd(mixed $var, boolean $showHtml = null)**
119141

120142
It behaves like `debug()`, but execution is also halted.
121143
If the core `$debug` variable is `true`, `$var` is printed.
122144
If `$showHTML` is `true` or left as `null`, the data is rendered to be
123145
browser-friendly. Also see [Debugging](../development/debugging)
124146

147+
### pr()
148+
125149
`function` **pr(mixed $var)**
126150

127151
Convenience wrapper for `print_r()`, with the addition of
128152
wrapping `<pre>` tags around the output.
129153

154+
### pj()
155+
130156
`function` **pj(mixed $var)**
131157

132158
JSON pretty print convenience function, with the addition of
133159
wrapping `<pre>` tags around the output.
134160

135161
It is meant for debugging the JSON representation of objects and arrays.
136162

163+
### env()
164+
137165
`function` **env(string $key, string $default = null)**
138166

139167
Gets an environment variable from available sources. Used as a backup if
@@ -144,17 +172,23 @@ unsupporting servers. In fact, it's a good idea to always use `env()`
144172
instead of `$_SERVER` or `getenv()` (especially if you plan to
145173
distribute the code), since it's a full emulation wrapper.
146174

175+
### h()
176+
147177
`function` **h(string $text, boolean $double = true, string $charset = null)**
148178

149179
Convenience wrapper for `htmlspecialchars()`.
150180

181+
### pluginSplit()
182+
151183
`function` **pluginSplit(string $name, boolean $dotAppend = false, string $plugin = null)**
152184

153185
Splits a dot syntax plugin name into its plugin and class name. If `$name`
154186
does not have a dot, then index 0 will be `null`.
155187

156188
Commonly used like `list($plugin, $name) = pluginSplit('Users.User');`
157189

190+
### namespaceSplit()
191+
158192
`function` **namespaceSplit(string $class)**
159193

160194
Split the namespace from the classname.

0 commit comments

Comments
 (0)