Skip to content

Commit 0d7c8c0

Browse files
committed
change syntax sugar ?type to null|type
1 parent 435252a commit 0d7c8c0

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

src/Commands/MakeEntity.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function handle(): int
107107
$attributes .= $this->writeAttribute(
108108
$attributeStub,
109109
$_column->COLUMN_NAME,
110-
($_column->IS_NULLABLE === 'YES' ? '?' : '') . $this->dataTypes[$_column->DATA_TYPE]
110+
($_column->IS_NULLABLE === 'YES' ? 'null|' : '') . $this->dataTypes[$_column->DATA_TYPE]
111111
);
112112
}
113113

@@ -117,7 +117,7 @@ public function handle(): int
117117
$settersAndGetters .= $this->writeAccessors(
118118
$accessorsStub,
119119
$_column->COLUMN_NAME,
120-
($_column->IS_NULLABLE === 'YES' ? '?' : '') . $this->dataTypes[$_column->DATA_TYPE]
120+
($_column->IS_NULLABLE === 'YES' ? 'null|' : '') . $this->dataTypes[$_column->DATA_TYPE]
121121
);
122122
}
123123

src/Commands/MakeRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class MakeRepository extends Command
3131
private function writeFunction(string $functionStub, string $functionName, string $columnName, string $attributeType): string
3232
{
3333
if ($functionName === 'getOneBy') {
34-
$functionReturnType = '?{{ EntityName }}';
34+
$functionReturnType = 'null|{{ EntityName }}';
3535
$functionName .= ucfirst(Str::camel($columnName));
3636
$columnName = Str::camel($columnName);
3737
} elseif ($functionName === 'getAllBy') {

src/Models/Enums/Enum.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function getList(): array
1111
return (new ReflectionClass($this))->getConstants();
1212
}
1313

14-
public function getValue(int|string $key): ?string
14+
public function getValue(int|string $key): null|string
1515
{
1616
$list = $this->getList();
1717
$keys = array_keys($list);

src/Models/Repositories/MySqlRepository.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
abstract class MySqlRepository
1414
{
15-
private ?ConnectionInterface $alternativeDbConnection;
15+
private null|ConnectionInterface $alternativeDbConnection;
1616

1717
protected string $primaryKey = 'id';
1818

@@ -72,7 +72,7 @@ public function newQuery(): Builder
7272
* @param array $filters
7373
* @return Collection
7474
*/
75-
public function getAllForGridView(?int &$total, int $offset = 0, int $count = 0, array $orders = [], array $filters = []): Collection
75+
public function getAllForGridView(null|int &$total, int $offset = 0, int $count = 0, array $orders = [], array $filters = []): Collection
7676
{
7777
$query = $this->newQuery();
7878

@@ -166,7 +166,7 @@ public function getMaxId()
166166
* @param array $filters
167167
* @return Builder
168168
*/
169-
protected function processGridViewQuery(Builder $query, ?int &$total, int $offset = 0, int $count = 0, array $orders = [], array $filters = []): Builder
169+
protected function processGridViewQuery(Builder $query, null|int &$total, int $offset = 0, int $count = 0, array $orders = [], array $filters = []): Builder
170170
{
171171
if ($orders) {
172172
$query = $this->processOrder($query, $orders);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11

2-
public function getOneBy{{ FunctionName }}(int ${{ AttributeName }}): ?{{ EntityName }};
2+
public function getOneBy{{ FunctionName }}(int ${{ AttributeName }}): null|{{ EntityName }};

stubs/Repositories/Mysql/mysql.getOneBy.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @param int ${{ AttributeName }}
44
* @return {{ EntityName }}|null
55
*/
6-
public function getOneBy{{ FunctionName }}(int ${{ AttributeName }}): ?{{ EntityName }}
6+
public function getOneBy{{ FunctionName }}(int ${{ AttributeName }}): null|{{ EntityName }}
77
{
88
${{ EntityVariableName }} = $this->newQuery()
99
->where('{{ ColumnName }}', ${{ AttributeName }})

0 commit comments

Comments
 (0)