Skip to content

Commit 4ef25d3

Browse files
authored
[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
1 parent ecc0e25 commit 4ef25d3

File tree

7 files changed

+128
-64
lines changed

7 files changed

+128
-64
lines changed

frameworks/PHP/imi/Model/Base/FortuneBase.php

+30-16
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,47 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace ImiApp\Model\Base;
56

6-
use Imi\Model\Model as Model;
7-
use Imi\Model\Annotation\DDL;
8-
use Imi\Model\Annotation\Table;
7+
use Imi\Config\Annotation\ConfigValue;
98
use Imi\Model\Annotation\Column;
9+
use Imi\Model\Annotation\DDL;
1010
use Imi\Model\Annotation\Entity;
11+
use Imi\Model\Annotation\Table;
12+
use Imi\Model\Model as Model;
1113

1214
/**
13-
* fortune 基类
14-
* @Entity(bean=false)
15-
* @Table(name="fortune", id={"id"})
15+
* fortune 基类.
16+
*
17+
* @Entity(camel=true, bean=false, incrUpdate=false)
18+
* @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"))
1619
* @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="")
20+
*
1721
* @property int|null $id
1822
* @property string|null $message
1923
*/
2024
abstract class FortuneBase extends Model
2125
{
2226
/**
23-
* id
24-
* @Column(name="id", type="int", length=10, accuracy=0, nullable=false, default="", isPrimaryKey=true, primaryKeyIndex=0, isAutoIncrement=true)
27+
* {@inheritdoc}
28+
*/
29+
public const PRIMARY_KEY = 'id';
30+
31+
/**
32+
* {@inheritdoc}
33+
*/
34+
public const PRIMARY_KEYS = ["id"];
35+
36+
/**
37+
* id.
38+
* @Column(name="id", type="int", length=10, accuracy=0, nullable=false, default="", isPrimaryKey=true, primaryKeyIndex=0, isAutoIncrement=true, unsigned=true, virtual=false)
2539
* @var int|null
2640
*/
27-
protected ?int $id = null;
41+
protected ?int $id = NULL;
2842

2943
/**
30-
* 获取 id
44+
* 获取 id.
3145
*
3246
* @return int|null
3347
*/
@@ -37,7 +51,7 @@ public function getId(): ?int
3751
}
3852

3953
/**
40-
* 赋值 id
54+
* 赋值 id.
4155
* @param int|null $id id
4256
* @return static
4357
*/
@@ -48,14 +62,14 @@ public function setId($id)
4862
}
4963

5064
/**
51-
* message
52-
* @Column(name="message", type="varchar", length=2048, accuracy=0, nullable=false, default="", isPrimaryKey=false, primaryKeyIndex=-1, isAutoIncrement=false)
65+
* message.
66+
* @Column(name="message", type="varchar", length=2048, accuracy=0, nullable=false, default="", isPrimaryKey=false, primaryKeyIndex=-1, isAutoIncrement=false, unsigned=false, virtual=false)
5367
* @var string|null
5468
*/
55-
protected ?string $message = null;
69+
protected ?string $message = NULL;
5670

5771
/**
58-
* 获取 message
72+
* 获取 message.
5973
*
6074
* @return string|null
6175
*/
@@ -65,7 +79,7 @@ public function getMessage(): ?string
6579
}
6680

6781
/**
68-
* 赋值 message
82+
* 赋值 message.
6983
* @param string|null $message message
7084
* @return static
7185
*/

frameworks/PHP/imi/Model/Base/WorldBase.php

+30-16
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,47 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace ImiApp\Model\Base;
56

6-
use Imi\Model\Model as Model;
7-
use Imi\Model\Annotation\DDL;
8-
use Imi\Model\Annotation\Table;
7+
use Imi\Config\Annotation\ConfigValue;
98
use Imi\Model\Annotation\Column;
9+
use Imi\Model\Annotation\DDL;
1010
use Imi\Model\Annotation\Entity;
11+
use Imi\Model\Annotation\Table;
12+
use Imi\Model\Model as Model;
1113

