Skip to content

Commit

Permalink
Test against PHP 8.4RC4
Browse files Browse the repository at this point in the history
  • Loading branch information
olvlvl committed Nov 15, 2024
1 parent 9cdc2ee commit e891ee2
Show file tree
Hide file tree
Showing 11 changed files with 99 additions and 70 deletions.
8 changes: 7 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,11 @@ insert_final_newline = true
indent_style = space
indent_size = 4

[*.yml]
[{*.yaml,*.yml,*.neon,*.json}]
indent_size = 2

[*.md]
max_line_length = 80

[{Dockerfile,Makefile}]
indent_style = tab
2 changes: 1 addition & 1 deletion .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "7.2"
php-version: "7.1"
ini-values: memory_limit=-1
tools: composer:v2, phpcs
- name: Run PHPCS
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ on:

jobs:
phpstan:
name: PHPStan
name: phpstan
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "7.1"
ini-values: memory_limit=-1
tools: composer:v2
- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: |
~/.composer/cache
Expand All @@ -28,5 +28,5 @@ jobs:
- name: Install dependencies
run: composer install --no-interaction --no-progress

- name: Run PHPStan
- name: Analyze
run: vendor/bin/phpstan
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ jobs:
- "7.1"
- "7.4"
- "8.0"
- "8.4"
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
Expand All @@ -25,7 +26,7 @@ jobs:
ini-values: memory_limit=-1
tools: composer:v2
- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: |
~/.composer/cache
Expand Down
37 changes: 24 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
FROM php:7.1-cli-buster
ARG PHP_TAG=7.1-cli-buster
FROM php:${PHP_TAG}

RUN docker-php-ext-enable opcache && \
docker-php-source delete
RUN <<-EOF
docker-php-ext-enable opcache
docker-php-source delete
EOF

RUN echo '\
display_errors=On\n\
error_reporting=E_ALL\n\
date.timezone=UTC\n\
' >> /usr/local/etc/php/conf.d/php.ini
RUN <<-EOF
cat <<-SHELL >> /usr/local/etc/php/conf.d/php.ini
display_errors=On
error_reporting=E_ALL
date.timezone=UTC
SHELL
EOF

ENV COMPOSER_ALLOW_SUPERUSER 1

RUN apt-get update && \
apt-get install unzip && \
curl -s https://raw.githubusercontent.com/composer/getcomposer.org/76a7060ccb93902cd7576b67264ad91c8a2700e2/web/installer | php -- --quiet && \
mv composer.phar /usr/local/bin/composer && \
echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"\n' >> /root/.bashrc
RUN <<-EOF
apt-get update
apt-get install unzip
curl -s https://raw.githubusercontent.com/composer/getcomposer.org/76a7060ccb93902cd7576b67264ad91c8a2700e2/web/installer | php -- --quiet
mv composer.phar /usr/local/bin/composer
cat <<-SHELL >> /root/.bashrc
export PATH="$HOME/.composer/vendor/bin:$PATH"
SHELL
EOF

RUN composer global require squizlabs/php_codesniffer

ENV COMPOSER_ROOT_VERSION 2.1.0
17 changes: 12 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# customization

PACKAGE_NAME = icanboogie/common
PHPUNIT = vendor/bin/phpunit

# do not edit the following lines
Expand All @@ -26,11 +25,19 @@ test-coveralls: test-dependencies
@XDEBUG_MODE=coverage $(PHPUNIT) --coverage-clover build/logs/clover.xml

.PHONY: test-container
test-container:
@docker-compose run --rm app bash
test-container: test-container-71

.PHONY: test-container-71
test-container-71:
@-docker-compose run --rm app71 bash
@docker-compose down -v

.PHONY: test-container-84
test-container-84:
@-docker-compose run --rm app84 bash
@docker-compose down -v

.PHONY: lint
lint:
@phpcs
@vendor/bin/phpstan
@XDEBUG_MODE=none phpcs
@XDEBUG_MODE=none vendor/bin/phpstan
54 changes: 23 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
# Common

