Skip to content

Commit

Permalink
Update boilerplate
Browse files Browse the repository at this point in the history
  • Loading branch information
olvlvl committed Nov 2, 2024
1 parent f4a2bd7 commit 77cc0f3
Show file tree
Hide file tree
Showing 28 changed files with 257 additions and 335 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

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

[*.md]
max_line_length = 100

[Dockerfile]
indent_style = tab
16 changes: 8 additions & 8 deletions .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ on:
- pull_request

jobs:
phpstan:
name: PHPCS
runs-on: ubuntu-20.04
phpcs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.1"
coverage: none
php-version: "8.3"
ini-values: memory_limit=-1
tools: composer:v2, phpcs
- name: Run PHPCS
run: phpcs
tools: phpcs, cs2pr
- name: Run PHP Code Sniffer
run: phpcs -q --report=checkstyle | cs2pr
12 changes: 6 additions & 6 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
runs-on: ubuntu-20.04
name: phpstan
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.1"
php-version: "8.3"
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
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ on:
jobs:
phpunit:
name: phpunit
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
Expand All @@ -25,7 +25,7 @@ jobs:
tools: composer:v2
extensions: gd
- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: |
~/.composer/cache
Expand All @@ -40,7 +40,7 @@ jobs:
run: make test-coveralls

- name: Upload code coverage
if: ${{ matrix.php-version == '8.1' }}
if: ${{ matrix.php-version == '8.3' }}
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

Contributions are **welcome** and will be fully **credited**.