1214
/**
13-
* world 基类
14-
* @Entity(bean=false)
15-
* @Table(name="world", id={"id"})
15+
* world 基类.
16+
*
17+
* @Entity(camel=true, bean=false, incrUpdate=false)
18+
* @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"))
1619
* @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="")
20+
*
1721
* @property int|null $id
1822
* @property int|null $randomNumber
1923
*/
2024
abstract class WorldBase extends Model
2125
{
2226
/**
23-
* id
24-
* @Column(name="id", type="int", length=10, accuracy=0, nullable=false, default="", isPrimaryKey=true, primaryKeyIndex=0, isAutoIncrement=true)
27+
* {@inheritdoc}
28+
*/
29+
public const PRIMARY_KEY = 'id';
30+
31+
/**
32+
* {@inheritdoc}
33+
*/
34+
public const PRIMARY_KEYS = ["id"];
35+
36+
/**
37+
* id.
38+
* @Column(name="id", type="int", length=10, accuracy=0, nullable=false, default="", isPrimaryKey=true, primaryKeyIndex=0, isAutoIncrement=true, unsigned=true, virtual=false)
2539
* @var int|null
2640
*/
27-
protected ?int $id = null;
41+
protected ?int $id = NULL;
2842

2943
/**
30-
* 获取 id
44+
* 获取 id.
3145
*
3246
* @return int|null
3347
*/
@@ -37,7 +51,7 @@ public function getId(): ?int
3751
}
3852

3953
/**
40-
* 赋值 id
54+
* 赋值 id.
4155
* @param int|null $id id
4256
* @return static
4357
*/
@@ -48,14 +62,14 @@ public function setId($id)
4862
}
4963

5064
/**
51-
* randomNumber
52-
* @Column(name="randomNumber", type="int", length=11, accuracy=0, nullable=false, default="0", isPrimaryKey=false, primaryKeyIndex=-1, isAutoIncrement=false)
65+
* randomNumber.
66+
* @Column(name="randomNumber", type="int", length=11, accuracy=0, nullable=false, default="0", isPrimaryKey=false, primaryKeyIndex=-1, isAutoIncrement=false, unsigned=false, virtual=false)
5367
* @var int|null
5468
*/
55-
protected ?int $randomNumber = null;
69+
protected ?int $randomNumber = 0;
5670

5771
/**
58-
* 获取 randomNumber
72+
* 获取 randomNumber.
5973
*
6074
* @return int|null
6175
*/
@@ -65,7 +79,7 @@ public function getRandomNumber(): ?int
6579
}
6680

6781
/**
68-
* 赋值 randomNumber
82+
* 赋值 randomNumber.
6983
* @param int|null $randomNumber randomNumber
7084
* @return static
7185
*/

frameworks/PHP/imi/Model/PgSql/Base/FortuneBase.php

+32-14
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,46 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace ImiApp\Model\PgSql\Base;
56

6-
use Imi\Pgsql\Model\PgModel as Model;
7-
use Imi\Model\Annotation\Table;
7+
use Imi\Config\Annotation\ConfigValue;
88
use Imi\Model\Annotation\Column;
99
use Imi\Model\Annotation\Entity;
10+
use Imi\Model\Annotation\Table;
11+
use Imi\Pgsql\Model\PgModel as Model;
1012

1113
/**
12-
* Fortune 基类
14+
* fortune 基类.
15+
*
1316
* @Entity(bean=false)
14-
* @Table(name="Fortune", id={"id"}, dbPoolName="pgsql")
17+
* @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"))
18+
*
1519
* @property int|null $id
1620
* @property string|null $message
1721
*/
1822
abstract class FortuneBase extends Model
1923
{
2024
/**
21-
* id
22-
* @Column(name="id", type="int4", length=-1, accuracy=0, nullable=false, default="", isPrimaryKey=true, primaryKeyIndex=1, isAutoIncrement=false, ndims=0)
25+
* {@inheritdoc}
26+
*/
27+
public const PRIMARY_KEY = 'id';
28+
29+
/**
30+
* {@inheritdoc}
31+
*/
32+
public const PRIMARY_KEYS = ["id"];
33+
34+
/**
35+
* id.
36+
37+
* @Column(name="id", type="int4", length=-1, accuracy=0, nullable=false, default="", isPrimaryKey=true, primaryKeyIndex=1, isAutoIncrement=false, ndims=0, virtual=false)
2338
* @var int|null
2439
*/
25-
protected ?int $id = null;
40+
protected ?int $id = NULL;
2641

2742
/**
28-
* 获取 id
43+
* 获取 id.
2944
*
3045
* @return int|null
3146
*/
@@ -35,7 +50,8 @@ public function getId(): ?int
3550
}
3651

3752
/**
38-
* 赋值 id
53+
* 赋值 id.
54+
*
3955
* @param int|null $id id
4056
* @return static
4157
*/
@@ -46,14 +62,15 @@ public function setId(?int $id)
4662
}
4763

