Skip to content

Commit

Permalink
Merge pull request #1 from Erwane/cakephp5-compatibility
Browse files Browse the repository at this point in the history
Cakephp5 compatibility
  • Loading branch information
Erwane authored Jan 4, 2025
2 parents 44c6f43 + 0c7b8c0 commit 8637772
Show file tree
Hide file tree
Showing 17 changed files with 179 additions and 326 deletions.
15 changes: 9 additions & 6 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# editorconfig.org
; This file is for unifying the coding style for different editors and IDEs.
; More information at http://editorconfig.org

root = true

[*]
indent_style = space
charset = utf-8
indent_size = 4
indent_style = space
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
trim_trailing_whitespace = true

[*.yml]
indent_size = 2

[*.md]
trim_trailing_whitespace = false

[*.{yaml,yml}]
indent_size = 2
59 changes: 10 additions & 49 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,49 +1,10 @@
# Define the line ending behavior of the different file extensions
# Set default behaviour, in case users don't have core.autocrlf set.
* text=auto
* text eol=lf

# Explicitly declare text files we want to always be normalized and converted
# to native line endings on checkout.
*.php text
*.default text
*.ctp text
*.sql text
*.md text
*.po text
*.js text
*.css text
*.ini text
*.properties text
*.txt text
*.xml text
*.svg text
*.yml text
.htaccess text

# Declare files that will always have CRLF line endings on checkout.
*.bat eol=crlf

# Declare files that will always have LF line endings on checkout.
*.pem eol=lf

# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
*.gif binary
*.ico binary
*.mo binary
*.pdf binary
*.phar binary
*.woff binary
*.woff2 binary
*.ttf binary
*.otf binary
*.eot binary
*.gz binary
*.bz2 binary
*.7z binary
*.zip binary
*.docx binary
*.xlsx binary
*.mmdb binary
/.github/ export-ignore
/docs/ export-ignore
/tests/ export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.composer.lock export-ignore
/grumphp.yml export-ignore
/phpcs.xml export-ignore
/phpunit.xml.dist export-ignore
49 changes: 24 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,54 @@ name: CI
on:
push:
branches:
- 1.x
- '2.x'
pull_request:
branches:
- '*'
workflow_dispatch:

permissions:
contents: read # to fetch code (actions/checkout)

jobs:
testsuite:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version: ['7.2', '8.0', '8.1']
php-version: ['8.1', '8.3']

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl, apcu, pdo_${{ matrix.db-type }}
ini-values: apc.enable_cli = 1
extensions: mbstring, intl
ini-values: zend.assertions = 1
coverage: pcov

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Get date part for cache key
id: key-date
run: echo "::set-output name=date::$(date +'%Y-%m')"

- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }}

- name: Composer install
run: |
composer update
uses: ramsey/composer-install@v3
with:
dependency-versions: ${{ matrix.dependencies }}
composer-options: "${{ matrix.composer-options }}"

- name: Run PHPUnit
env:
XDEBUG_MODE: coverage
run: |
if [[ ${{ matrix.php-version }} == '8.1' ]]; then
export CODECOVERAGE=1 && vendor/bin/phpunit --verbose --coverage-clover=coverage.xml
if [[ '${{ matrix.php-version }}' == '8.1' ]]; then
export CODECOVERAGE=1
vendor/bin/phpunit --display-warnings --display-incomplete --coverage-clover=coverage.xml
else
vendor/bin/phpunit
vendor/bin/phpunit --display-phpunit-deprecations --display-deprecations --display-warnings
fi
- name: Submit code coverage
if: matrix.php-version == '8.1'
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v5
with:
files: coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
20 changes: 11 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
/logs
/tmp
/vendor/
/.phpunit.cache
/.phpunit.result.cache
/composer.lock
vendor/
composer.lock
composer.phar

/phpunit.xml
.phpunit.result.cache
.phpunit.cache

/coverage.xml

