Skip to content

Commit 4b06350

Browse files
committed
The helper file is no longer autoloaded
1 parent ac253d9 commit 4b06350

File tree

7 files changed

+98
-91
lines changed

7 files changed

+98
-91
lines changed

CHANGELOG.md

+26
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,31 @@
11
# CHANGELOG
22

3+
## 2.x to 3.0
4+
5+
### New requirements
6+
7+
None
8+
9+
### New features
10+
11+
None
12+
13+
### Backward Incompatible Changes
14+
15+
The file with the helper functions is no longer included in the autoload. You
16+
need to include the file `lib/helpers.php` in your `composer.json` if you want
17+
to continue using these functions.
18+
19+
### Deprecated Features
20+
21+
None
22+
23+
### Other Changes
24+
25+
None
26+
27+
28+
329
## 1.x to 2.0
430

531
### New requirements

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ $inflector->is_uncountable("weather"); // true
120120
$inflector->is_uncountable("cat"); // false
121121
```
122122

123-
Helpers makes it easy to use default locale inflections.
123+
Helpers make it easy to use default locale inflections.
124124

125125
```php
126126
<?php
@@ -133,6 +133,12 @@ echo singularize('lærere', 'nb'); // "lærer"
133133
echo pluralize('üçgen', 'tr'); // "üçgenler"
134134
```
135135

136+
> [!WARNING]
137+
> Since v3.0 the file with the helper functions is no longer included in the
138+
> autoload.
139+
> You need to include the file `lib/helpers.php` in your `composer.json` if
140+
> you want to continue using these functions.
141+
136142

137143
## About inflections
138144

composer.json

+50-43
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,53 @@
11
{
2-
"name": "icanboogie/inflector",
3-
"type": "library",
4-
"description": "Multilingual inflector that transforms words from singular to plural, underscore to camel case, and more.",
5-
"keywords": [ "inflect", "pluralize", "singularize", "camelize", "underscore", "hyphenate", "multilingual" ],
6-
"homepage": "http://icanboogie.org/",
7-
"license": "BSD-3-Clause",
8-
"authors": [
9-
{
10-
"name": "Olivier Laviale",
11-
"email": "[email protected]",
12-
"homepage": "http://www.weirdog.com/",
13-
"role" : "Developer"
14-
}
15-
],
16-
"support": {
17-
"issues": "https://github.com/ICanBoogie/Inflector/issues",
18-
"source": "https://github.com/ICanBoogie/Inflector"
19-
},
20-
"config": {
21-
"sort-packages": true
22-
},
23-
"require": {
24-
"php": ">=7.1",
25-
"ext-mbstring": "*"
26-
},
27-
"require-dev": {
28-
"icanboogie/common": "^2.1",
29-
"phpstan/phpstan": "^0.12.100|^2.0",
30-
"phpunit/phpunit": "^7.5.20|^11.4"
31-
},
32-
"conflict": {
33-
"icanboogie/common": "<2.0"
34-
},
35-
"autoload": {
36-
"psr-4": {
37-
"ICanBoogie\\": "lib/"
38-
},
39-
"files": [ "lib/helpers.php" ]
40-
},
41-
"autoload-dev": {
42-
"psr-4": {
43-
"Tests\\ICanBoogie\\": "tests"
44-
}
2+
"name": "icanboogie/inflector",
3+
"type": "library",
4+
"description": "Multilingual inflector that transforms words from singular to plural, underscore to camel case, and more.",
5+
"keywords": [
6+
"inflect",
7+
"pluralize",
8+
"singularize",
9+
"camelize",
10+
"underscore",
11+
"hyphenate",
12+
"multilingual"
13+
],
14+
"homepage": "https://icanboogie.org/",
15+
"license": "BSD-3-Clause",
16+
"authors": [
17+
{
18+
"name": "Olivier Laviale",
19+
"email": "[email protected]",
20+
"homepage": "https://olvlvl.com/",
21+
"role": "Developer"
4522
}
23+
],
24+
"support": {
25+
"issues": "https://github.com/ICanBoogie/Inflector/issues",
26+
"source": "https://github.com/ICanBoogie/Inflector"
27+
},
28+
"config": {
29+
"sort-packages": true
30+
},
31+
"require": {
32+
"php": ">=7.1",
33+
"ext-mbstring": "*"
34+
},
35+
"require-dev": {
36+
"icanboogie/common": "^2.1",
37+
"phpstan/phpstan": "^1.4|^2.0",
38+
"phpunit/phpunit": "^7.5.20|^11.4"
39+
},
40+
"conflict": {
41+
"icanboogie/common": "<2.0"
42+
},
43+
"autoload": {
44+
"psr-4": {
45+
"ICanBoogie\\": "lib/"
46+
}
47+
},
48+
"autoload-dev": {
49+
"psr-4": {
50+
"Tests\\ICanBoogie\\": "tests"
51+
}
52+
}
4653
}

lib/Inflections.php

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
<?php
22

3-
/*
4-
* This file is part of the ICanBoogie package.
5-
*
6-
* (c) Olivier Laviale <[email protected]>
7-
*
8-
* For the full copyright and license information, please view the LICENSE
9-
* file that was distributed with this source code.
10-
*/
11-
123
namespace ICanBoogie;
134

145
use InvalidArgumentException;
@@ -38,7 +29,7 @@ final class Inflections
3829
* Note: Inflections are shared for the same locale. If you need to alter an instance you
3930
* MUST clone it first, otherwise your changes will affect others.
4031
*/
41-
public static function get(string $locale = INFLECTOR_DEFAULT_LOCALE): Inflections
32+
public static function get(string $locale = Inflector::DEFAULT_LOCALE): Inflections
4233
{
4334
if (isset(self::$inflections[$locale])) {
4435
return self::$inflections[$locale];

lib/Inflector.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ class Inflector
2828
{
2929
/**
3030
* Default inflector locale.
31-
*
32-
* Alias to {@see INFLECTOR_DEFAULT_LOCALE}.
3331
*/
34-
public const DEFAULT_LOCALE = INFLECTOR_DEFAULT_LOCALE;
32+
public const DEFAULT_LOCALE = 'en';
3533

3634
/**
3735
* {@see camelize()} option to downcase the first letter.

lib/helpers.php

+12-23
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,11 @@
11
<?php
22

3-
/*
4-
* This file is part of the ICanBoogie package.
5-
*
6-
* (c) Olivier Laviale <[email protected]>
7-
*
8-
* For the full copyright and license information, please view the LICENSE
9-
* file that was distributed with this source code.
10-
*/
11-
123
namespace ICanBoogie;
134

14-
/**
15-
* Default inflector locale.
16-
*/
17-
const INFLECTOR_DEFAULT_LOCALE = 'en';
18-
195
// Avoid conflicts with ICanBoogie/Common
206
if (!function_exists(__NAMESPACE__ . '\downcase')) {
217
/**
22-
* Returns an lowercase string.
8+
* Returns a lowercase string.
239
*/
2410
function downcase(string $str): string
2511
{
@@ -61,55 +47,58 @@ function capitalize(string $str, bool $preserve_str_end = false): string
6147
/**
6248
* Forwards calls to `Inflector::get()->pluralize()`.
6349
*/
64-
function pluralize(string $word, string $locale = INFLECTOR_DEFAULT_LOCALE): string
50+
function pluralize(string $word, string $locale = Inflector::DEFAULT_LOCALE): string
6551
{
6652
return Inflector::get($locale)->pluralize($word);
6753
}
6854

6955
/**
7056
* Forwards calls to `Inflector::get()->singularize()`.
7157
*/
72-
function singularize(string $word, string $locale = INFLECTOR_DEFAULT_LOCALE): string
58+
function singularize(string $word, string $locale = Inflector::DEFAULT_LOCALE): string
7359
{
7460
return Inflector::get($locale)->singularize($word);
7561
}
7662

7763
/**
7864
* Forwards calls to `Inflector::get()->camelize()`.
7965
*/
80-
function camelize(string $str, bool $uppercase_first_letter = false, string $locale = INFLECTOR_DEFAULT_LOCALE): string
81-
{
66+
function camelize(
67+
string $str,
68+
bool $uppercase_first_letter = false,
69+
string $locale = Inflector::DEFAULT_LOCALE
70+
): string {
8271
return Inflector::get($locale)->camelize($str, $uppercase_first_letter);
8372
}
8473

8574
/**
8675
* Forwards calls to `Inflector::get()->underscore()`.
8776
*/
88-
function underscore(string $camel_cased_word, string $locale = INFLECTOR_DEFAULT_LOCALE): string
77+
function underscore(string $camel_cased_word, string $locale = Inflector::DEFAULT_LOCALE): string
8978
{
9079
return Inflector::get($locale)->underscore($camel_cased_word);
9180
}
9281

9382
/**
9483
* Forwards calls to `Inflector::get()->hyphenate()`.
9584
*/
96-
function hyphenate(string $str, string $locale = INFLECTOR_DEFAULT_LOCALE): string
85+
function hyphenate(string $str, string $locale = Inflector::DEFAULT_LOCALE): string
9786
{
9887
return Inflector::get($locale)->hyphenate($str);
9988
}
10089

10190
/**
10291
* Forwards calls to `Inflector::get()->humanize()`.
10392
*/
104-
function humanize(string $lower_case_and_underscored_word, string $locale = INFLECTOR_DEFAULT_LOCALE): string
93+
function humanize(string $lower_case_and_underscored_word, string $locale = Inflector::DEFAULT_LOCALE): string
10594
{
10695
return Inflector::get($locale)->humanize($lower_case_and_underscored_word);
10796
}
10897

10998
/**
11099
* Forwards calls to `Inflector::get()->titleize()`.
111100
*/
112-
function titleize(string $str, string $locale = INFLECTOR_DEFAULT_LOCALE): string
101+
function titleize(string $str, string $locale = Inflector::DEFAULT_LOCALE): string
113102
{
114103
return Inflector::get($locale)->titleize($str);
115104
}

tests/bootstrap.php

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
11
<?php
22

3-
/*
4-
* This file is part of the ICanBoogie package.
5-
*
6-
* (c) Olivier Laviale <[email protected]>
7-
*
8-
* For the full copyright and license information, please view the LICENSE
9-
* file that was distributed with this source code.
10-
*/
11-
123
require __DIR__ . '/../vendor/autoload.php';
13-
14-
mb_internal_encoding('UTF-8');
4+
require __DIR__ . '/../lib/helpers.php';

0 commit comments

Comments
 (0)