Skip to content

Commit 5b45f54

Browse files
author
rotimi
committed
PHP 8.1 min version readiness
1 parent 2ff8a08 commit 5b45f54

File tree

7 files changed

+69
-119
lines changed

7 files changed

+69
-119
lines changed

.github/workflows/php.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,19 @@ jobs:
1616

1717
strategy:
1818
matrix:
19-
php: [8.1, 8.0, 7.4]
19+
php: [8.2, 8.1]
2020
# prefer-lowest is causing unit tests to fail when php 7.2 is run against PHPunit 7.x,
2121
# PHPUnit 8.x is the latest stable release that supports PHP 7.2 and that runs fine
2222
# dependency-version: [prefer-lowest, prefer-stable]
2323
dependency-version: [prefer-stable]
2424
os: [ubuntu-20.04, ubuntu-22.04]
2525
include:
26-
- os: ubuntu-20.04
27-
php: 7.4
28-
- os: ubuntu-20.04
29-
php: 8.0
3026
- os: ubuntu-20.04
3127
php: 8.1
3228
- os: ubuntu-22.04
3329
php: 8.1
30+
- os: ubuntu-22.04
31+
php: 8.2
3432
#exclude:
3533
#- os: ubuntu-20.04
3634
#php: 7.3

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
}
1515
],
1616
"require": {
17-
"php": ">=7.4"
17+
"php": ">=8.1"
1818
},
1919
"require-dev": {
20-
"phpunit/phpunit": "^9.0",
20+
"phpunit/phpunit": "^10.0",
2121
"php-coveralls/php-coveralls": "^2.0",
2222
"vimeo/psalm": "^5.4.0",
2323
"rector/rector": "^0.15.0"

rector.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
$rectorConfigurator->import(SetList::PHP_72);
2424
$rectorConfigurator->import(SetList::PHP_73);
2525
$rectorConfigurator->import(SetList::PHP_74);
26-
//$containerConfigurator->import(SetList::PHP_80);
27-
//$containerConfigurator->import(SetList::PHP_81);
26+
$rectorConfigurator->import(SetList::PHP_80);
27+
$rectorConfigurator->import(SetList::PHP_81);
2828
$rectorConfigurator->import(SetList::CODE_QUALITY);
2929
$rectorConfigurator->import(SetList::CODING_STYLE);
3030
$rectorConfigurator->import(SetList::DEAD_CODE);
@@ -38,7 +38,4 @@
3838
$services->remove(\Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector::class);
3939
$services->remove(\Rector\CodingStyle\Rector\ClassMethod\UnSpreadOperatorRector::class);
4040
$services->remove(\Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector::class);
41-
42-
//TODO:PHP8 comment once PHP 8 becomes minimum version
43-
(PHP_MAJOR_VERSION < 8) && $services->remove(Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPromotedPropertyRector::class);
4441
};

src/GDAO/Model.php

