diff --git a/composer.json b/composer.json index 88803804..5afc3f56 100644 --- a/composer.json +++ b/composer.json @@ -17,16 +17,17 @@ "issues": "https://github.com/kdyby/doctrine/issues" }, "require": { - "php": "^7.1", - "doctrine/orm": "~2.7", - "doctrine/dbal": "~2.9", - "kdyby/console": "^2.7.1", + "php": "^7.1 || ^8.0", + "doctrine/orm": "^2.10", + "doctrine/dbal": "~2.13.1", + "kdyby/console": "^4.0", "kdyby/annotations": "^3.0", - "kdyby/doctrine-cache": "^3.0", - "kdyby/strict-objects": "^2.0", + "kdyby/doctrine-cache": "dev-php-8-support as 3.1.2", + "kdyby/strict-objects": "dev-updates", "nette/di": "^3.0", "nette/utils": "^3.0", - "nette/finder": "^2.5" + "nette/finder": "^2.5", + "symfony/console": "^4.4" }, "suggest": { "kdyby/doctrine-magic-accessors": "Fast-prototyping magic accessors trait for Doctrine entities", @@ -61,5 +62,11 @@ "branch-alias": { "dev-master": "4.0-dev" } - } + }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/mhucik/DoctrineCache" + } + ] } diff --git a/src/Kdyby/Doctrine/Console/DbalDelegateCommand.php b/src/Kdyby/Doctrine/Console/DbalDelegateCommand.php index 2aba7c2d..d6926d53 100644 --- a/src/Kdyby/Doctrine/Console/DbalDelegateCommand.php +++ b/src/Kdyby/Doctrine/Console/DbalDelegateCommand.php @@ -58,8 +58,6 @@ protected function configure() $this->setHelp($this->command->getHelp()); $this->setDefinition($this->command->getDefinition()); $this->setDescription($this->command->getDescription()); - - $this->addOption('connection', NULL, InputOption::VALUE_OPTIONAL, 'The connection to use for this command'); } /** diff --git a/src/Kdyby/Doctrine/Console/OrmDelegateCommand.php b/src/Kdyby/Doctrine/Console/OrmDelegateCommand.php index 00bf7dc0..308eea0b 100644 --- a/src/Kdyby/Doctrine/Console/OrmDelegateCommand.php +++ b/src/Kdyby/Doctrine/Console/OrmDelegateCommand.php @@ -58,8 +58,6 @@ protected function configure() $this->setHelp($this->command->getHelp()); $this->setDefinition($this->command->getDefinition()); $this->setDescription($this->command->getDescription()); - - $this->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command'); } /** diff --git a/src/Kdyby/Doctrine/DI/OrmExtension.php b/src/Kdyby/Doctrine/DI/OrmExtension.php index daa84659..4f18dd68 100644 --- a/src/Kdyby/Doctrine/DI/OrmExtension.php +++ b/src/Kdyby/Doctrine/DI/OrmExtension.php @@ -28,6 +28,7 @@ use Kdyby\Annotations\DI\AnnotationsExtension; use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper; use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper; +use ReflectionClass; /** * @author Filip Procházka @@ -243,7 +244,7 @@ protected function processEntityManager($name, array $defaults) } $metadataDriver = $builder->addDefinition($this->prefix($name . '.metadataDriver')) - ->setClass(Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain::class) + ->setClass(Doctrine\Persistence\Mapping\Driver\MappingDriverChain::class) ->setAutowired(FALSE); /** @var \Nette\DI\ServiceDefinition $metadataDriver */ @@ -595,7 +596,7 @@ protected function processMetadataDriver(Nette\DI\ServiceDefinition $metadataDri } $impl = $driver instanceof \stdClass ? $driver->value : ($driver instanceof Statement ? $driver->getEntity() : (string) $driver); - list($driver) = CacheHelpers::filterArgs($driver); + [$driver] = CacheHelpers::filterArgs($driver); /** @var Statement $driver */ /** @var string $impl */ @@ -618,7 +619,7 @@ protected function processMetadataDriver(Nette\DI\ServiceDefinition $metadataDri $serviceName = $this->prefix($prefix . '.driver.' . str_replace('\\', '_', $namespace) . '.' . str_replace('\\', '_', $impl) . 'Impl'); $this->getContainerBuilder()->addDefinition($serviceName) - ->setClass(Doctrine\Common\Persistence\Mapping\Driver\MappingDriver::class) + ->setClass(Doctrine\Persistence\Mapping\Driver\MappingDriver::class) ->setFactory($driver->getEntity(), $driver->arguments) ->setAutowired(FALSE); @@ -853,9 +854,9 @@ private function isKdybyEventsPresent() private function addCollapsePathsToTracy(Method $init) { $blueScreen = \Tracy\Debugger::class . '::getBlueScreen()'; - $commonDirname = dirname(Nette\Reflection\ClassType::from(Doctrine\Common\Version::class)->getFileName()); + $commonDirname = dirname((new ReflectionClass(Doctrine\Common\ClassLoader::class))->getFileName()); - $init->addBody($blueScreen . '->collapsePaths[] = ?;', [dirname(Nette\Reflection\ClassType::from(Kdyby\Doctrine\Exception::class)->getFileName())]); + $init->addBody($blueScreen . '->collapsePaths[] = ?;', [dirname((new ReflectionClass(Kdyby\Doctrine\Exception::class))->getFileName())]); $init->addBody($blueScreen . '->collapsePaths[] = ?;', [dirname(dirname(dirname(dirname($commonDirname))))]); // this should be vendor/doctrine foreach ($this->proxyAutoloaders as $dir) { $init->addBody($blueScreen . '->collapsePaths[] = ?;', [$dir]); diff --git a/src/Kdyby/Doctrine/Diagnostics/Panel.php b/src/Kdyby/Doctrine/Diagnostics/Panel.php index f90da8f8..80283ed7 100644 --- a/src/Kdyby/Doctrine/Diagnostics/Panel.php +++ b/src/Kdyby/Doctrine/Diagnostics/Panel.php @@ -12,13 +12,14 @@ use Doctrine; use Doctrine\Common\Collections\ArrayCollection; -use Doctrine\Common\Persistence\Proxy; use Doctrine\Common\Annotations\AnnotationException; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\Type; +use Doctrine\Persistence\Proxy; use Kdyby; use Nette; use Nette\Utils\Strings; +use ReflectionClass; use Tracy\Bar; use Tracy\BlueScreen; use Tracy\Debugger; @@ -97,7 +98,7 @@ public function startQuery($sql, array $params = NULL, array $types = NULL) foreach (debug_backtrace(FALSE) as $row) { if (isset($row['file']) && $this->filterTracePaths(realpath($row['file']))) { if (isset($row['class']) && stripos($row['class'], '\\' . Proxy::MARKER) !== FALSE) { - if (!in_array(Doctrine\Common\Persistence\Proxy::class, class_implements($row['class']))) { + if (!in_array(Proxy::class, class_implements($row['class']))) { continue; } elseif (isset($row['function']) && $row['function'] === '__load') { @@ -287,7 +288,7 @@ protected function renderStyles() protected function processQuery(array $query) { $h = 'htmlspecialchars'; - list($sql, $params, $time, $types, $source) = $query; + [$sql, $params, $time, $types, $source] = $query; $s = self::highlightQuery(static::formatQuery($sql, (array) $params, (array) $types, $this->connection ? $this->connection->getDatabasePlatform() : NULL)); if ($source) { @@ -318,10 +319,10 @@ public function renderQueryException($e) return NULL; } - list($sql, $params, , , $source) = $this->failed[spl_object_hash($e)]; + [$sql, $params, , , $source] = $this->failed[spl_object_hash($e)]; } else { - list($sql, $params, , $types, $source) = end($this->queries) + range(1, 5); + [$sql, $params, , $types, $source] = end($this->queries) + range(1, 5); } if (!$sql) { @@ -370,7 +371,7 @@ public static function renderException($e, Nette\DI\Container $dic) } elseif ($e instanceof Doctrine\ORM\Mapping\MappingException) { if ($invalidEntity = Strings::match($e->getMessage(), '~^Class "([\\S]+)" .*? is not .*? valid~i')) { - $refl = Nette\Reflection\ClassType::from($invalidEntity[1]); + $refl = new ReflectionClass($invalidEntity[1]); $file = $refl->getFileName(); $errorLine = $refl->getStartLine(); @@ -494,7 +495,7 @@ protected function dumpQuery($query, $params, array $types = [], $source = NULL) $e = NULL; if ($source && is_array($source)) { - list($file, $line) = $source; + [$file, $line] = $source; $e = '

