Skip to content

Commit

Permalink
Update to require PHP 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
brianlmoon committed Sep 26, 2022
1 parent 41e832b commit 05d253f
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 33 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ phpunit.xml
*.sublime-project

# test artifacts
tests/fixtures/test_copy.db
tests/fixtures/test_copy.db
.phpunit.result.cache
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"license": "BSD-3-Clause",
"description": "PHP Library for implementing the Data Mapper pattern",
"require": {
"php": "^7.3",
"dealnews/repository": "^2.0"
"php": "^8.0",
"dealnews/repository": "^3.0"
},
"autoload": {
"psr-4": {
Expand Down
41 changes: 20 additions & 21 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/bootstrap.php"
colors="true">
<testsuites>
<testsuite name="default">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<groups>
<exclude>
<group>functional</group>
</exclude>
</groups>
<filter>
<whitelist>
<directory>./src</directory>
</whitelist>
</filter>
<php>
<env name="DN_INI_FILE" value="./tests/fixtures/test.ini"/>
</php>
</phpunit>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="./tests/bootstrap.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory>./src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="default">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<groups>
<exclude>
<group>functional</group>
</exclude>
</groups>
<php>
<env name="DN_INI_FILE" value="./tests/fixtures/test.ini"/>
</php>
</phpunit>
10 changes: 5 additions & 5 deletions src/AbstractMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ abstract class AbstractMapper implements Mapper {
* Returns the name of the primary key property for
* the object being mapped
*
* @return int|string
* @return string
*/
public function getPrimaryKey() {
public function getPrimaryKey(): string {
return static::PRIMARY_KEY;
}

Expand All @@ -45,7 +45,7 @@ public function getPrimaryKey() {
*
* @return string
*/
public static function getMappedClass() {
public static function getMappedClass(): string {
return static::MAPPED_CLASS;
}

Expand All @@ -57,7 +57,7 @@ public static function getMappedClass() {
*
* @suppress PhanTypeExpectedObjectOrClassName
*/
protected function setData(array $data) {
protected function setData(array $data): object {
$class = $this::MAPPED_CLASS;
$object = new $class();
foreach ($this::MAPPING as $property => $mapping) {
Expand All @@ -76,7 +76,7 @@ protected function setData(array $data) {
*
* @return array
*/
protected function getData($object) {
protected function getData($object): array {
$data = [];
foreach ($this::MAPPING as $property => $mapping) {
$data[$property] = $this->getValue($object, $property, $mapping);
Expand Down
8 changes: 4 additions & 4 deletions src/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ class Repository extends \DealNews\Repository\Repository {
* Keeps the list of mappers
* @var array
*/
protected $mappers = [];
protected array $mappers = [];

/**
* Keeps the list of classes
* @var array
*/
protected $classes = [];
protected array $classes = [];

/**
* Creates the repository
Expand All @@ -44,7 +44,7 @@ public function __construct(array $mappers = []) {
*
* @param string $name Mapped Object name
*/
public function new(string $name) {
public function new(string $name): object {
if (!isset($this->classes[$name])) {
throw new \LogicException("There is no class registered for `$name`", 1);
}
Expand All @@ -61,7 +61,7 @@ public function new(string $name) {
*
* @return boolean
*/
public function delete(string $name, $id) {
public function delete(string $name, $id): bool {
if (!isset($this->classes[$name])) {
throw new \LogicException("There is no class registered for `$name`", 2);
}
Expand Down

0 comments on commit 05d253f

Please sign in to comment.