+21-21
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* the future.
1313
*
1414
* @author Rotimi Adegbamigbe
15-
* @copyright (c) 2022, Rotexsoft
15+
* @copyright (c) 2023, Rotexsoft
1616
*/
1717
abstract class Model {
1818

@@ -604,22 +604,22 @@ abstract class Model {
604604
/**
605605
* @var string
606606
*/
607-
public const RELATION_TYPE_HAS_ONE = 'rt_ho';
607+
final public const RELATION_TYPE_HAS_ONE = 'rt_ho';
608608

609609
/**
610610
* @var string
611611
*/
612-
public const RELATION_TYPE_HAS_MANY = 'rt_hm';
612+
final public const RELATION_TYPE_HAS_MANY = 'rt_hm';
613613

614614
/**
615615
* @var string
616616
*/
617-
public const RELATION_TYPE_BELONGS_TO = 'rt_bt';
617+
final public const RELATION_TYPE_BELONGS_TO = 'rt_bt';
618618

619619
/**
620620
* @var string
621621
*/
622-
public const RELATION_TYPE_HAS_MANY_THROUGH = 'rt_hmt';
622+
final public const RELATION_TYPE_HAS_MANY_THROUGH = 'rt_hmt';
623623

624624
/**
625625
* A PDO compliant Data Source Name (DSN) string containing the information
@@ -1467,7 +1467,7 @@ public abstract function fetchPairs(?object $query = null): array;
14671467
*
14681468
* @throws \PDOException
14691469
*/
1470-
public abstract function fetchValue(?object $query = null);
1470+
public abstract function fetchValue(?object $query = null): mixed;
14711471

14721472
/**
14731473
* Return the PDO object powering this model or throw
@@ -1511,7 +1511,7 @@ public abstract function getPDO(): \PDO;
15111511
* @throws \GDAO\ModelInvalidInsertValueSuppliedException
15121512
* @throws \GDAO\ModelPrimaryColValueNotRetrievableAfterInsertException
15131513
*/
1514-
public abstract function insert(array $data_2_insert = []);
1514+
public abstract function insert(array $data_2_insert = []): bool|array;
15151515

15161516
/**
15171517
* Insert one or more rows to the model table with the specified values.
@@ -1604,7 +1604,7 @@ public abstract function insertMany(array $rows_of_data_2_insert = []): bool;
16041604
public abstract function updateMatchingDbTableRows(
16051605
array $col_names_n_values_2_save = [],
16061606
array $col_names_n_values_2_match = []
1607-
):self;
1607+
): static;
16081608

16091609
/**
16101610
* Update the specified record in the database.
@@ -1617,7 +1617,7 @@ public abstract function updateMatchingDbTableRows(
16171617
*
16181618
* @throws \PDOException
16191619
*/
1620-
public abstract function updateSpecifiedRecord(\GDAO\Model\RecordInterface $record): self;
1620+
public abstract function updateSpecifiedRecord(\GDAO\Model\RecordInterface $record): static;
16211621

16221622
//////////////////////////////////////
16231623
// Getters for non-public properties
@@ -1763,13 +1763,13 @@ public function getUsername(): string {
17631763
return $this->username;
17641764
}
17651765

1766-
public function setCollectionClassName(?string $collection_class_name): self {
1766+
public function setCollectionClassName(?string $collection_class_name): static {
17671767

17681768
$this->collection_class_name = $collection_class_name;
17691769
return $this;
17701770
}
17711771

1772-
public function setCreatedTimestampColumnName(?string $created_timestamp_column_name): self {
1772+
public function setCreatedTimestampColumnName(?string $created_timestamp_column_name): static {
17731773

17741774
$this->created_timestamp_column_name = $created_timestamp_column_name;
17751775
return $this;
@@ -1781,7 +1781,7 @@ public function setCreatedTimestampColumnName(?string $created_timestamp_column_
17811781
* that can be used for connecting to the DB then setting this property would make
17821782
* sense.
17831783
*/
1784-
public function setDsn(string $dsn): self {
1784+
public function setDsn(string $dsn): static {
17851785

17861786
$this->dsn = $dsn;
17871787
return $this;
@@ -1793,7 +1793,7 @@ public function setDsn(string $dsn): self {
17931793
* that can be used for connecting to the DB then setting this property would make
17941794
* sense.
17951795
*/
1796-
public function setPasswd(string $passwd): self {
1796+
public function setPasswd(string $passwd): static {
17971797

17981798
$this->passwd = $passwd;
17991799
return $this;
@@ -1802,19 +1802,19 @@ public function setPasswd(string $passwd): self {
18021802
/**
18031803
* @param mixed[] $pdo_driver_opts
18041804
*/
1805-
public function setPdoDriverOpts(array $pdo_driver_opts): self {
1805+
public function setPdoDriverOpts(array $pdo_driver_opts): static {
18061806

18071807
$this->pdo_driver_opts = $pdo_driver_opts;
18081808
return $this;
18091809
}
18101810

1811-
public function setPrimaryCol(string $primary_col): self {
1811+
public function setPrimaryCol(string $primary_col): static {
18121812

18131813
$this->primary_col = $primary_col;
18141814
return $this;
18151815
}
18161816

1817-
public function setRecordClassName(?string $record_class_name): self {
1817+
public function setRecordClassName(?string $record_class_name): static {
18181818

18191819
$this->record_class_name = $record_class_name;
18201820
return $this;
@@ -1823,7 +1823,7 @@ public function setRecordClassName(?string $record_class_name): self {
18231823
/**
18241824
* @param mixed[] $relations
18251825
*/
1826-
public function setRelations(array $relations): self {
1826+
public function setRelations(array $relations): static {
18271827

18281828
$this->relations = $relations;
18291829
return $this;
@@ -1832,19 +1832,19 @@ public function setRelations(array $relations): self {
18321832
/**
18331833
* @param mixed[] $table_cols
18341834
*/
1835-
public function setTableCols(array $table_cols): self {
1835+
public function setTableCols(array $table_cols): static {
18361836

18371837
$this->table_cols = $table_cols;
18381838
return $this;
18391839
}
18401840

1841-
public function setTableName(string $table_name): self {
1841+
public function setTableName(string $table_name): static {
18421842

18431843
$this->table_name = $table_name;
18441844
return $this;
18451845
}
18461846

1847-
public function setUpdatedTimestampColumnName(?string $updated_timestamp_column_name): self {
1847+
public function setUpdatedTimestampColumnName(?string $updated_timestamp_column_name): static {
18481848

18491849
$this->updated_timestamp_column_name = $updated_timestamp_column_name;
18501850
return $this;
@@ -1856,7 +1856,7 @@ public function setUpdatedTimestampColumnName(?string $updated_timestamp_column_
18561856
* that can be used for connecting to the DB then setting this property would make
18571857
* sense.
18581858
*/
1859-
public function setUsername(string $username): self {
1859+
public function setUsername(string $username): static {
18601860

18611861
$this->username = $username;
18621862
return $this;

0 commit comments

Comments
 (0)