Skip to content

Commit

Permalink
Add PHP8 Compatibility (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
antonkomarev authored Oct 11, 2023
1 parent c08c341 commit 9395da6
Show file tree
Hide file tree
Showing 37 changed files with 207 additions and 577 deletions.
445 changes: 0 additions & 445 deletions .buildpath

This file was deleted.

2 changes: 0 additions & 2 deletions .coveralls.yml

This file was deleted.

22 changes: 22 additions & 0 deletions .docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# ----------------------
# The FPM base container
# ----------------------
FROM php:8.2-fpm-alpine AS dev

RUN apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS

# Cleanup apk cache and temp files
RUN rm -rf /var/cache/apk/* /tmp/*

# ----------------------
# Composer install step
# ----------------------

# Get latest Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

# ----------------------
# The FPM production container
# ----------------------
FROM dev
85 changes: 85 additions & 0 deletions .docker/php/www.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
; Start a new pool named 'www'.
; the variable $pool can be used in any directive and will be replaced by the
; pool name ('www' here)
[www]

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
user = www-data
group = www-data

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
; a specific port;
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses
; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 9000

; Choose how the process manager will control the number of child processes.
; Possible Values:
; static - a fixed number (pm.max_children) of child processes;
; dynamic - the number of child processes are set dynamically based on the
; following directives. With this process management, there will be
; always at least 1 children.
; pm.max_children - the maximum number of children that can
; be alive at the same time.
; pm.start_servers - the number of children created on startup.
; pm.min_spare_servers - the minimum number of children in 'idle'
; state (waiting to process). If the number
; of 'idle' processes is less than this
; number then some children will be created.
; pm.max_spare_servers - the maximum number of children in 'idle'
; state (waiting to process). If the number
; of 'idle' processes is greater than this
; number then some children will be killed.
; ondemand - no children are created at startup. Children will be forked when
; new requests will connect. The following parameter are used:
; pm.max_children - the maximum number of children that
; can be alive at the same time.
; pm.process_idle_timeout - The number of seconds after which
; an idle process will be killed.
; Note: This value is mandatory.
pm = dynamic

; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI. The below defaults are based on a server without much resources. Don't
; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory.
pm.max_children = 5

; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
pm.start_servers = 2

; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.min_spare_servers = 1

; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.max_spare_servers = 3

; The number of seconds after which an idle process will be killed.
; Note: Used only when pm is set to 'ondemand'
; Default Value: 10s
;pm.process_idle_timeout = 10s;

; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
;pm.max_requests = 500
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
* text=auto

/src/test export-ignore
/.docker export-ignore
/.buildpath export-ignore
/.coveralls.yml export-ignore
/.gitattributes export-ignore
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: tests

on: [ push, pull_request ]

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ ubuntu-latest ]
php: [ 8.0, 8.1, 8.2 ]
dependency-version: [ prefer-lowest, prefer-stable ]

name: P${{ matrix.php }} - ${{ matrix.dependency-version }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.composer/cache/files
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip
tools: composer:v2
coverage: none

- name: Install dependencies
run: |
composer install --no-interaction
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
- name: Execute tests
run: vendor/bin/phpunit src/test/php --testdox
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
/Gemfile.lock
/phpdocumentor/
/build/
.phpunit.result.cache
composer.lock
26 changes: 0 additions & 26 deletions .travis.yml

This file was deleted.

30 changes: 0 additions & 30 deletions code-climate-test-reporter

This file was deleted.

15 changes: 3 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cybercog/php-pushwoosh",
"description": "A PHP Library to easily send push notifications with the Pushwoosh REST Web Services.",
"description": "A PHP Library to easily send PUSH notifications with the Pushwoosh REST Web Services.",
"license": "MIT",
"type": "library",
"keywords": [
Expand Down Expand Up @@ -49,21 +49,12 @@
}
},
"require": {
"php": "^5.6 || ^7.0",
"php": "^8.0",
"ext-curl": "*",
"ext-json": "*"
},
"require-dev": {
"codeclimate/php-test-reporter": "^0.3.2",
"pdepend/pdepend": "^2.2.4",
"phpdocumentor/phpdocumentor": "^2.9.0",
"phploc/phploc": "^3.0.1",
"phpmd/phpmd": "^2.4.3",
"phpunit/phpunit": "^5.5.4",
"satooshi/php-coveralls": "^1.0.1",
"sebastian/phpcpd": "^2.0.4",
"squizlabs/php_codesniffer": "^3.5",
"symfony/yaml": "^3.1.4"
"phpunit/phpunit": "^9.0|^10.0"
},
"config": {
"sort-packages": true
Expand Down
19 changes: 19 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: "3.9"
services:
app:
container_name: php-pushwoosh-app
image: php-pushwoosh-app
build:
context: ./
dockerfile: ./.docker/php/Dockerfile
restart: unless-stopped
working_dir: /app
volumes:
- ./:/app
- ./.docker/php/www.conf:/usr/local/etc/php-fpm.d/www.conf:ro
networks:
- php_pushwoosh

networks:
php_pushwoosh:
driver: bridge
47 changes: 10 additions & 37 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,39 +1,12 @@
<?xml version="1.0"?>
<phpunit
bootstrap="src/test/php/bootstrap.php"
stopOnError="true"
stopOnFailure="true"
stopOnIncomplete="true"
stopOnSkipped="true"
verbose="true">

<logging>

<!-- Log Unit Test results into a JUnit XML file -->
<log type="junit"
target="build/reports/phpunit/TEST-phpunit.report.xml"
logIncompleteSkipped="false"/>

<!-- Log Code Coverage results as HTML -->
<log type="coverage-html"
target="build/reports/coverage/html"
charset="UTF-8"
yui="true"
highlight="false"
lowUpperBound="35"
highLowerBound="70" />

<!-- Log Code Coverage results as a Clover XML file (WARNING: Path must no be changed because its Needed by Code
Climate). -->
<log type="coverage-clover"
target="build/logs/clover.xml" />

</logging>

<!-- Includes and Excludes files for Code Coverage -->
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src/main/php</directory>
</whitelist>
</filter>

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd"
bootstrap="src/test/php/bootstrap.php"
>
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./src/main/php</directory>
</testsuite>
</testsuites>
</phpunit>
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class PushwooshException extends \Exception
* @param \Exception $previous A previous exception which leads to a creation of this exception.
* @param array $data Additional data / details to attach to the exception.
*/
public function __construct($message = null, $code = null, $previous = null, array $data = [])
public function __construct($message = '', $code = 0, $previous = null, array $data = [])
{
parent::__construct($message, $code, $previous);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function getTagName()
/**
* {@inheritDoc}
*/
public function jsonSerialize()
public function jsonSerialize(): mixed
{
return [
$this->tagName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function in(array $values = [])
/**
* {@inheritDoc}
*/
public function jsonSerialize()
public function jsonSerialize(): mixed
{
$operandWithString = null;

Expand Down
2 changes: 1 addition & 1 deletion src/main/php/Gomoob/Pushwoosh/Model/Notification/ADM.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function getTtl()
/**
* {@inheritdoc}
*/
public function jsonSerialize()
public function jsonSerialize(): mixed
{
$json = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function isVibration()
/**
* {@inheritdoc}
*/
public function jsonSerialize()
public function jsonSerialize(): mixed
{
$json = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function getHeader()
/**
* {@inheritdoc}
*/
public function jsonSerialize()
public function jsonSerialize(): mixed
{
$json = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function getImage()
/**
* {@inheritdoc}
*/
public function jsonSerialize()
public function jsonSerialize(): mixed
{
$json = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function getTitle()
/**
* {@inheritdoc}
*/
public function jsonSerialize()
public function jsonSerialize(): mixed
{
$json = [];

Expand Down
Loading

0 comments on commit 9395da6

Please sign in to comment.