# OS generated files #
######################
Expand All @@ -29,12 +32,11 @@ Thumbs.db
*.tmPreferences.cache
# Eclipse
.settings/*
/.project
/.buildpath
# JetBrains, aka PHPStorm, IntelliJ IDEA
.idea/*
# NetBeans
nbproject/*
# Visual Studio Code
.vscode
# Sass preprocessor
.sass-cache/
/.phpstorm.meta.php
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
# HCaptcha plugin for CakePHP 4.x

![Build Status](https://github.com/Erwane/cakephp-hcaptcha/actions/workflows/ci.yml/badge.svg?branch=1.x)
[![codecov](https://codecov.io/gh/Erwane/cakephp-hcaptcha/branch/1.x/graph/badge.svg?token=NNY4FBXCEE)](https://codecov.io/gh/Erwane/cakephp-hcaptcha)
[![Total Downloads](https://img.shields.io/packagist/dt/Erwane/cakephp-hcaptcha?style=flat-square)](https://packagist.org/packages/Erwane/cakephp-hcaptcha/stats)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.txt)
[![codecov](https://codecov.io/gh/Erwane/cakephp-hcaptcha/branch/2.x/graph/badge.svg?token=NNY4FBXCEE)](https://codecov.io/gh/Erwane/cakephp-hcaptcha)
![Build Status](https://github.com/Erwane/cakephp-hcaptcha/actions/workflows/ci.yml/badge.svg?branch=2.x)
[![Packagist Downloads](https://img.shields.io/packagist/dt/Erwane/cakephp-hcaptcha)](https://packagist.org/packages/Erwane/cakephp-hcaptcha)
[![Packagist Version](https://img.shields.io/packagist/v/Erwane/cakephp-hcaptcha)](https://packagist.org/packages/Erwane/cakephp-hcaptcha)

## Installation
## Version map

With composer
| branch | CakePHP core | PHP min |
|--------|--------------|---------|
| 1.x | ^4.0 | PHP 7.2 |
| 2.x | ^5.0 | PHP 8.1 |

```
## Installation

```sh
composer require erwane/cakephp-hcaptcha
```

Expand Down
34 changes: 20 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,25 @@
"license": "MIT",
"authors": [
{
"name": "erwane",
"email": "[email protected]"
"name": "Erwane Breton",
"email": "[email protected]",
"homepage": "https://erwane-breton.fr"
}
],
"support": {
"issues": "https://github.com/Erwane/cakephp-hcaptcha/issues",
"source": "https://github.com/Erwane/cakephp-hcaptcha"
},
"require": {
"php": "^8.1",
"cakephp/cakephp": "^5.0"
},
"require-dev": {
"cakephp/cakephp-codesniffer": "^5.0",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phpro/grumphp": "^2.0",
"phpunit/phpunit": "^10.5.5 || ^11.1.3"
},
"autoload": {
"psr-4": {
"HCaptcha\\": "src/"
Expand All @@ -23,22 +38,13 @@
"HCaptcha\\Test\\": "tests/"
}
},
"require": {
"php": "^7.2 | ^8.0",
"ext-intl": "*",
"cakephp/cakephp": "^4.0"
},
"require-dev": {
"cakephp/cakephp-codesniffer": "^4.0",
"php-parallel-lint/php-parallel-lint": "^1.0",
"phpro/grumphp": "^v0.19 | ^v1.0",
"phpunit/phpunit": "^8.0 | ^9.0"
},
"scripts": {
"cscheck": "vendor/bin/phpcs -p src/ tests/",
"csfix": "vendor/bin/phpcbf src/ tests/"
"csfix": "vendor/bin/phpcbf -p src/ tests/"
},
"config": {
"platform-check": true,
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpro/grumphp": true
Expand Down
4 changes: 2 additions & 2 deletions grumphp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ grumphp:
phplint: ~
phpcs:
whitelist_patterns:
- /^config\/(.*)/
- /^src\/(.*)/
- /^src\/(.*\.php)/
- /^tests\/(.*\.php)/
15 changes: 9 additions & 6 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
<?xml version="1.0"?>
<ruleset name="Project">
<ruleset name="CakePHP hCaptcha">
<arg name="colors"/>
<arg name="encoding=UTF-8"/>
<arg name="report=full"/>
<arg name="parallel=8"/>
<arg name="severity=1"/>
<arg name="extensions=php"/>

<config name="installed_paths" value="../../cakephp/cakephp-codesniffer" />
<rule ref="CakePHP" />
<config name="installed_paths" value="../../cakephp/cakephp-codesniffer"/>

<file>src/</file>
<file>tests/</file>

<rule ref="CakePHP"/>
<arg value="s"/>

<rule ref="Generic.Commenting.Todo.CommentFound">
<severity>0</severity>
</rule>
<rule ref="Generic.Commenting.Todo.TaskFound">
<severity>0</severity>
</rule>
Expand Down
28 changes: 0 additions & 28 deletions phpunit.xml

This file was deleted.

31 changes: 31 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
bootstrap="tests/bootstrap.php"
colors="true"
backupGlobals="true"
cacheDirectory=".phpunit.cache"
stopOnFailure="false">

<php>
<ini name="memory_limit" value="-1"/>
<ini name="error_reporting" value="32767"/>
<const name="PHPUNIT_TESTSUITE" value="true"/>
</php>

<extensions>
<bootstrap class="Cake\TestSuite\Fixture\Extension\PHPUnitExtension"/>
</extensions>

<testsuites>
<testsuite name="default">
<directory>tests/TestCase</directory>
</testsuite>
</testsuites>

<source>
<include>
<directory suffix=".php">src/</directory>
</include>
</source>
</phpunit>
6 changes: 3 additions & 3 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function initialize(): void
/**
* Add HCaptcha widget to FormHelper, if exists.
*
* @param \Cake\Event\EventInterface $event Dispatched event
* @param \Cake\Event\EventInterface $event Dispatched event
* @return void
*/
public function addWidget(EventInterface $event): void
Expand All @@ -44,7 +44,7 @@ public function addWidget(EventInterface $event): void
}

/** @var \Cake\View\Helper\FormHelper $formHelper */
$view->helpers()->get('Form')
->addWidget('hcaptcha', ['HCaptcha.HCaptcha', '_view']);
$formHelper = $view->helpers()->get('Form');
$formHelper->addWidget('hcaptcha', ['HCaptcha.HCaptcha', '_view']);
}
}
Loading

0 comments on commit 8637772

Please sign in to comment.