Forráskód Böngészése

[PHP] Update imi PHP 8.2 (#7779)

* Update imi PHP 8.2

* Update base model file

* Update base model file

* Update base model file

* Change to mysqli

* Update base model file

* Fix
Yurun 2 éve
szülő
commit
4ef25d3688

+ 30 - 16
frameworks/PHP/imi/Model/Base/FortuneBase.php

@@ -1,33 +1,47 @@
 <?php
+
 declare(strict_types=1);
 
 namespace ImiApp\Model\Base;
 
-use Imi\Model\Model as Model;
-use Imi\Model\Annotation\DDL;
-use Imi\Model\Annotation\Table;
+use Imi\Config\Annotation\ConfigValue;
 use Imi\Model\Annotation\Column;
+use Imi\Model\Annotation\DDL;
 use Imi\Model\Annotation\Entity;
+use Imi\Model\Annotation\Table;
+use Imi\Model\Model as Model;
 
 /**
- * fortune 基类
- * @Entity(bean=false)
- * @Table(name="fortune", id={"id"})
+ * fortune 基类.
+ *
+ * @Entity(camel=true, bean=false, incrUpdate=false)
+ * @Table(name=@ConfigValue(name="@app.models.ImiApp\Model\Fortune.name", default="fortune"), usePrefix=false, id={"id"}, dbPoolName=@ConfigValue(name="@app.models.ImiApp\Model\Fortune.poolName"))
  * @DDL(sql="CREATE TABLE `fortune` (   `id` int(10) unsigned NOT NULL AUTO_INCREMENT,   `message` varchar(2048) CHARACTER SET utf8 NOT NULL,   PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", decode="")
+ *
  * @property int|null $id 
  * @property string|null $message 
  */
 abstract class FortuneBase extends Model
 {
     /**
-     * id
-     * @Column(name="id", type="int", length=10, accuracy=0, nullable=false, default="", isPrimaryKey=true, primaryKeyIndex=0, isAutoIncrement=true)
+     * {@inheritdoc}
+     */
+    public const PRIMARY_KEY = 'id';
+
+    /**
+     * {@inheritdoc}
+     */
+    public const PRIMARY_KEYS = ["id"];
+
+    /**
+     * id.
+     * @Column(name="id", type="int", length=10, accuracy=0, nullable=false, default="", isPrimaryKey=true, primaryKeyIndex=0, isAutoIncrement=true, unsigned=true, virtual=false)
      * @var int|null
      */
-    protected ?int $id = null;
+    protected ?int $id = NULL;
 
     /**
-     * 获取 id
+     * 获取 id.
      *
      * @return int|null
      */
@@ -37,7 +51,7 @@ abstract class FortuneBase extends Model
     }
 
     /**
-     * 赋值 id
+     * 赋值 id.
      * @param int|null $id id
      * @return static
      */
@@ -48,14 +62,14 @@ abstract class FortuneBase extends Model
     }
 
     /**
-     * message
-     * @Column(name="message", type="varchar", length=2048, accuracy=0, nullable=false, default="", isPrimaryKey=false, primaryKeyIndex=-1, isAutoIncrement=false)
+     * message.
+     * @Column(name="message", type="varchar", length=2048, accuracy=0, nullable=false, default="", isPrimaryKey=false, primaryKeyIndex=-1, isAutoIncrement=false, unsigned=false, virtual=false)
      * @var string|null
      */
-    protected ?string $message = null;
+    protected ?string $message = NULL;
 
     /**
-     * 获取 message
+     * 获取 message.
      *
      * @return string|null
      */
@@ -65,7 +79,7 @@ abstract class FortuneBase extends Model
     }
 
     /**
-     * 赋值 message
+     * 赋值 message.
      * @param string|null $message message
      * @return static
      */

+ 30 - 16
frameworks/PHP/imi/Model/Base/WorldBase.php

@@ -1,33 +1,47 @@
 <?php
+
 declare(strict_types=1);
 
 namespace ImiApp\Model\Base;
 
-use Imi\Model\Model as Model;
-use Imi\Model\Annotation\DDL;
-use Imi\Model\Annotation\Table;
+use Imi\Config\Annotation\ConfigValue;
 use Imi\Model\Annotation\Column;
+use Imi\Model\Annotation\DDL;
 use Imi\Model\Annotation\Entity;
