Skip to content

Commit 770192a

Browse files
committed
Use Symfony's deprecation function to trigger runtime deprecations with additional package information
1 parent d5d59c5 commit 770192a

File tree

2 files changed

+37
-42
lines changed

2 files changed

+37
-42
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"homepage": "https://github.com/joomla-framework/string",
77
"license": "GPL-2.0-or-later",
88
"require": {
9-
"php": "^7.2.5"
9+
"php": "^7.2.5",
10+
"symfony/deprecation-contracts": "^2.1"
1011
},
1112
"require-dev": {
1213
"doctrine/inflector": "^1.2",

src/Inflector.php

Lines changed: 35 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,12 @@ public function addCountableRule($data)
111111
*/
112112
public function addWord($singular, $plural = '')
113113
{
114-
@trigger_error(
115-
sprintf(
116-
'%1$s() is deprecated and will be removed in 3.0, use %2$s::rules() instead.',
117-
__METHOD__,
118-
DoctrineInflector::class
119-
),
120-
E_USER_DEPRECATED
114+
trigger_deprecation(
115+
'joomla/string',
116+
'2.0.0',
117+
'%s() is deprecated and will be removed in 3.0, use %s::rules() instead.',
118+
__METHOD__,
119+
DoctrineInflector::class
121120
);
122121

123122
if ($plural !== '')
@@ -168,13 +167,12 @@ public function addWord($singular, $plural = '')
168167
*/
169168
public function addPluraliseRule($data)
170169
{
171-
@trigger_error(
172-
sprintf(
173-
'%1$s() is deprecated and will be removed in 3.0, use %2$s::rules() instead.',
174-
__METHOD__,
175-
DoctrineInflector::class
176-
),
177-
E_USER_DEPRECATED
170+
trigger_deprecation(
171+
'joomla/string',
172+
'2.0.0',
173+
'%s() is deprecated and will be removed in 3.0, use %s::rules() instead.',
174+
__METHOD__,
175+
DoctrineInflector::class
178176
);
179177

180178
$this->addRule($data, 'plural');
@@ -194,13 +192,12 @@ public function addPluraliseRule($data)
194192
*/
195193
public function addSingulariseRule($data)
196194
{
197-
@trigger_error(
198-
sprintf(
199-
'%1$s() is deprecated and will be removed in 3.0, use %2$s::rules() instead.',
200-
__METHOD__,
201-
DoctrineInflector::class
202-
),
203-
E_USER_DEPRECATED
195+
trigger_deprecation(
196+
'joomla/string',
197+
'2.0.0',
198+
'%s() is deprecated and will be removed in 3.0, use %s::rules() instead.',
199+
__METHOD__,
200+
DoctrineInflector::class
204201
);
205202

206203
$this->addRule($data, 'singular');
@@ -220,12 +217,11 @@ public function addSingulariseRule($data)
220217
*/
221218
public static function getInstance($new = false)
222219
{
223-
@trigger_error(
224-
sprintf(
225-
'%1$s() is deprecated and will be removed in 3.0.',
226-
__METHOD__
227-
),
228-
E_USER_DEPRECATED
220+
trigger_deprecation(
221+
'joomla/string',
222+
'2.0.0',
223+
'%s() is deprecated and will be removed in 3.0.',
224+
__METHOD__
229225
);
230226

231227
if ($new)
@@ -295,13 +291,12 @@ public function isSingular($word)
295291
*/
296292
public function toPlural($word)
297293
{
298-
@trigger_error(
299-
sprintf(
300-
'%1$s() is deprecated and will be removed in 3.0, use %2$s::pluralize() instead.',
301-
__METHOD__,
302-
DoctrineInflector::class
303-
),
304-
E_USER_DEPRECATED
294+
trigger_deprecation(
295+
'joomla/string',
296+
'2.0.0',
297+
'%s() is deprecated and will be removed in 3.0, use %s::pluralize() instead.',
298+
__METHOD__,
299+
DoctrineInflector::class
305300
);
306301

307302
return static::pluralize($word);
@@ -319,13 +314,12 @@ public function toPlural($word)
319314
*/
320315
public function toSingular($word)
321316
{
322-
@trigger_error(
323-
sprintf(
324-
'%1$s() is deprecated and will be removed in 3.0, use %2$s::singularize() instead.',
325-
__METHOD__,
326-
DoctrineInflector::class
327-
),
328-
E_USER_DEPRECATED
317+
trigger_deprecation(
318+
'joomla/string',
319+
'2.0.0',
320+
'%s() is deprecated and will be removed in 3.0, use %s::singularize() instead.',
321+
__METHOD__,
322+
DoctrineInflector::class
329323
);
330324

331325
return static::singularize($word);

0 commit comments

Comments
 (0)