Skip to content

Commit

Permalink
Merge pull request #5 from Larium/feature/upgrade-php81
Browse files Browse the repository at this point in the history
Refactor to php 8.1
  • Loading branch information
akDeveloper committed Apr 17, 2023
2 parents 0895fc6 + b50698b commit 227c437
Show file tree
Hide file tree
Showing 20 changed files with 372 additions and 336 deletions.
21 changes: 18 additions & 3 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
FROM php:7.4-cli
FROM php:8.1-cli
WORKDIR "/opt/php"

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update && \
pecl channel-update pecl.php.net && \
apt-get install -y \
unzip \
git && \
rm -rf /var/lib/apt/lists/*

RUN pecl channel-update pecl.php.net && \
pecl install xdebug && \
docker-php-source delete && \
rm -r /tmp/* /var/cache/*

COPY ./.docker/php-ini-overrides.ini /usr/local/etc/php/conf.d/99-overrides.ini
COPY ./.docker/php-ini-overrides.ini /usr/local/etc/php/conf.d/99-overrides.ini

RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
&& php composer-setup.php \
&& php -r "unlink('composer-setup.php');" \
&& chmod +x composer.phar \
&& mv composer.phar /usr/local/bin/composer

RUN curl -L https://cs.symfony.com/download/php-cs-fixer-v3.phar -o php-cs-fixer \
&& chmod a+x php-cs-fixer \
&& mv php-cs-fixer /usr/bin/php-cs-fixer
2 changes: 1 addition & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: '8.1'
coverage: xdebug
- name: Checkout code
uses: actions/checkout@v2
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
composer.lock
/vendor
/build
.phpunit.result.cache
.phpunit.result.cache
/.phpunit.cache
.vscode
.DS_Store
18 changes: 18 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
;

return (new PhpCsFixer\Config())
->setUsingCache(false)
->setRules([
'@PSR12' => true,
'ordered_imports' => ['sort_algorithm' => 'alpha', 'imports_order' => ['const', 'class', 'function']],
'array_syntax' => ['syntax' => 'short'],
'concat_space' => ['spacing' => 'one'],
'blank_line_between_import_groups' => true,
])->setFinder($finder)
;
28 changes: 19 additions & 9 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
filter:
excluded_paths: [vendor/*, tests/*]
excluded_paths: [vendor/*, tests/*, .php-cs-fixer.php]
checks:
php:
code_rating: true
duplication: true
tools:
php_code_sniffer:
config:
standard: "PSR2"
standard: "PSR12"
build:
environment:
php:
version: 7.4
tests:
override:
-
command: './vendor/bin/phpunit --configuration code-coverage.xml tests/'
nodes:
analysis:
dependencies:
override:
- composer install --ignore-platform-reqs --no-interaction
environment:
php:
version: 8.1
ini:
xdebug.mode: coverage
tests:
override:
- php-scrutinizer-run
- command: './vendor/bin/phpunit tests/'
coverage:
file: build/logs/clover.xml
format: clover
17 changes: 0 additions & 17 deletions code-coverage.xml

This file was deleted.

8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
],
"require": {
"php": ">=7.4"
"php": ">=8.1"
},
"minimum-stability": "stable",
"autoload": {
Expand All @@ -25,11 +25,11 @@
}
},
"require-dev": {
"phpunit/phpunit": "^9.0"
"phpunit/phpunit": "^10.0"
},
"scripts": {
"docker-build": "docker build -f .docker/Dockerfile -t larium-creditcard .",
"docker-tests": "docker run -v $(pwd):/opt/php larium-creditcard sh -c './vendor/bin/phpunit --configuration code-coverage.xml tests/'",
"tests": "./vendor/bin/phpunit --configuration code-coverage.xml tests/"
"docker-tests": "docker run -v $(pwd):/opt/php larium-creditcard sh -c './vendor/bin/phpunit tests/'",
"tests": "./vendor/bin/phpunit tests/"
}
}
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "3.1"
services:
php-cli:
build: .docker
container_name: larium-creditcard
image: larium-creditcard:latest
working_dir: /opt/php
tty: true
stdin_open: true
volumes:
- .:/opt/php
31 changes: 24 additions & 7 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit
backupGlobals = "false"
backupStaticAttributes = "false"
colors = "true"
bootstrap = "vendor/autoload.php">

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
colors="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="vendor/autoload.php"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false">
<coverage>
<report>
<clover outputFile="build/logs/clover.xml"/>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
</report>
</coverage>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
</source>
</phpunit>
Loading

0 comments on commit 227c437

Please sign in to comment.