+use Imi\Model\Annotation\Table;
+use Imi\Model\Model as Model;
 
 /**
- * world 基类
- * @Entity(bean=false)
- * @Table(name="world", id={"id"})
+ * world 基类.
+ *
+ * @Entity(camel=true, bean=false, incrUpdate=false)
+ * @Table(name=@ConfigValue(name="@app.models.ImiApp\Model\World.name", default="world"), usePrefix=false, id={"id"}, dbPoolName=@ConfigValue(name="@app.models.ImiApp\Model\World.poolName"))
  * @DDL(sql="CREATE TABLE `world` (   `id` int(10) unsigned NOT NULL AUTO_INCREMENT,   `randomNumber` int(11) NOT NULL DEFAULT '0',   PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", decode="")
+ *
  * @property int|null $id 
  * @property int|null $randomNumber 
  */
 abstract class WorldBase extends Model
 {
     /**
-     * id
-     * @Column(name="id", type="int", length=10, accuracy=0, nullable=false, default="", isPrimaryKey=true, primaryKeyIndex=0, isAutoIncrement=true)
+     * {@inheritdoc}
+     */
+    public const PRIMARY_KEY = 'id';
+
+    /**
+     * {@inheritdoc}
+     */
+    public const PRIMARY_KEYS = ["id"];
+
+    /**
+     * id.
+     * @Column(name="id", type="int", length=10, accuracy=0, nullable=false, default="", isPrimaryKey=true, primaryKeyIndex=0, isAutoIncrement=true, unsigned=true, virtual=false)
      * @var int|null
      */
-    protected ?int $id = null;
+    protected ?int $id = NULL;
 
     /**
-     * 获取 id
+     * 获取 id.
      *
      * @return int|null
      */
@@ -37,7 +51,7 @@ abstract class WorldBase extends Model
     }
 
     /**
-     * 赋值 id
+     * 赋值 id.
      * @param int|null $id id
      * @return static
      */
@@ -48,14 +62,14 @@ abstract class WorldBase extends Model
     }
 
     /**
-     * randomNumber
-     * @Column(name="randomNumber", type="int", length=11, accuracy=0, nullable=false, default="0", isPrimaryKey=false, primaryKeyIndex=-1, isAutoIncrement=false)
+     * randomNumber.
+     * @Column(name="randomNumber", type="int", length=11, accuracy=0, nullable=false, default="0", isPrimaryKey=false, primaryKeyIndex=-1, isAutoIncrement=false, unsigned=false, virtual=false)
      * @var int|null
      */
-    protected ?int $randomNumber = null;
+    protected ?int $randomNumber = 0;
 
     /**
-     * 获取 randomNumber
+     * 获取 randomNumber.
      *
      * @return int|null
      */
@@ -65,7 +79,7 @@ abstract class WorldBase extends Model
     }
 
     /**
-     * 赋值 randomNumber
+     * 赋值 randomNumber.
      * @param int|null $randomNumber randomNumber
      * @return static
      */

+ 32 - 14
frameworks/PHP/imi/Model/PgSql/Base/FortuneBase.php

@@ -1,31 +1,46 @@
 <?php
+
 declare(strict_types=1);
 
 namespace ImiApp\Model\PgSql\Base;
 
-use Imi\Pgsql\Model\PgModel as Model;
-use Imi\Model\Annotation\Table;
+use Imi\Config\Annotation\ConfigValue;
 use Imi\Model\Annotation\Column;
 use Imi\Model\Annotation\Entity;
+use Imi\Model\Annotation\Table;
+use Imi\Pgsql\Model\PgModel as Model;
 
 /**
- * Fortune 基类
+ * fortune 基类.
+ *
  * @Entity(bean=false)
- * @Table(name="Fortune", id={"id"}, dbPoolName="pgsql")
+ * @Table(name=@ConfigValue(name="@app.models.ImiApp\Model\PgSql\Fortune.name", default="fortune"), usePrefix=false, id={"id"}, dbPoolName=@ConfigValue(name="@app.models.ImiApp\Model\PgSql\Fortune.poolName", default="pgsql"))
+ *
  * @property int|null $id 
  * @property string|null $message 
  */
 abstract class FortuneBase extends Model
 {
     /**
-     * id
-     * @Column(name="id", type="int4", length=-1, accuracy=0, nullable=false, default="", isPrimaryKey=true, primaryKeyIndex=1, isAutoIncrement=false, ndims=0)
+     * {@inheritdoc}
+     */
+    public const PRIMARY_KEY = 'id';
+
+    /**
+     * {@inheritdoc}
+     */
+    public const PRIMARY_KEYS = ["id"];
+
+    /**
+     * id.
+
+     * @Column(name="id", type="int4", length=-1, accuracy=0, nullable=false, default="", isPrimaryKey=true, primaryKeyIndex=1, isAutoIncrement=false, ndims=0, virtual=false)
      * @var int|null
      */
-    protected ?int $id = null;
+    protected ?int $id = NULL;
 
     /**
-     * 获取 id
+     * 获取 id.
      *
      * @return int|null
      */
@@ -35,7 +50,8 @@ abstract class FortuneBase extends Model
     }
 
     /**
-     * 赋值 id
+     * 赋值 id.
+     *
      * @param int|null $id id
      * @return static
      */
@@ -46,14 +62,15 @@ abstract class FortuneBase extends Model
     }
 
     /**
-     * message
-     * @Column(name="message", type="varchar", length=0, accuracy=2048, nullable=false, default="", isPrimaryKey=false, primaryKeyIndex=-1, isAutoIncrement=false, ndims=0)
+     * message.
+
+     * @Column(name="message", type="varchar", length=0, accuracy=2048, nullable=false, default="", isPrimaryKey=false, primaryKeyIndex=-1, isAutoIncrement=false, ndims=0, virtual=false)
      * @var string|null
      */
-    protected ?string $message = null;
+    protected ?string $message = NULL;
 
     /**
-     * 获取 message
+     * 获取 message.
      *
      * @return string|null
      */
