Skip to content

Commit d83f4ff

Browse files
committed
Removing deprecated calls to doctrine/inflector API
1 parent b0246c5 commit d83f4ff

File tree

5 files changed

+63
-49
lines changed

5 files changed

+63
-49
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"mouf/schema-analyzer": "^1.1.4",
2424
"doctrine/dbal": "^2.9.2",
2525
"psr/log": "~1.0",
26-
"doctrine/inflector": "~1.0",
26+
"doctrine/inflector": "^1.4.3 || ^2",
2727
"beberlei/porpaginas": "~1.0",
2828
"mouf/classname-mapper": "~1.0",
2929
"doctrine/cache": "^1.6",
@@ -58,7 +58,7 @@
5858
"mouf/database.tdbm": "~5.0.0"
5959
},
6060
"suggest" : {
61-
"ext/weakref" : "Allows efficient memory management. Useful for batches."
61+
"ext/weakref" : "Allows efficient memory management (in PHP 7.2 only). Useful for batches."
6262
},
6363
"autoload" : {
6464
"psr-4" : {

src/Utils/DefaultNamingStrategy.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
namespace TheCodingMachine\TDBM\Utils;
66

7-
use Doctrine\Common\Inflector\Inflector;
87
use Doctrine\DBAL\Schema\AbstractSchemaManager;
9-
use Doctrine\DBAL\Schema\Column;
108
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
119
use Doctrine\DBAL\Schema\Schema;
10+
use Doctrine\Inflector\Inflector;
11+
use Doctrine\Inflector\InflectorFactory;
1212
use TheCodingMachine\TDBM\TDBMException;
1313
use TheCodingMachine\TDBM\Utils\Annotation\AnnotationParser;
1414
use TheCodingMachine\TDBM\Utils\Annotation\Bean;
@@ -40,11 +40,16 @@ class DefaultNamingStrategy extends AbstractNamingStrategy
4040
* @var Schema
4141
*/
4242
private $schema;
43+
/**
44+
* @var Inflector
45+
*/
46+
private $inflector;
4347

4448
public function __construct(AnnotationParser $annotationParser, AbstractSchemaManager $schemaManager)
4549
{
4650
$this->annotationParser = $annotationParser;
4751
$this->schemaManager = $schemaManager;
52+
$this->inflector = InflectorFactory::create()->build();
4853
}
4954

5055
/**
@@ -233,7 +238,7 @@ private function toSingularCamelCase(string $str): string
233238

234239
$str = '';
235240
foreach ($tokens as $token) {
236-
$str .= ucfirst(Inflector::singularize($token));
241+
$str .= ucfirst($this->inflector->singularize($token));
237242
}
238243

239244
return $str;

src/Utils/TDBMDaoGenerator.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33

44
namespace TheCodingMachine\TDBM\Utils;
55

6-
use Doctrine\Common\Inflector\Inflector;
6+
use Doctrine\Inflector\Inflector;
77
use Doctrine\DBAL\Schema\Schema;
88
use Doctrine\DBAL\Schema\Table;
99
use Doctrine\DBAL\Types\Type;
10+
use Doctrine\Inflector\InflectorFactory;
1011
use Psr\Container\ContainerInterface;
1112
use TheCodingMachine\TDBM\Schema\ForeignKeys;
1213
use TheCodingMachine\TDBM\TDBMService;
@@ -51,6 +52,10 @@ class TDBMDaoGenerator
5152
* @var ConfigurationInterface
5253
*/
5354
private $configuration;
55+
/**
56+
* @var Inflector
57+
*/
58+
private static $inflector;
5459

5560
/**
5661
* Constructor.
@@ -470,7 +475,11 @@ public static function toCamelCase(string $str) : string
470475
*/
471476
public static function toSingular(string $str): string
472477
{
473-
return Inflector::singularize($str);
478+
if (self::$inflector === null) {
479+
self::$inflector = InflectorFactory::create()->build();
480+
}
481+
482+
return self::$inflector->singularize($str);
474483
}
475484

476485
/**

vendor-bin/couscous/composer.lock

Lines changed: 24 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor-bin/require-checker/composer.lock

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)