Skip to content

Commit 7592e8a

Browse files
committed
code modernized
1 parent 05f7963 commit 7592e8a

32 files changed

Lines changed: 1140 additions & 377 deletions

.github/workflows/pint.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Pint
2+
3+
on: [ push, pull_request ]
4+
5+
jobs:
6+
pint:
7+
runs-on: ubuntu-latest
8+
name: Pint
9+
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
14+
- name: Setup PHP
15+
uses: shivammathur/setup-php@v2
16+
with:
17+
php-version: 8.5
18+
19+
- name: Install dependencies
20+
run: composer install --no-interaction --no-progress
21+
22+
- name: Run Pint
23+
run: vendor/bin/pint --test

.github/workflows/rector.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Rector
2+
3+
on: [ push, pull_request ]
4+
5+
jobs:
6+
rector:
7+
runs-on: ubuntu-latest
8+
name: Rector
9+
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
14+
- name: Setup PHP
15+
uses: shivammathur/setup-php@v2
16+
with:
17+
php-version: 8.5
18+
19+
- name: Install dependencies
20+
run: composer install --no-interaction --no-progress
21+
22+
- name: Run Rector
23+
run: vendor/bin/rector --dry-run
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: run-tests
1+
name: tests
22

33
on: [push, pull_request]
44

@@ -9,25 +9,31 @@ jobs:
99
fail-fast: false
1010
matrix:
1111
os: [ubuntu-latest]
12-
php: [8.1]
13-
laravel: [9.*]
14-
dependency-version: [prefer-stable]
12+
php: [8.5, 8.4, 8.3, 8.2]
13+
laravel: [13.*, 12.*, 11.*]
14+
exclude:
15+
- laravel: 13.*
16+
php: 8.3
17+
- laravel: 13.*
18+
php: 8.2
1519

16-
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}
20+
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.os }}
1721

1822
steps:
1923
- name: Checkout code
20-
uses: actions/checkout@v2
24+
uses: actions/checkout@v4
2125

2226
- name: Setup PHP
2327
uses: shivammathur/setup-php@v2
2428
with:
2529
php-version: ${{ matrix.php }}
26-
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
30+
extensions: dom, curl, libxml, mbstring, zip
2731
coverage: none
2832

2933
- name: Install dependencies
30-
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress
34+
run: |
35+
composer require "illuminate/support:${{ matrix.laravel }}" --no-interaction --no-update
36+
composer install --no-interaction --no-progress
3137
3238
- name: Execute tests
3339
run: vendor/bin/phpunit

.phpunit.cache/test-results

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

