Skip to content

Commit

Permalink
chore: prepare for PHP 8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ramsey committed Aug 5, 2021
1 parent ab22376 commit 3caa99d
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 16 deletions.
19 changes: 6 additions & 13 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@

name: "CI"

on:
pull_request:
push:
branches:
- "main"
- "2.x"
on: ["pull_request", "push"]

env:
COMPOSER_ROOT_VERSION: "1.99.99"
Expand All @@ -21,10 +16,9 @@ jobs:
- uses: "actions/checkout@v2"
- uses: "shivammathur/setup-php@v2"
with:
php-version: "7.4"
php-version: "latest"
coverage: "none"
ini-values: "memory_limit=-1"
tools: "composer:v2"
- uses: "ramsey/composer-install@v1"
- name: "Check coding standards"
run: "composer br:lint"
Expand All @@ -36,10 +30,9 @@ jobs:
- uses: "actions/checkout@v2"
- uses: "shivammathur/setup-php@v2"
with:
php-version: "7.4"
php-version: "latest"
coverage: "none"
ini-values: "memory_limit=-1"
tools: "composer:v2"
- uses: "ramsey/composer-install@v1"
- name: "Run PHPStan"
run: "composer br:analyze:phpstan"
Expand All @@ -57,23 +50,23 @@ jobs:
- "7.2"
- "7.3"
- "7.4"
- "8.0"
operating-system:
- "ubuntu-latest"
experimental:
- false
include:
- php-version: "8.0"
- php-version: "8.1"
operating-system: "ubuntu-latest"
experimental: true
composer-options: "--ignore-platform-reqs"
composer-options: "--ignore-platform-req=php"
steps:
- uses: "actions/checkout@v2"
- uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
coverage: "pcov"
ini-values: "memory_limit=-1"
tools: "composer:v2"
- uses: "ramsey/composer-install@v1"
with:
composer-options: "${{ matrix.composer-options }}"
Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
}
],
"require": {
"php": "^7.2 || ^8"
"php": "^7.2 || ^8",
"symfony/polyfill-php81": "^1.23"
},
"require-dev": {
"captainhook/captainhook": "^5.3",
Expand All @@ -29,6 +30,7 @@
"hamcrest/hamcrest-php": "^2",
"jangregor/phpstan-prophecy": "^0.8",
"mockery/mockery": "^1.3",
"phpspec/prophecy-phpunit": "^2.0",
"phpstan/extension-installer": "^1",
"phpstan/phpstan": "^0.12.32",
"phpstan/phpstan-mockery": "^0.12.5",
Expand Down
1 change: 1 addition & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

<description>Project coding standards.</description>

<arg name="bootstrap" value="./tests/bootstrap.php"/>
<arg name="extensions" value="php"/>
<arg name="colors"/>
<arg value="sp"/>
Expand Down
2 changes: 2 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ parameters:
- ./src
- ./tests
- ./resources/console
bootstrapFiles:
- ./tests/bootstrap.php
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="./vendor/autoload.php"
bootstrap="./tests/bootstrap.php"
cacheResultFile="./build/cache/phpunit.result.cache"
colors="true"
verbose="true">
Expand Down
4 changes: 3 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
totallyTyped="true"
cacheDirectory="./build/cache/psalm"
errorBaseline="psalm-baseline.xml">
errorBaseline="psalm-baseline.xml"
autoloader="./tests/bootstrap.php">

<projectFiles>
<directory name="./src"/>
<directory name="./resources/console"/>
<ignoreFiles>
<directory name="./tests"/>
<directory name="./vendor"/>
</ignoreFiles>
</projectFiles>

Expand Down
30 changes: 30 additions & 0 deletions src/AbstractArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ public function offsetExists($offset): bool
*
* @return T|null the value stored at the offset, or null if the offset
* does not exist.
*
* @psalm-suppress InvalidAttribute
*/
#[\ReturnTypeWillChange] // phpcs:ignore
public function offsetGet($offset)
{
return $this->data[$offset] ?? null;
Expand Down Expand Up @@ -123,6 +126,8 @@ public function offsetUnset($offset): void
/**
* Returns a serialized string representation of this array object.
*
* @deprecated The Serializable interface will go away in PHP 9.
*
* @link http://php.net/manual/en/serializable.serialize.php Serializable::serialize()
*
* @return string a PHP serialized string.
Expand All @@ -132,9 +137,24 @@ public function serialize(): string
return serialize($this->data);
}

/**
* Returns data suitable for PHP serialization.
*
* @link https://www.php.net/manual/en/language.oop5.magic.php#language.oop5.magic.serialize
* @link https://www.php.net/serialize
*
* @return array<array-key, T>
*/
public function __serialize(): array
{
return $this->data;
}

/**
* Converts a serialized string representation into an instance object.
*
* @deprecated The Serializable interface will go away in PHP 9.
*
* @link http://php.net/manual/en/serializable.unserialize.php Serializable::unserialize()
*
* @param string $serialized A PHP serialized string to unserialize.
Expand All @@ -149,6 +169,16 @@ public function unserialize($serialized): void
$this->data = $data;
}

/**
* Adds unserialized data to the object.
*
* @param array<array-key, T> $data
*/
public function __unserialize(array $data): void
{
$this->data = $data;
}

/**
* Returns the number of items in this array.
*
Expand Down
3 changes: 3 additions & 0 deletions tests/CollectionManipulationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Ramsey\Collection\Test;

use Prophecy\PhpUnit\ProphecyTrait;
use Ramsey\Collection\Collection;
use Ramsey\Collection\Exception\CollectionMismatchException;
use Ramsey\Collection\Exception\InvalidSortOrderException;
Expand All @@ -20,6 +21,8 @@
*/
class CollectionManipulationTest extends TestCase
{
use ProphecyTrait;

public function testSortNameAscWithAscendingIdAndNames(): void
{
$bar1 = new Bar(1, 'a');
Expand Down
7 changes: 7 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

declare(strict_types=1);

error_reporting(E_ALL ^ E_DEPRECATED);

require_once __DIR__ . '/../vendor/autoload.php';

0 comments on commit 3caa99d

Please sign in to comment.