[![Release](https://img.shields.io/packagist/v/icanboogie/common.svg)](https://packagist.org/packages/icanboogie/common)
[![Code Quality](https://img.shields.io/scrutinizer/g/ICanBoogie/Common.svg)](https://scrutinizer-ci.com/g/ICanBoogie/Common)
[![Code Coverage](https://img.shields.io/coveralls/ICanBoogie/Common.svg)](https://coveralls.io/r/ICanBoogie/Common)
[![Code Coverage](https://img.shields.io/coveralls/ICanBoogie/Common/badge.svg?branch=2.1)](https://coveralls.io/r/ICanBoogie/Common?branch=2.1)
[![Packagist](https://img.shields.io/packagist/dt/icanboogie/common.svg)](https://packagist.org/packages/icanboogie/common)

This package provides basic classes and helpers shared by many [ICanBoogie][]
packages. It provides offset exceptions, property exceptions, some interfaces, and helpers to
transform strings and arrays.
packages. It provides offset exceptions, property exceptions, some interfaces,
and helpers to transform strings and arrays.

#### Installation

```bash
```shell
composer require icanboogie/common
```

Expand All @@ -21,7 +20,7 @@ composer require icanboogie/common

### Offset exceptions

The following exceptions related to array offset are defined by the package:
The package defines the following exceptions related to array offset:

* [OffsetError][]: Interface for offset errors.
* [OffsetNotDefined][]: Exception thrown when an array offset is not defined.
Expand Down Expand Up @@ -63,7 +62,7 @@ class A

## Interfaces

The following interfaces are defined by the package:
The package defines the following interfaces:

- [ToArray][]: Should be implemented by classes whose instances can be converted into arrays.
- [ToArrayRecursive][]: Should be implemented by classes whose instances can be converted into
Expand Down Expand Up @@ -96,41 +95,34 @@ class A implements ToArrayRecursive

The project is continuously tested by [GitHub actions](https://github.com/ICanBoogie/Common/actions).

[![Tests](https://github.com/ICanBoogie/Common/workflows/test/badge.svg?branch=master)](https://github.com/ICanBoogie/master/actions?query=workflow%3Atest)
[![Static Analysis](https://github.com/ICanBoogie/Common/workflows/static-analysis/badge.svg?branch=master)](https://github.com/ICanBoogie/Common/actions?query=workflow%3Astatic-analysis)
[![Code Style](https://github.com/ICanBoogie/Common/workflows/code-style/badge.svg?branch=master)](https://github.com/ICanBoogie/Common/actions?query=workflow%3Acode-style)
[![Tests](https://github.com/ICanBoogie/Common/actions/workflows/test.yml/badge.svg?branch=2.1)](https://github.com/ICanBoogie/Common/actions/workflows/test.yml)
[![Static Analysis](https://github.com/ICanBoogie/Common/actions/workflows/static-analysis.yml/badge.svg?branch=2.1)](https://github.com/ICanBoogie/Common/actions/workflows/static-analysis.yml)
[![Code Style](https://github.com/ICanBoogie/Common/actions/workflows/code-style.yml/badge.svg?branch=2.1)](https://github.com/ICanBoogie/Common/actions/workflows/code-style.yml)



## Code of Conduct

This project adheres to a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project and its
community, you are expected to uphold this code.
This project adheres to a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in
this project and its community, you're expected to uphold this code.



## Contributing

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
See [CONTRIBUTING](CONTRIBUTING.md) for details.



## License

**icanboogie/common** is released under the [BSD-3-Clause](LICENSE).



[documentation]: https://icanboogie.org/api/common/1.2/
[OffsetError]: https://icanboogie.org/api/common/1.2/class-ICanBoogie.OffsetError.html
[OffsetNotDefined]: https://icanboogie.org/api/common/1.2/class-ICanBoogie.OffsetNotDefined.html
[OffsetNotReadable]: https://icanboogie.org/api/common/1.2/class-ICanBoogie.OffsetNotReadable.html
[OffsetNotWritable]: https://icanboogie.org/api/common/1.2/class-ICanBoogie.OffsetNotWritable.html
[PropertyError]: https://icanboogie.org/api/common/1.2/class-ICanBoogie.PropertyError.html
[PropertyNotDefined]: https://icanboogie.org/api/common/1.2/class-ICanBoogie.PropertyNotDefined.html
[PropertyNotReadable]: https://icanboogie.org/api/common/1.2/class-ICanBoogie.PropertyNotReadable.html
[PropertyNotWritable]: https://icanboogie.org/api/common/1.2/class-ICanBoogie.PropertyNotWritable.html
[ToArray]: https://icanboogie.org/api/common/1.2/class-ICanBoogie.ToArray.html
[ToArrayRecursive]: https://icanboogie.org/api/common/1.2/class-ICanBoogie.ToArrayRecursive.html
[ToArrayRecursiveTrait]: https://icanboogie.org/api/common/1.2/class-ICanBoogie.ToArrayRecursiveTrait.html
[OffsetError]: lib/OffsetError.php
[OffsetNotDefined]: lib/OffsetNotDefined.php
[OffsetNotReadable]: lib/OffsetNotReadable.php
[OffsetNotWritable]: lib/OffsetNotWritable.php
[PropertyError]: lib/PropertyError.php
[PropertyNotDefined]: lib/PropertyNotDefined.php
[PropertyNotReadable]: lib/PropertyNotReadable.php
[PropertyNotWritable]: lib/PropertyNotWritable.php
[ToArray]: lib/ToArray.php
[ToArrayRecursive]: lib/ToArrayRecursive.php
[ToArrayRecursiveTrait]: lib/ToArrayRecursiveTrait.php
[ICanBoogie]: https://icanboogie.org/
21 changes: 21 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
services:
app71:
build:
context: .
args:
PHP_TAG: 7.1-cli-buster
environment: &env
PHP_IDE_CONFIG: 'serverName=icanboogie-common'
volumes: &vol
- .:/app:delegated
- ~/.composer:/root/.composer:delegated
working_dir: /app
app84:
build:
context: .
args:
PHP_TAG: 8.4.0RC4-cli-bookworm
environment: *env
volumes: *vol
working_dir: /app
11 changes: 0 additions & 11 deletions docker-compose.yml

This file was deleted.

4 changes: 2 additions & 2 deletions lib/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function capitalize(string $str, bool $preserve_str_end = false): string
* @param float $position Position at which characters can be removed.
* @param bool $shortened `true` if the string was shortened, `false` otherwise.
*/
function shorten(string $str, int $length = 32, float $position = .75, bool &$shortened = null): string
function shorten(string $str, int $length = 32, float $position = .75, ?bool &$shortened = null): string
{
$l = mb_strlen($str);

Expand Down Expand Up @@ -298,7 +298,7 @@ function format(string $str, array $args = []): string
*
* @param array<int|string, mixed> $array
*/
function stable_sort(array &$array, callable $picker = null): void
function stable_sort(array &$array, ?callable $picker = null): void
{
static $transform, $restore;

Expand Down
2 changes: 2 additions & 0 deletions tests/SampleToArrayRecursive.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@

namespace Tests\ICanBoogie;

use AllowDynamicProperties;
use ICanBoogie\ToArrayRecursive;
use ICanBoogie\ToArrayRecursiveTrait;

#[AllowDynamicProperties]
class SampleToArrayRecursive implements ToArrayRecursive
{
use ToArrayRecursiveTrait;
Expand Down

0 comments on commit e891ee2

Please sign in to comment.