@@ -63,7 +80,8 @@ abstract class FortuneBase extends Model
     }
 
     /**
-     * 赋值 message
+     * 赋值 message.
+     *
      * @param string|null $message message
      * @return static
      */

+ 32 - 14
frameworks/PHP/imi/Model/PgSql/Base/WorldBase.php

@@ -1,31 +1,46 @@
 <?php
+
 declare(strict_types=1);
 
 namespace ImiApp\Model\PgSql\Base;
 
-use Imi\Pgsql\Model\PgModel as Model;
-use Imi\Model\Annotation\Table;
+use Imi\Config\Annotation\ConfigValue;
 use Imi\Model\Annotation\Column;
 use Imi\Model\Annotation\Entity;
+use Imi\Model\Annotation\Table;
+use Imi\Pgsql\Model\PgModel as Model;
 
 /**
- * World 基类
+ * World 基类.
+ *
  * @Entity(bean=false)
- * @Table(name="World", id={"id"}, dbPoolName="pgsql")
+ * @Table(name=@ConfigValue(name="@app.models.ImiApp\Model\PgSql\World.name", default="World"), usePrefix=false, id={"id"}, dbPoolName=@ConfigValue(name="@app.models.ImiApp\Model\PgSql\World.poolName", default="pgsql"))
+ *
  * @property int|null $id 
  * @property int|null $randomnumber 
  */
 abstract class WorldBase extends Model
 {
     /**
-     * id
-     * @Column(name="id", type="int4", length=-1, accuracy=0, nullable=false, default="", isPrimaryKey=true, primaryKeyIndex=1, isAutoIncrement=false, ndims=0)
+     * {@inheritdoc}
+     */
+    public const PRIMARY_KEY = 'id';
+
+    /**
+     * {@inheritdoc}
+     */
+    public const PRIMARY_KEYS = ["id"];
+
+    /**
+     * id.
+
+     * @Column(name="id", type="int4", length=-1, accuracy=0, nullable=false, default="", isPrimaryKey=true, primaryKeyIndex=1, isAutoIncrement=false, ndims=0, virtual=false)
      * @var int|null
      */
-    protected ?int $id = null;
+    protected ?int $id = NULL;
 
     /**
-     * 获取 id
+     * 获取 id.
      *
      * @return int|null
      */
@@ -35,7 +50,8 @@ abstract class WorldBase extends Model
     }
 
     /**
-     * 赋值 id
+     * 赋值 id.
+     *
      * @param int|null $id id
      * @return static
      */
@@ -46,14 +62,15 @@ abstract class WorldBase extends Model
     }
 
     /**
-     * randomnumber
-     * @Column(name="randomnumber", type="int4", length=-1, accuracy=0, nullable=false, default="0", isPrimaryKey=false, primaryKeyIndex=-1, isAutoIncrement=false, ndims=0)
+     * randomnumber.
+
+     * @Column(name="randomnumber", type="int4", length=-1, accuracy=0, nullable=false, default="0", isPrimaryKey=false, primaryKeyIndex=-1, isAutoIncrement=false, ndims=0, virtual=false)
      * @var int|null
      */
-    protected ?int $randomnumber = null;
+    protected ?int $randomnumber = 0;
 
     /**
-     * 获取 randomnumber
+     * 获取 randomnumber.
      *
      * @return int|null
      */
@@ -63,7 +80,8 @@ abstract class WorldBase extends Model
     }
 
     /**
-     * 赋值 randomnumber
+     * 赋值 randomnumber.
+     *
      * @param int|null $randomnumber randomnumber
      * @return static
      */

+ 1 - 1
frameworks/PHP/imi/config/config.php

@@ -98,7 +98,7 @@ return (function() {
                     'username'    => env('DB_USERNAME', 'benchmarkdbuser'),
                     'password'    => env('DB_PASSWORD', 'benchmarkdbpass'),
                     'database'    => 'hello_world',
-                    'dbClass'     => \Imi\Swoole\Db\Driver\Swoole\Driver::class,
+                    'dbClass'     => \Imi\Db\Mysql\Drivers\Mysqli\Driver::class,
                 ],
             ],
             'pgsql' => [

+ 2 - 2
frameworks/PHP/imi/imi-swoole.dockerfile

@@ -1,10 +1,10 @@
-FROM php:8.1-cli
+FROM php:8.2-cli
 
 ENV SWOOLE_VERSION 5.0.1
 ARG TFB_TEST_DATABASE
 ENV TFB_TEST_DATABASE=${TFB_TEST_DATABASE}
 
-RUN docker-php-ext-install -j$(nproc) opcache
+RUN docker-php-ext-install -j$(nproc) opcache mysqli
 
 RUN apt -yqq update && \
     apt -yqq install git unzip libpq-dev

+ 1 - 1
frameworks/PHP/imi/imi-workerman.dockerfile

@@ -1,4 +1,4 @@
-FROM php:8.1-cli
+FROM php:8.2-cli
 
 ARG TFB_TEST_DATABASE
 ENV TFB_TEST_DATABASE=${TFB_TEST_DATABASE}