Skip to content

Commit

Permalink
class aliases are loaded on demand [Closes #226]
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jan 10, 2020
1 parent 4eab937 commit da70799
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 5 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
"nette/bootstrap": "<3.0"
},
"autoload": {
"classmap": ["src/"],
"files": ["src/compatibility.php"]
"classmap": ["src/"]
},
"minimum-stability": "dev",
"scripts": {
Expand Down
3 changes: 3 additions & 0 deletions src/DI/Config/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ function load(string $file): array;
*/
function dump(array $data): string;
}


class_exists(IAdapter::class);
3 changes: 3 additions & 0 deletions src/DI/Definitions/ServiceDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,6 @@ public function __clone()
$this->setup = unserialize(serialize($this->setup));
}
}


class_exists(Nette\DI\ServiceDefinition::class);
3 changes: 3 additions & 0 deletions src/DI/Definitions/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,6 @@ public function getEntity()
return $this->entity;
}
}


class_exists(Nette\DI\Statement::class);
33 changes: 30 additions & 3 deletions src/compatibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,33 @@

declare(strict_types=1);

class_alias(Nette\DI\Config\Adapter::class, Nette\DI\Config\IAdapter::class);
class_alias(Nette\DI\Definitions\Statement::class, Nette\DI\Statement::class);
class_alias(Nette\DI\Definitions\ServiceDefinition::class, Nette\DI\ServiceDefinition::class);
namespace Nette\DI\Config {
if (false) {
/** @deprecated use Nette\DI\Config\Adapter */
interface IAdapter
{
}
} elseif (!interface_exists(IAdapter::class)) {
class_alias(Adapter::class, IAdapter::class);
}
}

namespace Nette\DI {
if (false) {
/** @deprecated use Nette\DI\Definitions\ServiceDefinition */
class ServiceDefinition
{
}
} elseif (!class_exists(ServiceDefinition::class)) {
class_alias(Definitions\ServiceDefinition::class, ServiceDefinition::class);
}

if (false) {
/** @deprecated use Nette\DI\Definitions\Statement */
class Statement
{
}
} elseif (!class_exists(Statement::class)) {
class_alias(Definitions\Statement::class, Statement::class);
}
}

0 comments on commit da70799

Please sign in to comment.