File: ' . self::editorLink($file, $line) . '

'; } @@ -576,7 +577,7 @@ public static function formatQuery($query, $params, array $types = [], AbstractP } try { - list($query, $params, $types) = \Doctrine\DBAL\SQLParserUtils::expandListParameters($query, $params, $types); + [$query, $params, $types] = \Doctrine\DBAL\SQLParserUtils::expandListParameters($query, $params, $types); } catch (Doctrine\DBAL\SQLParserUtilsException $e) { } @@ -648,7 +649,7 @@ public static function highlightAnnotationLine(AnnotationException $e) return FALSE; } - $refl = Nette\Reflection\ClassType::from($context['class']); + $refl = new ReflectionClass($context['class']); $file = $refl->getFileName(); $line = NULL; @@ -673,7 +674,7 @@ public static function highlightAnnotationLine(AnnotationException $e) /** - * @param \Reflector|\Nette\Reflection\ClassType|\Nette\Reflection\Method|\Nette\Reflection\Property $refl + * @param \Reflector|\ReflectionClass|\ReflectionMethod|\ReflectionProperty $refl * @param \Exception|\Throwable $e * @param int|NULL $startLine * @return int|NULL @@ -711,7 +712,7 @@ public static function calculateErrorLine(\Reflector $refl, $e, $startLine = NUL /** - * @param \Reflector|\Nette\Reflection\ClassType|\Nette\Reflection\Method $refl + * @param \Reflector|\ReflectionClass|\ReflectionMethod $refl * @param int $symbolPos * @return int */ @@ -731,7 +732,7 @@ protected static function calculateAffectedLine(\Reflector $refl, $symbolPos) /** - * @param \Reflector|Nette\Reflection\ClassType|Nette\Reflection\Method $refl + * @param \Reflector|\ReflectionClass|\ReflectionMethod $refl * @param string $annotation * @return string */ @@ -762,7 +763,7 @@ private static function findRenamed(\Reflector $refl, $annotation) /** - * @param \Nette\Reflection\ClassType|\Nette\Reflection\Method|\Reflector $refl + * @param \ReflectionClass|\ReflectionMethod|\Reflector $refl * @param int|null $atPos * @return string */ diff --git a/src/Kdyby/Doctrine/Entities/SerializableMixin.php b/src/Kdyby/Doctrine/Entities/SerializableMixin.php index 9ff4982e..b6298a56 100644 --- a/src/Kdyby/Doctrine/Entities/SerializableMixin.php +++ b/src/Kdyby/Doctrine/Entities/SerializableMixin.php @@ -12,8 +12,7 @@ use Kdyby; use Kdyby\Doctrine\StaticClassException; -use Nette; -use Nette\Reflection\ClassType; +use ReflectionClass; use Serializable; @@ -25,12 +24,12 @@ final class SerializableMixin { /** - * @var array|\Nette\Reflection\ClassType[] + * @var array|\ReflectionClass[] */ private static $classes = []; /** - * @var array|\Nette\Reflection\Property + * @var array|\ReflectionProperty */ private static $properties = []; @@ -60,10 +59,10 @@ public static function serialize(Serializable $object) $allowed = (array)$object->__sleep(); } - $class = ClassType::from($object); + $class = new ReflectionClass($object); do { - /** @var \Nette\Reflection\Property $propertyRefl */ + /** @var \ReflectionProperty $propertyRefl */ foreach ($class->getProperties() as $propertyRefl) { if ($allowed !== FALSE && !in_array($propertyRefl->getName(), $allowed)) { continue; @@ -99,7 +98,7 @@ public static function unserialize(Serializable $object, $serialized) foreach ($data as $target => $value) { if (strpos($target, '::') !== FALSE) { - list($class, $name) = explode('::', $target, 2); + [$class, $name] = explode('::', $target, 2); $propertyRefl = self::getProperty($name, $class); } else { @@ -122,7 +121,7 @@ public static function unserialize(Serializable $object, $serialized) * @param string $name * @param string|object $class * - * @return \Nette\Reflection\Property + * @return \ReflectionProperty */ private static function getProperty($name, $class) { @@ -132,10 +131,10 @@ private static function getProperty($name, $class) } if (!isset(self::$classes[$class])) { - self::$classes[$class] = ClassType::from($class); + self::$classes[$class] = new ReflectionClass($class); } - /** @var \Nette\Reflection\Property $propRefl */ + /** @var \ReflectionProperty $propRefl */ $propRefl = self::$classes[$class]->getProperty($name); $propRefl->setAccessible(TRUE); diff --git a/src/Kdyby/Doctrine/Mapping/ClassMetadata.php b/src/Kdyby/Doctrine/Mapping/ClassMetadata.php index d6d6d7a6..3e5cb447 100644 --- a/src/Kdyby/Doctrine/Mapping/ClassMetadata.php +++ b/src/Kdyby/Doctrine/Mapping/ClassMetadata.php @@ -35,7 +35,7 @@ class ClassMetadata extends Doctrine\ORM\Mapping\ClassMetadata public function getReflectionClass() { if ($this->reflClass === NULL) { - $this->reflClass = new Nette\Reflection\ClassType($this->name); + $this->reflClass = new \ReflectionClass($this->name); } return $this->reflClass; diff --git a/src/Kdyby/Doctrine/Mapping/RuntimeReflectionService.php b/src/Kdyby/Doctrine/Mapping/RuntimeReflectionService.php index fece83bc..f633abaa 100644 --- a/src/Kdyby/Doctrine/Mapping/RuntimeReflectionService.php +++ b/src/Kdyby/Doctrine/Mapping/RuntimeReflectionService.php @@ -12,26 +12,22 @@ use Doctrine; use Kdyby; -use Nette; -use Nette\Reflection; - +use ReflectionClass; +use ReflectionProperty; /** * @author Filip Procházka */ -class RuntimeReflectionService extends Doctrine\Common\Persistence\Mapping\RuntimeReflectionService +class RuntimeReflectionService extends Doctrine\Persistence\Mapping\RuntimeReflectionService { /** - * Return a reflection class instance or null - * * @param string $class - * @return \Nette\Reflection\ClassType */ - public function getClass($class) + public function getClass($class): ?ReflectionClass { - return new Reflection\ClassType($class); + return new ReflectionClass($class); } @@ -41,12 +37,11 @@ public function getClass($class) * * @param string $class * @param string $property - * @return \Nette\Reflection\Property|NULL */ - public function getAccessibleProperty($class, $property) + public function getAccessibleProperty($class, $property): ?ReflectionProperty { try { - $property = new Reflection\Property($class, $property); + $property = new ReflectionProperty($class, $property); $property->setAccessible(TRUE); return $property; diff --git a/src/Kdyby/Doctrine/Registry.php b/src/Kdyby/Doctrine/Registry.php index bb3c0e8a..471af8d2 100644 --- a/src/Kdyby/Doctrine/Registry.php +++ b/src/Kdyby/Doctrine/Registry.php @@ -10,8 +10,8 @@ namespace Kdyby\Doctrine; -use Doctrine\Common\Persistence\AbstractManagerRegistry; use Doctrine\ORM\ORMException; +use Doctrine\Persistence\AbstractManagerRegistry; use Kdyby; use Nette;