composer.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@
1313
],
1414
"license": "MIT",
1515
"require": {
16-
"php": "^8.0.2",
16+
"php": "^8.2",
1717
"typicms/form": "^3.0.0"
1818
},
1919
"require-dev": {
20-
"phpunit/phpunit": "^9.5.10",
21-
"mockery/mockery": "^1.4.4",
22-
"php-coveralls/php-coveralls": "~2.5.2",
23-
"nunomaduro/larastan": "^2.0",
24-
"orchestra/testbench": "^7.4"
20+
"laravel/pint": "^1.0",
21+
"mockery/mockery": "^1.6",
22+
"phpunit/phpunit": "^11.0",
23+
"rector/rector": "^2.0"
2524
},
2625
"autoload": {
2726
"psr-4": {

phpstan.neon

Lines changed: 0 additions & 13 deletions
This file was deleted.

phpunit.xml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3-
<coverage>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
bootstrap="vendor/autoload.php"
4+
colors="true"
5+
cacheDirectory=".phpunit.cache"
6+
failOnRisky="true"
7+
failOnWarning="true"
8+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd"
9+
>
10+
<source>
411
<include>
512
<directory suffix=".php">./src</directory>
613
</include>
714
<exclude>
815
<file>./src/BootFormsServiceProvider.php</file>
916
<file>./src/Facades/BootForm.php</file>
1017
</exclude>
11-
</coverage>
18+
</source>
1219
<testsuites>
1320
<testsuite name="Package Test Suite">
14-
<directory suffix=".php">./tests/</directory>
21+
<directory suffix="Test.php">./tests</directory>
1522
</testsuite>
1623
</testsuites>
1724
</phpunit>

readme.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# BootForms
22

3-
[![Actions Status](https://github.com/TypiCMS/bootforms/workflows/run-tests/badge.svg)](https://github.com/TypiCMS/bootforms/actions)
4-
[![Coverage Status](https://coveralls.io/repos/github/TypiCMS/bootforms/badge.svg?branch=master)](https://coveralls.io/github/TypiCMS/bootforms?branch=master)
5-
[![StyleCI](https://styleci.io/repos/132662795/shield?branch=master)](https://styleci.io/repos/132662795)
3+
[![Latest Version on Packagist](https://img.shields.io/packagist/v/typicms/bootforms.svg)](https://packagist.org/packages/typicms/bootforms)
4+
[![tests](https://github.com/typicms/bootforms/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/typicms/bootforms/actions/workflows/tests.yml)
5+
[![Rector](https://github.com/typicms/bootforms/actions/workflows/rector.yml/badge.svg?branch=main)](https://github.com/typicms/bootforms/actions/workflows/rector.yml)
6+
[![Pint](https://github.com/typicms/bootforms/actions/workflows/pint.yml/badge.svg?branch=main)](https://github.com/typicms/bootforms/actions/workflows/pint.yml)
67

78
BootForms was originally created by [Adam Wathan](https://github.com/adamwathan). It is build on top of the more general [Form](https://github.com/adamwathan/form) package by adding another layer of abstraction to rapidly generate markup for standard Bootstrap 5 forms. Probably not perfect for your super custom branded ready-for-release apps, but a _huge_ time saver when you are still in the prototyping stage!
89

rector.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
7+
return RectorConfig::configure()
8+
->withPaths([
9+
__DIR__.'/src',
10+
__DIR__.'/tests',
11+
])
12+
->withPhpSets()
13+
->withPreparedSets(
14+
deadCode: true,
15+
codeQuality: true,
16+
codingStyle: true,
17+
typeDeclarations: true,
18+
earlyReturn: true,
19+
);

src/BasicFormBuilder.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@
1313

1414
class BasicFormBuilder
1515
{
16-
protected FormBuilder $builder;
17-
18-
public function __construct(FormBuilder $builder)
19-
{
20-
$this->builder = $builder;
21-
}
16+
public function __construct(protected FormBuilder $builder) {}
2217

2318
protected function formGroup(string $label, string $name, mixed $control): GroupWrapper
2419
{
@@ -130,7 +125,7 @@ protected function radioGroup(string $label, string $name, mixed $control): Grou
130125

131126
protected function buildRadioGroup(string $label, string $name, mixed $control): CheckGroup
132127
{
133-
$id = $name . '_' . mb_strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '_', $control->getAttribute('value'))));
128+
$id = $name.'_'.mb_strtolower(trim((string) preg_replace('/[^A-Za-z0-9-]+/', '_', (string) $control->getAttribute('value'))));
134129
$label = $this->builder->label($label)->addClass('form-check-label')->forId($id);
135130
$control->id($id)->addClass('form-check-input');
136131

@@ -191,9 +186,10 @@ public function file(string $label, string $name, ?string $value = null): GroupW
191186
public function inputGroup(string $label, string $name, ?string $value = null): GroupWrapper
192187
{
193188
$control = new InputGroup($name);
194-
if (!is_null($value) || !is_null($value = $this->getValueFor($name))) {
189+
if (! is_null($value) || ! is_null($value = $this->getValueFor($name))) {
195190
$control->value($value);
196191
}
192+
197193
$control->addClass('form-control');
198194

199195
return $this->formGroup($label, $name, $control);
@@ -206,7 +202,7 @@ public function number(string $label, string $name, ?string $value = null): Grou
206202
return $this->formGroup($label, $name, $control);
207203
}
208204

209-
public function __call($method, $parameters)
205+
public function __call(string $method, array $parameters)
210206
{
211207
return call_user_func_array([$this->builder, $method], $parameters);
212208
}

0 commit comments

Comments
 (0)