We accept contributions via Pull Requests on [Github](https://github.com/ICanBoogie/Inflector).
We accept contributions via Pull Requests.

## Pull Requests

- **Code style** — We're following a [Coding Standard][]. Check the code style with `make lint`.
- **Code health** — We're using [PHPStan][] to analyse the code, with maximum scrutiny. Check the code with `make lint`.
- **Add tests!** — Your contribution won't be accepted if it doesn't have tests.
- **Add tests!** — Your contribution won't be accepted if it does not have tests.
- **Document any change in behaviour** — Make sure the `README.md` and any other relevant documentation are kept
up-to-date.
- **Consider our release cycle** — We follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not
Expand Down
68 changes: 41 additions & 27 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,37 +1,51 @@
ARG PHP_VERSION
FROM php:${PHP_VERSION}-cli-buster

RUN apt-get update && \
apt-get install -y autoconf pkg-config && \
pecl channel-update pecl.php.net && \
pecl install xdebug && \
docker-php-ext-enable opcache xdebug

RUN echo '\
xdebug.client_host=host.docker.internal\n\
xdebug.mode=develop\n\
xdebug.start_with_request=yes\n\
' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

RUN echo '\
display_errors=On\n\
error_reporting=E_ALL\n\
date.timezone=UTC\n\
' >> /usr/local/etc/php/conf.d/php.ini
ARG PHP_VERSION=8.2
FROM php:${PHP_VERSION}-cli-bookworm

RUN <<-EOF
docker-php-ext-enable opcache

if [ "$PHP_VERSION" \< "8.4" ]; then
apt-get update
apt-get install -y autoconf pkg-config
pecl channel-update pecl.php.net
pecl install xdebug
docker-php-ext-enable xdebug
fi
EOF

RUN <<-EOF
cat <<-SHELL >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
xdebug.client_host=host.docker.internal
xdebug.mode=develop
xdebug.start_with_request=yes
SHELL

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

#
# Package specifics stages
#
RUN apt-get update && \
apt-get install -y libpng-dev && \
RUN <<-EOF
apt-get update
apt-get install -y libpng-dev
docker-php-ext-install gd
EOF
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
The icanboogie/http package is free software.
It is released under the terms of the following BSD License.

Copyright (c) 2011-2023 by Olivier Laviale
Copyright (c) 2011 by Olivier Laviale
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
Expand Down
21 changes: 8 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
# customization

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

# do not edit the following lines

.PHONY: usage
usage:
@echo "test: Runs the test suite.\ndoc: Creates the documentation.\nclean: Removes the documentation, the dependencies and the Composer files."

vendor:
@composer install

Expand All @@ -19,7 +14,7 @@ test-dependencies: vendor test-cleanup

.PHONY: test
test: test-dependencies
@$(PHPUNIT)
@$(PHPUNIT) $(ARGS)

.PHONY: test-coverage
test-coverage: test-dependencies
Expand All @@ -29,25 +24,25 @@ test-coverage: test-dependencies
.PHONY: test-coveralls
test-coveralls: test-dependencies
@mkdir -p build/logs
@$(PHPUNIT) --coverage-clover build/logs/clover.xml
@XDEBUG_MODE=coverage $(PHPUNIT) --coverage-clover build/logs/clover.xml

.PHONY: test-cleanup
test-cleanup:
@rm -rf tests/sandbox/*

.PHONY: test-container
test-container: test-container-81

.PHONY: test-container-81
test-container-81:
@-docker-compose run --rm app81 bash
@docker-compose down -v
test-container: test-container-82

.PHONY: test-container-82
test-container-82:
@-docker-compose run --rm app82 bash
@docker-compose down -v

.PHONY: test-container-83
test-container-83:
@-docker-compose run --rm app83 bash
@docker-compose down -v

.PHONY: lint
lint:
@XDEBUG_MODE=off phpcs -s
Expand Down
22 changes: 7 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# HTTP

[![Release](https://img.shields.io/packagist/v/icanboogie/http.svg)](https://packagist.org/packages/icanboogie/http)
[![Code Quality](https://img.shields.io/scrutinizer/g/icanboogie/http.svg)](https://scrutinizer-ci.com/g/ICanBoogie/HTTP)
[![Code Quality](https://img.shields.io/scrutinizer/g/ICanBoogie/HTTP/6.0.svg)](https://scrutinizer-ci.com/g/ICanBoogie/HTTP)
[![Code Coverage](https://img.shields.io/coveralls/ICanBoogie/HTTP.svg)](https://coveralls.io/r/ICanBoogie/HTTP)
[![Packagist](https://img.shields.io/packagist/dt/icanboogie/http.svg)](https://packagist.org/packages/icanboogie/http)

Expand Down Expand Up @@ -34,7 +34,7 @@ $response();

#### Installation

```bash
```shell
composer require icanboogie/http
```

Expand Down Expand Up @@ -697,30 +697,22 @@ $response = dispatch($request);

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

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



## 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 and its community, you're expected to uphold this code.



## Contributing

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



## Testing

Run `make test-container` to create and log into the test container, then run `make test` to run the
test suite. Alternatively, run `make test-coverage` to run the test suite with test coverage. Open
`build/coverage/index.html` to see the breakdown of the code coverage.
See [CONTRIBUTING](CONTRIBUTING.md) for details.



Expand Down
9 changes: 4 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,18 @@
},
"minimum-stability": "dev",
"prefer-stable": true,
"prefer-dist": true,
"require": {
"php": ">=8.1",
"php": ">=8.2",
"ext-mbstring": "*",
"icanboogie/prototype": "^6.0",
"icanboogie/event": "^6.0",
"icanboogie/datetime": "^6.0"
"icanboogie/datetime": "^3.0"
},
"require-dev": {
"ext-fileinfo": "*",
"ext-gd": "*",
"phpstan/phpstan": "^1.5",
"phpunit/phpunit": "^9.5"
"phpstan/phpstan": "^1.12",
"phpunit/phpunit": "^11.4"
},
"autoload": {
"psr-4": {
Expand Down
19 changes: 15 additions & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
---
services:
app81:
app82:
build:
context: .
args:
PHP_VERSION: 8.1
PHP_VERSION: "8.2"
environment:
PHP_IDE_CONFIG: 'serverName=icanboogie-http'
volumes:
- .:/app:delegated
- ~/.composer:/root/.composer:delegated
working_dir: /app
app82:
app83:
build:
context: .
args:
PHP_VERSION: "8.3"
environment:
PHP_IDE_CONFIG: 'serverName=icanboogie-http'
volumes:
- .:/app:delegated
- ~/.composer:/root/.composer:delegated
working_dir: /app
app84:
build:
context: .
args:
PHP_VERSION: 8.2
PHP_VERSION: "8.4.0RC3"
environment:
PHP_IDE_CONFIG: 'serverName=icanboogie-http'
volumes:
Expand Down
5 changes: 4 additions & 1 deletion lib/Headers/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
*/
class Date extends DateTime
{
public static function from($source, $timezone = null): self|parent
public static function from(
self|\DateTime|string|null $source,
DateTimeZone|string|null $timezone = null
): static
{
if ($source === null) {
return static::none();
Expand Down
Loading

0 comments on commit 77cc0f3

Please sign in to comment.