Skip to content

Commit

Permalink
Merge pull request #373 from j4mie/aaronpk-master
Browse files Browse the repository at this point in the history
Annotations for PHP 8.1 compatibility and GitHub actions CI
  • Loading branch information
treffynnon authored Jul 18, 2022
2 parents 1467659 + 98db4ff commit 6da4e7e
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 50 deletions.
26 changes: 18 additions & 8 deletions .github/workflows/idiorm-workflow.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
env:
REGISTRY: ghcr.io
IMAGE_NAME: treffynnon/php5.2cli:latest

on: [push, pull_request]
on: push

jobs:
test-idiorm-with-php5-2:
Expand All @@ -11,6 +8,10 @@ jobs:
contents: read
packages: read

env:
REGISTRY: ghcr.io
IMAGE_NAME: treffynnon/php5.2cli:latest

name: 'PHP 5.2'
steps:
- name: Checkout repository
Expand All @@ -26,7 +27,13 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['5.4', '5.6', '7.0', '7.1', '7.4']
php-versions: ['5.4', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
phpunit-versions: ['4.8']
include:
- php-versions: '8.0'
phpunit-versions: '8.5.21'
- php-versions: '8.2'
phpunit-versions: '8.5.21'

name: PHP ${{ matrix.php-versions }}

Expand All @@ -39,13 +46,16 @@ jobs:
with:
php-version: ${{ matrix.php-versions }}
coverage: xdebug
tools: composer
tools: composer, phpunit:${{ matrix.phpunit-versions }}

- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Install composer deps
run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Add PHP 8 return types
if: ${{ matrix.php-versions >= '8.0' }}
run: |
sed -i 's#setUp()#setUp(): void#' test/*.php
sed -i 's#tearDown()#tearDown(): void#' test/*.php
- name: Run phpunit tests
run: composer run-script test -- --colors --coverage-text
42 changes: 0 additions & 42 deletions .travis.yml

This file was deleted.

5 changes: 5 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ is a Docker setup in `./test/docker_for_php52` - check the readme in there for m
Changelog
---------

#### 1.5.8 - released 2022-07-18

* Update to support PHP 8.1 [[edlerd](https://github.com/edlerd) and [aaronpk](https://github.com/aaronpk)] - [issue #370](https://github.com/j4mie/idiorm/pull/370) and [issue #372](https://github.com/j4mie/idiorm/pull/372)
* GitHub actions used to perform unit testing/CI [[Treffynnon](https://github.com/treffynnon) and [yan12125](https://github.com/yan12125)]

#### 1.5.7 - released 2020-04-29

* Fix argument order in call to join() [[CatalinFrancu](https://github.com/CatalinFrancu)] - [issue #357](https://github.com/j4mie/idiorm/pull/357)
Expand Down
18 changes: 18 additions & 0 deletions idiorm.php
Original file line number Diff line number Diff line change
Expand Up @@ -2209,21 +2209,25 @@ public function delete_many() {
// --- ArrayAccess --- //
// --------------------- //

#[\ReturnTypeWillChange]
public function offsetExists($key) {
return array_key_exists($key, $this->_data);
}

#[\ReturnTypeWillChange]
public function offsetGet($key) {
return $this->get($key);
}

#[\ReturnTypeWillChange]
public function offsetSet($key, $value) {
if(is_null($key)) {
throw new InvalidArgumentException('You must specify a key/array index.');
}
$this->set($key, $value);
}

#[\ReturnTypeWillChange]
public function offsetUnset($key) {
unset($this->_data[$key]);
unset($this->_dirty_fields[$key]);
Expand Down Expand Up @@ -2445,6 +2449,7 @@ public function as_array() {
* Get the number of records in the result set
* @return int
*/
#[\ReturnTypeWillChange]
public function count() {
return count($this->_results);
}
Expand All @@ -2454,6 +2459,7 @@ public function count() {
* over the result set.
* @return \ArrayIterator
*/
#[\ReturnTypeWillChange]
public function getIterator() {
return new ArrayIterator($this->_results);
}
Expand All @@ -2463,6 +2469,7 @@ public function getIterator() {
* @param int|string $offset
* @return bool
*/
#[\ReturnTypeWillChange]
public function offsetExists($offset) {
return isset($this->_results[$offset]);
}
Expand All @@ -2472,6 +2479,7 @@ public function offsetExists($offset) {
* @param int|string $offset
* @return mixed
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset) {
return $this->_results[$offset];
}
Expand All @@ -2481,6 +2489,7 @@ public function offsetGet($offset) {
* @param int|string $offset
* @param mixed $value
*/
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value) {
$this->_results[$offset] = $value;
}
Expand All @@ -2489,10 +2498,19 @@ public function offsetSet($offset, $value) {
* ArrayAccess
* @param int|string $offset
*/
#[\ReturnTypeWillChange]
public function offsetUnset($offset) {
unset($this->_results[$offset]);
}

public function __serialize() {
return $this->serialize();
}

public function __unserialize($data) {
$this->unserialize($data);
}

/**
* Serializable
* @return string
Expand Down
7 changes: 7 additions & 0 deletions test/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,10 @@ public function getAttribute($attribute) {
}

}

/**
* Alias the test case class so that these same tests can run against PHPUnit >4
*/
if (!class_exists('PHPUnit_Framework_TestCase')) {
class_alias('\PHPUnit\Framework\TestCase', 'PHPUnit_Framework_TestCase');
}
1 change: 1 addition & 0 deletions test/docker_for_php52/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ FROM ubuntu:12.04

RUN mkdir /php && \
cd /php && \
sed -i "s#archive.ubuntu.com#old-releases.ubuntu.com#g" /etc/apt/sources.list && \
apt-get update && \
apt-get install -y --no-install-recommends \
autoconf binutils build-essential bzip2 ca-certificates \
Expand Down

0 comments on commit 6da4e7e

Please sign in to comment.