Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doctrine orm version bump #76

Merged
merged 5 commits into from
Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
strategy:
matrix:
php: ['7.2', '7.3', '7.4', '8.0']
orm: ['2.6.0', '2.7.0', '2.8.0', '2.9.5']
orm: ['2.6', '2.7', '2.8', '2.9', '2.10', '2.11']
exclude:
- php: '8.0'
orm: '2.6.0'
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
],
"require": {
"php": "^7.2|^8.0",
"doctrine/orm": "~2.6.0|~2.7.0|~2.8.0|~2.9.5",
"doctrine/inflector": "^1.1",
"doctrine/orm": "^2.6",
"doctrine/inflector": "^1.4|^2.0",
"doctrine/persistence": "^1.3.5|^2.0"
eigan marked this conversation as resolved.
Show resolved Hide resolved
},
"require-dev": {
Expand Down
4 changes: 2 additions & 2 deletions src/Builders/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace LaravelDoctrine\Fluent\Builders;

use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use InvalidArgumentException;
use LaravelDoctrine\Fluent\Extensions\Gedmo\GedmoBuilderHints;
use LaravelDoctrine\Fluent\Fluent;
Expand Down Expand Up @@ -153,7 +153,7 @@ public function isEmbeddedClass()
*/
protected function setArray($name, callable $callback = null)
{
return $this->field(Type::TARRAY, $name, $callback);
return $this->field(Types::ARRAY, $name, $callback);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions src/Builders/Traits/Dates.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace LaravelDoctrine\Fluent\Builders\Traits;

use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;

trait Dates
{
Expand All @@ -11,31 +11,31 @@ trait Dates
*/
public function date($name, callable $callback = null)
{
return $this->field(Type::DATE, $name, $callback);
return $this->field(Types::DATE_MUTABLE, $name, $callback);
}

/**
* {@inheritdoc}
*/
public function dateTime($name, callable $callback = null)
{
return $this->field(Type::DATETIME, $name, $callback);
return $this->field(Types::DATETIME_MUTABLE, $name, $callback);
}

/**
* {@inheritdoc}
*/
public function dateTimeTz($name, callable $callback = null)
{
return $this->field(Type::DATETIMETZ, $name, $callback);
return $this->field(Types::DATETIMETZ_MUTABLE, $name, $callback);
}

/**
* {@inheritdoc}
*/
public function time($name, callable $callback = null)
{
return $this->field(Type::TIME, $name, $callback);
return $this->field(Types::TIME_MUTABLE, $name, $callback);
}

/**
Expand Down
30 changes: 15 additions & 15 deletions src/Builders/Traits/Fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace LaravelDoctrine\Fluent\Builders\Traits;

use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use LaravelDoctrine\Fluent\Buildable;
use LaravelDoctrine\Fluent\Builders\Field;

Expand All @@ -25,111 +25,111 @@ public function field($type, $name, callable $callback = null)
*/
public function string($name, callable $callback = null)
{
return $this->field(Type::STRING, $name, $callback);
return $this->field(Types::STRING, $name, $callback);
}

/**
* {@inheritdoc}
*/
public function text($name, callable $callback = null)
{
return $this->field(Type::TEXT, $name, $callback);
return $this->field(Types::TEXT, $name, $callback);
}

/**
* {@inheritdoc}
*/
public function integer($name, callable $callback = null)
{
return $this->field(Type::INTEGER, $name, $callback);
return $this->field(Types::INTEGER, $name, $callback);
}

/**
* {@inheritdoc}
*/
public function smallInteger($name, callable $callback = null)
{
return $this->field(Type::SMALLINT, $name, $callback);
return $this->field(Types::SMALLINT, $name, $callback);
}

/**
* {@inheritdoc}
*/
public function bigInteger($name, callable $callback = null)
{
return $this->field(Type::BIGINT, $name, $callback);
return $this->field(Types::BIGINT, $name, $callback);
}

/**
* {@inheritdoc}
*/
public function guid($name, callable $callback = null)
{
return $this->field(Type::GUID, $name, $callback);
return $this->field(Types::GUID, $name, $callback);
}

/**
* {@inheritdoc}
*/
public function blob($name, callable $callback = null)
{
return $this->field(Type::BLOB, $name, $callback);
return $this->field(Types::BLOB, $name, $callback);
}

/**
* {@inheritdoc}
*/
public function object($name, callable $callback = null)
{
return $this->field(Type::OBJECT, $name, $callback);
return $this->field(Types::OBJECT, $name, $callback);
}

/**
* {@inheritdoc}
*/
public function float($name, callable $callback = null)
{
return $this->field(Type::FLOAT, $name, $callback)->precision(8)->scale(2);
return $this->field(Types::FLOAT, $name, $callback)->precision(8)->scale(2);
}

/**
* {@inheritdoc}
*/
public function decimal($name, callable $callback = null)
{
return $this->field(Type::DECIMAL, $name, $callback)->precision(8)->scale(2);
return $this->field(Types::DECIMAL, $name, $callback)->precision(8)->scale(2);
}

/**
* {@inheritdoc}
*/
public function boolean($name, callable $callback = null)
{
return $this->field(Type::BOOLEAN, $name, $callback);
return $this->field(Types::BOOLEAN, $name, $callback);
}

/**
* {@inheritdoc}
*/
public function simpleArray($name, callable $callback = null)
{
return $this->field(Type::SIMPLE_ARRAY, $name, $callback);
return $this->field(Types::SIMPLE_ARRAY, $name, $callback);
}

/**
* {@inheritdoc}
*/
public function jsonArray($name, callable $callback = null)
{
return $this->field(Type::JSON_ARRAY, $name, $callback);
return $this->field(Types::JSON, $name, $callback);
}

/**
* {@inheritdoc}
*/
public function binary($name, callable $callback = null)
{
return $this->field(Type::BINARY, $name, $callback)->nullable();
return $this->field(Types::BINARY, $name, $callback)->nullable();
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Builders/Traits/Relations.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace LaravelDoctrine\Fluent\Builders\Traits;

use Doctrine\Common\Inflector\Inflector;
use Doctrine\Inflector\InflectorFactory;
use LaravelDoctrine\Fluent\Buildable;
use LaravelDoctrine\Fluent\Relations\ManyToMany;
use LaravelDoctrine\Fluent\Relations\ManyToOne;
Expand Down Expand Up @@ -128,7 +128,7 @@ public function addRelation(Relation $relation, callable $callback = null)
*/
protected function guessSingularField($entity, $field = null)
{
return $field ?: Inflector::singularize(
return $field ?: (InflectorFactory::create()->build())->singularize(
lcfirst(basename(str_replace('\\', '/', $entity)))
);
}
Expand All @@ -141,7 +141,7 @@ protected function guessSingularField($entity, $field = null)
*/
protected function guessPluralField($entity, $field = null)
{
return $field ?: Inflector::pluralize($this->guessSingularField($entity));
return $field ?: (InflectorFactory::create()->build())->pluralize($this->guessSingularField($entity));
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Relations/AbstractRelation.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace LaravelDoctrine\Fluent\Relations;

use BadMethodCallException;
use Doctrine\Common\Inflector\Inflector;
use Doctrine\Inflector\InflectorFactory;
use Doctrine\ORM\Mapping\Builder\AssociationBuilder;
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
use Doctrine\ORM\Mapping\NamingStrategy;
Expand Down Expand Up @@ -86,7 +86,7 @@ abstract protected function createAssociation(ClassMetadataBuilder $builder, $re
public function cascade(array $cascade)
{
foreach ($cascade as $name) {
$method = 'cascade'.Inflector::classify(strtolower($name));
$method = 'cascade'.(InflectorFactory::create()->build())->classify(strtolower($name));

if (!method_exists($this->association, $method)) {
throw new InvalidArgumentException('Cascade ['.$name.'] does not exist');
Expand All @@ -105,7 +105,7 @@ public function cascade(array $cascade)
*/
public function fetch($strategy)
{
$method = 'fetch'.Inflector::classify(strtolower($strategy));
$method = 'fetch'.(InflectorFactory::create()->build())->classify(strtolower($strategy));

if (!method_exists($this->association, $method)) {
throw new InvalidArgumentException('Fetch ['.$strategy.'] does not exist');
Expand Down
51 changes: 26 additions & 25 deletions tests/Builders/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Tests\Builders;

use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
use Doctrine\ORM\Mapping\ClassMetadataInfo;
use Doctrine\ORM\Mapping\DefaultNamingStrategy;
Expand Down Expand Up @@ -56,32 +57,32 @@ class BuilderTest extends TestCase
* @var array
*/
protected $types = [
'string' => Type::STRING,
'text' => Type::TEXT,
'integer' => Type::INTEGER,
'smallInteger' => Type::SMALLINT,
'bigInteger' => Type::BIGINT,
'float' => Type::FLOAT,
'decimal' => Type::DECIMAL,
'object' => Type::OBJECT,
'boolean' => Type::BOOLEAN,
'jsonArray' => Type::JSON_ARRAY,
'date' => Type::DATE,
'dateTime' => Type::DATETIME,
'dateTimeTz' => Type::DATETIMETZ,
'time' => Type::TIME,
'string' => Types::STRING,
'text' => Types::TEXT,
'integer' => Types::INTEGER,
'smallInteger' => Types::SMALLINT,
'bigInteger' => Types::BIGINT,
'float' => Types::FLOAT,
'decimal' => Types::DECIMAL,
'object' => Types::OBJECT,
'boolean' => Types::BOOLEAN,
'jsonArray' => Types::JSON,
'date' => Types::DATE_MUTABLE,
'dateTime' => Types::DATETIME_MUTABLE,
'dateTimeTz' => Types::DATETIMETZ_MUTABLE,
'time' => Types::TIME_MUTABLE,
'carbonDateTime' => 'carbondatetime',
'carbonDateTimeTz' => 'carbondatetimetz',
'carbonDate' => 'carbondate',
'carbonTime' => 'carbontime',
'zendDate' => 'zenddate',
'timestamp' => 'carbondatetime',
'timestampTz' => 'carbondatetimetz',
'binary' => Type::BINARY,
'guid' => Type::GUID,
'blob' => Type::BLOB,
'array' => Type::TARRAY,
'simpleArray' => Type::SIMPLE_ARRAY,
'binary' => Types::BINARY,
'guid' => Types::GUID,
'blob' => Types::BLOB,
'array' => Types::ARRAY,
'simpleArray' => Types::SIMPLE_ARRAY,
];

public static function setUpBeforeClass(): void
Expand Down Expand Up @@ -337,7 +338,7 @@ public function test_can_add_increments_to_entity()

$this->assertContains('id', $this->fluent->getClassMetadata()->getIdentifier());
$this->assertContains('id', $this->fluent->getClassMetadata()->getFieldNames());
$this->assertEquals(Type::INTEGER, $this->fluent->getClassMetadata()->getFieldMapping('id')['type']);
$this->assertEquals(Types::INTEGER, $this->fluent->getClassMetadata()->getFieldMapping('id')['type']);
}

public function test_can_add_small_increments_to_entity()
Expand All @@ -353,7 +354,7 @@ public function test_can_add_small_increments_to_entity()

$this->assertContains('id', $this->fluent->getClassMetadata()->getIdentifier());
$this->assertContains('id', $this->fluent->getClassMetadata()->getFieldNames());
$this->assertEquals(Type::SMALLINT, $this->fluent->getClassMetadata()->getFieldMapping('id')['type']);
$this->assertEquals(Types::SMALLINT, $this->fluent->getClassMetadata()->getFieldMapping('id')['type']);
}

public function test_can_add_big_increments_to_entity()
Expand All @@ -369,7 +370,7 @@ public function test_can_add_big_increments_to_entity()

$this->assertContains('id', $this->fluent->getClassMetadata()->getIdentifier());
$this->assertContains('id', $this->fluent->getClassMetadata()->getFieldNames());
$this->assertEquals(Type::BIGINT, $this->fluent->getClassMetadata()->getFieldMapping('id')['type']);
$this->assertEquals(Types::BIGINT, $this->fluent->getClassMetadata()->getFieldMapping('id')['type']);
}

public function test_cannot_add_increments_to_embeddable()
Expand Down Expand Up @@ -460,7 +461,7 @@ public function test_can_add_unsigned_integer_to_entity()
$field->getBuilder()->build();

$this->assertContains('id', $this->fluent->getClassMetadata()->getFieldNames());
$this->assertEquals(Type::INTEGER, $this->fluent->getClassMetadata()->getFieldMapping('id')['type']);
$this->assertEquals(Types::INTEGER, $this->fluent->getClassMetadata()->getFieldMapping('id')['type']);
$this->assertTrue($this->fluent->getClassMetadata()->getFieldMapping('id')['options']['unsigned']);
}

Expand All @@ -476,7 +477,7 @@ public function test_can_add_unsigned_small_integer_to_entity()
$field->getBuilder()->build();

$this->assertContains('id', $this->fluent->getClassMetadata()->getFieldNames());
$this->assertEquals(Type::SMALLINT, $this->fluent->getClassMetadata()->getFieldMapping('id')['type']);
$this->assertEquals(Types::SMALLINT, $this->fluent->getClassMetadata()->getFieldMapping('id')['type']);
$this->assertTrue($this->fluent->getClassMetadata()->getFieldMapping('id')['options']['unsigned']);
}

Expand All @@ -492,7 +493,7 @@ public function test_can_add_unsigned_big_integer_to_entity()
$field->getBuilder()->build();

$this->assertContains('id', $this->fluent->getClassMetadata()->getFieldNames());
$this->assertEquals(Type::BIGINT, $this->fluent->getClassMetadata()->getFieldMapping('id')['type']);
$this->assertEquals(Types::BIGINT, $this->fluent->getClassMetadata()->getFieldMapping('id')['type']);
$this->assertTrue($this->fluent->getClassMetadata()->getFieldMapping('id')['options']['unsigned']);
}

Expand Down
Loading