4864
/**
49-
* message
50-
* @Column(name="message", type="varchar", length=0, accuracy=2048, nullable=false, default="", isPrimaryKey=false, primaryKeyIndex=-1, isAutoIncrement=false, ndims=0)
65+
* message.
66+
67+
* @Column(name="message", type="varchar", length=0, accuracy=2048, nullable=false, default="", isPrimaryKey=false, primaryKeyIndex=-1, isAutoIncrement=false, ndims=0, virtual=false)
5168
* @var string|null
5269
*/
53-
protected ?string $message = null;
70+
protected ?string $message = NULL;
5471

5572
/**
56-
* 获取 message
73+
* 获取 message.
5774
*
5875
* @return string|null
5976
*/
@@ -63,7 +80,8 @@ public function getMessage(): ?string
6380
}
6481

6582
/**
66-
* 赋值 message
83+
* 赋值 message.
84+
*
6785
* @param string|null $message message
6886
* @return static
6987
*/

frameworks/PHP/imi/Model/PgSql/Base/WorldBase.php

+32-14
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,46 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace ImiApp\Model\PgSql\Base;
56

6-
use Imi\Pgsql\Model\PgModel as Model;
7-
use Imi\Model\Annotation\Table;
7+
use Imi\Config\Annotation\ConfigValue;
88
use Imi\Model\Annotation\Column;
99
use Imi\Model\Annotation\Entity;
10+
use Imi\Model\Annotation\Table;
11+
use Imi\Pgsql\Model\PgModel as Model;
1012

1113
/**
12-
* World 基类
14+
* World 基类.
15+
*
1316
* @Entity(bean=false)
14-
* @Table(name="World", id={"id"}, dbPoolName="pgsql")
17+
* @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"))
18+
*
1519
* @property int|null $id
1620
* @property int|null $randomnumber
1721
*/
1822
abstract class WorldBase extends Model
1923
{
2024
/**
21-
* id
22-
* @Column(name="id", type="int4", length=-1, accuracy=0, nullable=false, default="", isPrimaryKey=true, primaryKeyIndex=1, isAutoIncrement=false, ndims=0)
25+
* {@inheritdoc}
26+
*/
27+
public const PRIMARY_KEY = 'id';
28+
29+
/**
30+
* {@inheritdoc}
31+
*/
32+
public const PRIMARY_KEYS = ["id"];
33+
34+
/**
35+
* id.
36+
37+
* @Column(name="id", type="int4", length=-1, accuracy=0, nullable=false, default="", isPrimaryKey=true, primaryKeyIndex=1, isAutoIncrement=false, ndims=0, virtual=false)
2338
* @var int|null
2439
*/
25-
protected ?int $id = null;
40+
protected ?int $id = NULL;
2641

2742
/**
28-
* 获取 id
43+
* 获取 id.
2944
*
3045
* @return int|null
3146
*/
@@ -35,7 +50,8 @@ public function getId(): ?int
3550
}
3651

3752
/**
38-
* 赋值 id
53+
* 赋值 id.
54+
*
3955
* @param int|null $id id
4056
* @return static
4157
*/
@@ -46,14 +62,15 @@ public function setId(?int $id)
4662
}
4763

4864
/**
49-
* randomnumber
50-
* @Column(name="randomnumber", type="int4", length=-1, accuracy=0, nullable=false, default="0", isPrimaryKey=false, primaryKeyIndex=-1, isAutoIncrement=false, ndims=0)
65+
* randomnumber.
66+
67+
* @Column(name="randomnumber", type="int4", length=-1, accuracy=0, nullable=false, default="0", isPrimaryKey=false, primaryKeyIndex=-1, isAutoIncrement=false, ndims=0, virtual=false)
5168
* @var int|null
5269
*/
53-
protected ?int $randomnumber = null;
70+
protected ?int $randomnumber = 0;
5471

5572
/**
56-
* 获取 randomnumber
73+
* 获取 randomnumber.
5774
*
5875
* @return int|null
5976
*/
@@ -63,7 +80,8 @@ public function getRandomnumber(): ?int
6380
}
6481

6582
/**
66-
* 赋值 randomnumber
83+
* 赋值 randomnumber.
84+
*
6785
* @param int|null $randomnumber randomnumber
6886
* @return static
6987
*/

frameworks/PHP/imi/config/config.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
'username' => env('DB_USERNAME', 'benchmarkdbuser'),
9999
'password' => env('DB_PASSWORD', 'benchmarkdbpass'),
100100
'database' => 'hello_world',
101-
'dbClass' => \Imi\Swoole\Db\Driver\Swoole\Driver::class,
101+
'dbClass' => \Imi\Db\Mysql\Drivers\Mysqli\Driver::class,
102102
],
103103
],
104104
'pgsql' => [

0 commit comments

Comments
 (0)