Skip to content

Commit

Permalink
Remove existing deprecations on the 2.x branch
Browse files Browse the repository at this point in the history
  • Loading branch information
mpdude committed Sep 5, 2024
1 parent 4dbb05b commit 4523a82
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 204 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ This changelog tracks deprecations and changes breaking backwards compatibility.
# Version 2.0

- The `ORMInfrastructure::create*()` methods by default read ORM mapping configuration through PHP attributes; annotations support has been removed in https://github.com/webfactory/doctrine-orm-test-infrastructure/pull/55/. You can, however, still create an instance of the `AnnotationDriver` mapping driver yourself (when using ORM 2.0) and pass it into these methods.
- `\Webfactory\Doctrine\ORMTestInfrastructure\ORMInfrastructure::__construct()` is now a private method. Use the `::create*` methods to instantiate the `ORMInfrastructure`.
- The `\Webfactory\Doctrine\ORMTestInfrastructure\Query::getExecutionTimeInSeconds()` method has been removed.

# Version 1.16

Expand Down
78 changes: 0 additions & 78 deletions src/ORMTestInfrastructure/DetachingObjectManagerDecorator.php

This file was deleted.

64 changes: 0 additions & 64 deletions src/ORMTestInfrastructure/MemorizingObjectManagerDecorator.php

This file was deleted.

39 changes: 11 additions & 28 deletions src/ORMTestInfrastructure/ORMInfrastructure.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,6 @@
*/
class ORMInfrastructure
{
/**
* The connection parameters that are used per default.
*
* Possible parameters are documented at
* {@link http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html}.
*
* @var array(string=>mixed)
* @deprecated To be removed in 2.0. Pass ConnectionConfiguration during construction to change the connection.
*/
protected $defaultConnectionParams = array(
'driver' => 'pdo_sqlite',
'user' => 'root',
'password' => '',
'memory' => true
);

/**
* List of entity classes that are managed by this infrastructure.
*
Expand Down Expand Up @@ -119,13 +103,7 @@ class ORMInfrastructure
*/
protected $namingStrategy = null;

/**
* Factory that is used to create ORM configurations.
*
* @var ConfigurationFactory
* @deprecated To be removed in 2.0. Only used once and can be degraded to a local variable.
*/
protected $configFactory = null;
private readonly ?MappingDriver $mappingDriver;

/**
* Listener that is used to resolve entity mappings.
Expand Down Expand Up @@ -203,21 +181,25 @@ protected static function normalizeEntityList($entityClassOrClasses)
*
* @param string[]|\Traversable $entityClasses
* @param ConnectionConfiguration|null $connectionConfiguration Optional, specific database connection information.
* @deprecated Use one of the create*For() factory methods.
*/
public function __construct($entityClasses, ?ConnectionConfiguration $connectionConfiguration = null, ?MappingDriver $mappingDriver = null)
private function __construct($entityClasses, ?ConnectionConfiguration $connectionConfiguration = null, ?MappingDriver $mappingDriver = null)
{
if ($entityClasses instanceof \Traversable) {
$entityClasses = iterator_to_array($entityClasses);
}
if ($connectionConfiguration === null) {
$connectionConfiguration = new ConnectionConfiguration($this->defaultConnectionParams);
$connectionConfiguration = new ConnectionConfiguration([
'driver' => 'pdo_sqlite',
'user' => 'root',
'password' => '',
'memory' => true,
]);
}
$this->entityClasses = $entityClasses;
$this->connectionConfiguration = $connectionConfiguration;
$this->queryLogger = new DebugStack();
$this->namingStrategy = new DefaultNamingStrategy();
$this->configFactory = new ConfigurationFactory($mappingDriver);
$this->mappingDriver = $mappingDriver;
$this->resolveTargetListener = new ResolveTargetEntityListener();

$this->eventSubscribers = [$this->resolveTargetListener];
Expand Down Expand Up @@ -348,7 +330,8 @@ public function registerEntityMapping($originalEntity, $targetEntity)
*/
protected function createEntityManager()
{
$config = $this->configFactory->createFor($this->entityClasses);
$configFactory = new ConfigurationFactory($this->mappingDriver);
$config = $configFactory->createFor($this->entityClasses);
$config->setSQLLogger($this->queryLogger);
$config->setNamingStrategy($this->namingStrategy);

Expand Down
23 changes: 1 addition & 22 deletions src/ORMTestInfrastructure/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,17 @@ class Query
*/
protected $params = null;

/**
* The execution time of the query in seconds.
*
* @var double
*/
protected $executionTimeInSeconds = null;

/**
* Currently not used:
* - types
*
* @param string $sql - sql
* @param mixed[] $params - params
* @param double $executionTimeInSeconds - executionMS
*/
public function __construct($sql, array $params, $executionTimeInSeconds)
public function __construct($sql, array $params)
{
$this->sql = $sql;
$this->params = $params;
$this->executionTimeInSeconds = $executionTimeInSeconds;
}

/**
Expand All @@ -74,18 +65,6 @@ public function getParams()
return $this->params;
}

/**
* Returns the execution time of the query in seconds.
*
* @return double
*/
public function getExecutionTimeInSeconds()
{
trigger_deprecation('webfactory/doctrine-orm-test-infrastructure', '1.16', 'The %s method has been deprecated without a replacement and will be removed in 2.0');

return $this->executionTimeInSeconds;
}

/**
* Returns a string representation of the query and its params.
*
Expand Down
13 changes: 1 addition & 12 deletions tests/ORMTestInfrastructure/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ protected function setUp(): void
parent::setUp();
$this->query= new Query(
'SELECT * FROM user WHERE id = ?',
array(42),
0.012
array(42)
);
}

Expand Down Expand Up @@ -62,16 +61,6 @@ public function testGetParamsReturnsCorrectValue()
$this->assertEquals(array(42), $this->query->getParams());
}

/**
* Ensures that the correct execution time is returned.
*
* @group legacy
*/
public function testGetExecutionTimeInSecondsReturnsCorrectValue()
{
$this->assertEquals(0.012, $this->query->getExecutionTimeInSeconds());
}

/**
* Checks if the query object can be used to retrieve a string representation of the query.
*/
Expand Down

0 comments on commit 4523a82

Please sign in to comment.