From 35d4c711d6aa9e7a54a2dbdf942d5becb2a121ad Mon Sep 17 00:00:00 2001 From: Bruce Wells Date: Fri, 17 Oct 2025 21:48:17 -0400 Subject: [PATCH 1/3] Update Eloquent to V12 --- eloquent/composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eloquent/composer.json b/eloquent/composer.json index ea6ab63a..f58b7aff 100644 --- a/eloquent/composer.json +++ b/eloquent/composer.json @@ -1,7 +1,7 @@ { "require": { - "illuminate/database": "^10.0", - "illuminate/contracts": "^10.0", - "illuminate/events": "^10.0" + "illuminate/database": "^12.0", + "illuminate/contracts": "^12.0", + "illuminate/events": "^12.0" } } From 0d3235db013dfe8364c1e61e35763d453f4669c3 Mon Sep 17 00:00:00 2001 From: Bruce Wells Date: Mon, 20 Oct 2025 11:02:02 -0400 Subject: [PATCH 2/3] Doctrine port --- AbstractTestSuite.php | 3 +- doctrine_m/DoctrineMTestSuite.php | 40 ++-- doctrine_m/DoctrineMWithCacheTestSuite.php | 4 - doctrine_m/models/Category.php | 9 +- doctrine_m/models/Image.php | 18 +- doctrine_m/models/Product.php | 32 ++- doctrine_m/models/ProductImage.php | 5 +- doctrine_m/models/Tag.php | 9 +- doctrine_m/proxies/__CG__Category.php | 220 ++------------------- 9 files changed, 78 insertions(+), 262 deletions(-) diff --git a/AbstractTestSuite.php b/AbstractTestSuite.php index 551a3d96..aab82be7 100644 --- a/AbstractTestSuite.php +++ b/AbstractTestSuite.php @@ -4,10 +4,9 @@ abstract class AbstractTestSuite { - /** @var PDO $con */ protected $con; - protected $products = array(); + protected array $products = []; const NB_TEST = 500; diff --git a/doctrine_m/DoctrineMTestSuite.php b/doctrine_m/DoctrineMTestSuite.php index e3c7d0ac..69403139 100644 --- a/doctrine_m/DoctrineMTestSuite.php +++ b/doctrine_m/DoctrineMTestSuite.php @@ -1,34 +1,32 @@ setMetadataCacheImpl($cache); - $driverImpl = $config->newDefaultAnnotationDriver(__DIR__ . '/models'); - $config->setMetadataDriverImpl($driverImpl); - $config->setQueryCacheImpl($cache); - $config->setProxyDir(__DIR__ . '/proxies'); - $config->setProxyNamespace('Proxies'); - $config->setAutoGenerateProxyClasses(true); // no code generation in production - - $dbParams = array('driver' => 'pdo_sqlite', 'memory' => true); -// unlink(__DIR__ . '/sqlite'); -// $dbParams = array('driver' => 'pdo_sqlite', 'path' => __DIR__ . '/sqlite'); - - $this->em = Doctrine\ORM\EntityManager::create($dbParams, $config); + $queryCache = new \Symfony\Component\Cache\Adapter\ArrayAdapter(); + $metadataCache = new \Symfony\Component\Cache\Adapter\ArrayAdapter(); + + $doctrineConfig = new \Doctrine\ORM\Configuration(); + $doctrineConfig->setMetadataCache($metadataCache); + $entityPath = __DIR__ . '/models'; + $driverImpl = new \Doctrine\ORM\Mapping\Driver\AttributeDriver([$entityPath], true); + $doctrineConfig->setMetadataDriverImpl($driverImpl); + $doctrineConfig->setQueryCache($queryCache); + $doctrineConfig->setProxyDir(__DIR__ . '/proxies'); + $doctrineConfig->setProxyNamespace('Proxies'); + $doctrineConfig->setAutoGenerateProxyClasses(true); + + $dbParams = new \Doctrine\DBAL\Connection(['driver' => 'pdo_sqlite', 'memory' => true], new \Doctrine\DBAL\Driver\SQLite3\Driver()); + + $this->em = new \Doctrine\ORM\EntityManager($dbParams, $doctrineConfig); if ( ! self::$classes) { self::$classes = $this->em->getMetadataFactory()->getAllMetadata(); diff --git a/doctrine_m/DoctrineMWithCacheTestSuite.php b/doctrine_m/DoctrineMWithCacheTestSuite.php index 88db316d..99a7f8ec 100644 --- a/doctrine_m/DoctrineMWithCacheTestSuite.php +++ b/doctrine_m/DoctrineMWithCacheTestSuite.php @@ -9,10 +9,6 @@ class DoctrineMWithCacheTestSuite extends DoctrineMTestSuite function initialize() { parent::initialize(); - $this->cache = new Doctrine\Common\Cache\ArrayCache(); - $this->em->getConfiguration()->setMetadataCacheImpl($this->cache); - $this->em->getConfiguration()->setQueryCacheImpl($this->cache); - $this->em->getConfiguration()->setResultCacheImpl($this->cache); } } \ No newline at end of file diff --git a/doctrine_m/models/Category.php b/doctrine_m/models/Category.php index 70cc030c..1b4379c2 100644 --- a/doctrine_m/models/Category.php +++ b/doctrine_m/models/Category.php @@ -1,10 +1,13 @@ NULL]; - - - - /** - * @param \Closure $initializer - * @param \Closure $cloner - */ - public function __construct($initializer = null, $cloner = null) - { - unset($this->name); - - $this->__initializer__ = $initializer; - $this->__cloner__ = $cloner; + use \Symfony\Component\VarExporter\LazyGhostTrait { + initializeLazyObject as private; + setLazyObjectAsInitialized as public __setInitialized; + isLazyObjectInitialized as private; + createLazyGhost as private; + resetLazyObject as private; } - /** - * - * @param string $name - */ - public function __get($name) + public function __load(): void { - if (array_key_exists($name, $this->__getLazyProperties())) { - $this->__initializer__ && $this->__initializer__->__invoke($this, '__get', [$name]); - - return $this->$name; - } - - trigger_error(sprintf('Undefined property: %s::$%s', __CLASS__, $name), E_USER_NOTICE); - } - - /** - * - * @param string $name - * @param mixed $value - */ - public function __set($name, $value) - { - if (array_key_exists($name, $this->__getLazyProperties())) { - $this->__initializer__ && $this->__initializer__->__invoke($this, '__set', [$name, $value]); - - $this->$name = $value; - - return; - } - - $this->$name = $value; - } - - /** - * - * @param string $name - * @return boolean - */ - public function __isset($name) - { - if (array_key_exists($name, $this->__getLazyProperties())) { - $this->__initializer__ && $this->__initializer__->__invoke($this, '__isset', [$name]); - - return isset($this->$name); - } - - return false; - } - - /** - * - * @return array - */ - public function __sleep() - { - if ($this->__isInitialized__) { - return ['__isInitialized__', 'id', 'name']; - } - - return ['__isInitialized__', 'id']; - } - - /** - * - */ - public function __wakeup() - { - if ( ! $this->__isInitialized__) { - $this->__initializer__ = function (Category $proxy) { - $proxy->__setInitializer(null); - $proxy->__setCloner(null); - - $existingProperties = get_object_vars($proxy); - - foreach ($proxy->__getLazyProperties() as $property => $defaultValue) { - if ( ! array_key_exists($property, $existingProperties)) { - $proxy->$property = $defaultValue; - } - } - }; - - unset($this->name); - } - } - - /** - * - */ - public function __clone() - { - $this->__cloner__ && $this->__cloner__->__invoke($this, '__clone', []); - } - - /** - * Forces initialization of the proxy - */ - public function __load() - { - $this->__initializer__ && $this->__initializer__->__invoke($this, '__load', []); - } - - /** - * {@inheritDoc} - * @internal generated method: use only when explicitly handling proxy specific loading logic - */ - public function __isInitialized() - { - return $this->__isInitialized__; + $this->initializeLazyObject(); } + - /** - * {@inheritDoc} - * @internal generated method: use only when explicitly handling proxy specific loading logic - */ - public function __setInitialized($initialized) - { - $this->__isInitialized__ = $initialized; - } + private const LAZY_OBJECT_PROPERTY_SCOPES = [ + 'id' => [parent::class, 'id', null, 4], + 'name' => [parent::class, 'name', null, 4], + ]; - /** - * {@inheritDoc} - * @internal generated method: use only when explicitly handling proxy specific loading logic - */ - public function __setInitializer(\Closure $initializer = null) + public function __isInitialized(): bool { - $this->__initializer__ = $initializer; + return isset($this->lazyObjectState) && $this->isLazyObjectInitialized(); } - /** - * {@inheritDoc} - * @internal generated method: use only when explicitly handling proxy specific loading logic - */ - public function __getInitializer() + public function __serialize(): array { - return $this->__initializer__; - } + $properties = (array) $this; + unset($properties["\0" . self::class . "\0lazyObjectState"]); - /** - * {@inheritDoc} - * @internal generated method: use only when explicitly handling proxy specific loading logic - */ - public function __setCloner(\Closure $cloner = null) - { - $this->__cloner__ = $cloner; + return $properties; } - - /** - * {@inheritDoc} - * @internal generated method: use only when explicitly handling proxy specific cloning logic - */ - public function __getCloner() - { - return $this->__cloner__; - } - - /** - * {@inheritDoc} - * @internal generated method: use only when explicitly handling proxy specific loading logic - * @static - */ - public function __getLazyProperties() - { - return self::$lazyPropertiesDefaults; - } - - } From 0d0933dd9030bafbd4fd2ab1f15561043b4c9ef6 Mon Sep 17 00:00:00 2001 From: Bruce Wells Date: Mon, 20 Oct 2025 16:40:00 -0400 Subject: [PATCH 3/3] PHP 8.4 updates for SiriusORM --- siriusorm/src/Entity/CategoryBase.php | 2 +- siriusorm/src/Entity/ImageBase.php | 2 +- siriusorm/src/Entity/ProductBase.php | 2 +- siriusorm/src/Entity/TagBase.php | 2 +- siriusorm/src/Mapper/ProductMapperBase.php | 8 ++++---- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/siriusorm/src/Entity/CategoryBase.php b/siriusorm/src/Entity/CategoryBase.php index 21450f50..502b5047 100644 --- a/siriusorm/src/Entity/CategoryBase.php +++ b/siriusorm/src/Entity/CategoryBase.php @@ -8,7 +8,7 @@ abstract class CategoryBase extends ClassMethodsEntity { - public function __construct(array $attributes = [], string $state = null) + public function __construct(array $attributes = [], ?string $state = null) { parent::__construct($attributes, $state); } diff --git a/siriusorm/src/Entity/ImageBase.php b/siriusorm/src/Entity/ImageBase.php index f39a81cb..789a40d9 100644 --- a/siriusorm/src/Entity/ImageBase.php +++ b/siriusorm/src/Entity/ImageBase.php @@ -8,7 +8,7 @@ abstract class ImageBase extends ClassMethodsEntity { - public function __construct(array $attributes = [], string $state = null) + public function __construct(array $attributes = [], ?string $state = null) { parent::__construct($attributes, $state); } diff --git a/siriusorm/src/Entity/ProductBase.php b/siriusorm/src/Entity/ProductBase.php index b35bf774..cf403a34 100644 --- a/siriusorm/src/Entity/ProductBase.php +++ b/siriusorm/src/Entity/ProductBase.php @@ -9,7 +9,7 @@ abstract class ProductBase extends ClassMethodsEntity { - public function __construct(array $attributes = [], string $state = null) + public function __construct(array $attributes = [], ?string $state = null) { parent::__construct($attributes, $state); } diff --git a/siriusorm/src/Entity/TagBase.php b/siriusorm/src/Entity/TagBase.php index 9875e37e..e79fbefa 100644 --- a/siriusorm/src/Entity/TagBase.php +++ b/siriusorm/src/Entity/TagBase.php @@ -8,7 +8,7 @@ abstract class TagBase extends ClassMethodsEntity { - public function __construct(array $attributes = [], string $state = null) + public function __construct(array $attributes = [], ?string $state = null) { parent::__construct($attributes, $state); } diff --git a/siriusorm/src/Mapper/ProductMapperBase.php b/siriusorm/src/Mapper/ProductMapperBase.php index 101d5a3e..7feab647 100644 --- a/siriusorm/src/Mapper/ProductMapperBase.php +++ b/siriusorm/src/Mapper/ProductMapperBase.php @@ -53,20 +53,20 @@ protected function initRelations() $this->addRelation('tags', [ 'type' => 'many_to_many', + 'native_key' => 'id', + 'foreign_mapper' => 'tags', 'foreign_key' => 'id', + 'load_strategy' => 'lazy', 'pivot_table' => 'products_tags', 'pivot_native_column' => 'product_id', 'pivot_foreign_column' => 'tag_id', - 'native_key' => 'id', - 'foreign_mapper' => 'tags', - 'load_strategy' => 'lazy', ]); $this->addRelation('category', [ 'type' => 'many_to_one', - 'foreign_key' => 'id', 'native_key' => 'category_id', 'foreign_mapper' => 'categories', + 'foreign_key' => 'id', 'load_strategy' => 'lazy', ]); }