Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
Expand Down
27 changes: 18 additions & 9 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
* text=auto

# Path-based git attributes
# https://git-scm.com/docs/gitattributes
* text=auto

# Ignore all test and documentation with "export-ignore".
/.editorconfig export-ignore
/.gitattributes export-ignore
/.github export-ignore
/.gitignore export-ignore
/phpunit.xml export-ignore
/rector.php export-ignore
/tests export-ignore
/.github export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/phpunit.xml.dist export-ignore
/art export-ignore
/docs export-ignore
/tests export-ignore
/.editorconfig export-ignore
/.php_cs.dist.php export-ignore
/psalm.xml export-ignore
/psalm.xml.dist export-ignore
/testbench.yaml export-ignore
/UPGRADING.md export-ignore
/phpstan.neon.dist export-ignore
/phpstan-baseline.neon export-ignore
/docker export-ignore
/docker-compose.yml export-ignore
32 changes: 32 additions & 0 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Dependabot Auto-Merge
on: pull_request_target

permissions:
pull-requests: write
contents: write

jobs:
dependabot:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:

- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v2
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

- name: Auto-merge Dependabot PRs for semver-minor updates
if: ${{ steps.metadata.outputs.update-type == 'version-update:semver-minor' }}
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Auto-merge Dependabot PRs for semver-patch updates
if: ${{ steps.metadata.outputs.update-type == 'version-update:semver-patch' }}
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47 changes: 47 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Static Analysis

on:
push:
paths:
- '**.php'
- 'phpstan.neon.dist'

jobs:
phpstan:
name: PHPStan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
coverage: none

- name: Install composer dependencies
uses: ramsey/composer-install@v3

- name: Run PHPStan
run: composer test:types

ecs:
name: ECS

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
coverage: none

- name: Install Dependencies
run: composer update --prefer-dist --no-interaction --no-progress --ansi

- name: Run ECS
run: composer test:style
31 changes: 19 additions & 12 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,27 @@ name: Tests

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
setup:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ ubuntu-latest ]
php: [ 8.2, 8.3 ]
laravel: [ 10.*, 11.* ]
stability: [ prefer-lowest, prefer-stable ]
os: [ubuntu-latest]
php: [8.4, 8.3]
laravel: [12.*, 11.*]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 10.*
testbench: 8.*
- laravel: 12.*
testbench: 10.*
- laravel: 11.*
testbench: 9.*

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

steps:
- name: Checkout code
Expand All @@ -28,13 +31,17 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
extensions: oauth
coverage: none
php-version: ${{ matrix.php }}
coverage: none

- name: Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Install Composer dependencies
- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update --ansi
composer update --${{ matrix.stability }} --prefer-dist --no-interaction --ansi

- name: Execute tests
Expand Down
16 changes: 13 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
/.idea
/build
composer.lock
vendor
/vendor
/.php_cs.cache
/composer.lock
/phpunit.xml
/phpstan.neon
.php_cs
.php_cs.cache
.phpunit.cache
.idea
.php-cs-fixer.cache
coverage
docs
node_modules
testbench.yaml
15 changes: 9 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
"type": "library",
"license": "MIT",
"require": {
"php": "^8.2",
"illuminate/support": "^10.0 || ^11.0",
"illuminate/contracts": "^10.0 || ^11.0"
"php": "^8.3",
"illuminate/support": "^11.0 || ^12.0",
"illuminate/contracts": "^11.0 || ^12.0"
},
"require-dev": {
"pestphp/pest": "^2.33",
"worksome/coding-style": "^2.8",
"mockery/mockery": "^1.6"
"mockery/mockery": "^1.6",
"orchestra/testbench": "^9.12 || ^10.1",
"pestphp/pest": "^3.1",
"worksome/coding-style": "^3.2"
},
"autoload": {
"psr-4": {
Expand All @@ -26,10 +27,12 @@
"scripts": {
"lint": "vendor/bin/ecs --fix",
"test:unit": "vendor/bin/pest",
"test:types": "vendor/bin/phpstan analyse",
"test:coverage": "vendor/bin/pest --coverage --min=95",
"test:style": "vendor/bin/ecs",
"test": [
"@test:style",
"@test:types",
"@test:unit"
]
},
Expand Down
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
services:
php:
build: ./docker
volumes:
- .:/var/www/html
environment:
- XDEBUG_MODE=${XDEBUG_MODE:-off}
- XDEBUG_CONFIG=${XDEBUG_CONFIG:-client_host=host.docker.internal}
composer:
build: ./docker
entrypoint: ["composer"]
volumes:
- .:/var/www/html
11 changes: 11 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM php:8.3-cli-alpine

RUN apk add --no-cache $PHPIZE_DEPS linux-headers
RUN pecl install xdebug
RUN docker-php-ext-enable xdebug

COPY --from=composer:2 /usr/bin/composer /usr/bin/composer

WORKDIR /var/www/html

ENTRYPOINT ["php"]
Empty file added phpstan-baseline.neon
Empty file.
19 changes: 19 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
includes:
- ./vendor/worksome/coding-style/larastan.neon
- phpstan-baseline.neon

parameters:
level: 5
paths:
- src
- config
tmpDir: build/phpstan
checkModelProperties: true
parallel:
processTimeout: 300.0

ignoreErrors:
-
identifier: larastan.noEnvCallsOutsideOfConfig
path: config
reportUnmatched: false
14 changes: 14 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
cacheDirectory=".phpunit.cache"
>
<testsuites>
<testsuite name="Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
2 changes: 2 additions & 0 deletions src/CdnHeadersManager.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Worksome\CdnHeaders;

use Illuminate\Support\Manager;
Expand Down
6 changes: 4 additions & 2 deletions src/CdnHeadersServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Worksome\CdnHeaders;

use Illuminate\Contracts\Container\Container;
Expand All @@ -18,12 +20,12 @@ public function register(): void
{
$this->app->singleton(
CdnHeadersManager::class,
static fn(Container $container) => new CdnHeadersManager($container)
static fn (Container $container) => new CdnHeadersManager($container)
);

$this->app->singleton(
CdnHeadersProvider::class,
static fn(Container $app) => $app->get(CdnHeadersManager::class)->driver()
static fn (Container $app) => $app->get(CdnHeadersManager::class)->driver()
);
}

Expand Down
2 changes: 2 additions & 0 deletions src/Contracts/CdnHeadersProvider.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Worksome\CdnHeaders\Contracts;

interface CdnHeadersProvider
Expand Down
2 changes: 2 additions & 0 deletions src/Providers/CloudFlare/CloudFlareProvider.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Worksome\CdnHeaders\Providers\CloudFlare;

use Worksome\CdnHeaders\Contracts\CdnHeadersProvider;
Expand Down
2 changes: 2 additions & 0 deletions src/Providers/FakeProvider.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Worksome\CdnHeaders\Providers;

use Worksome\CdnHeaders\Contracts\CdnHeadersProvider;
Expand Down
8 changes: 4 additions & 4 deletions src/ServerHeadersRepository.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

declare(strict_types=1);

namespace Worksome\CdnHeaders;

class ServerHeadersRepository
{
/**
* @return non-empty-string|null
*/
/** @return non-empty-string|null */
public function get(string $key): string|null
{
if (isset($_SERVER[$key])) {
Expand All @@ -25,6 +25,6 @@ public function set(string $key, string $value): string

public function has(string $key): bool
{
return isset($_SERVER[$key]) ?? false;
return isset($_SERVER[$key]);
}
}
2 changes: 2 additions & 0 deletions tests/CdnHeadersManagerTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

use Illuminate\Contracts\Config\Repository;
use Illuminate\Contracts\Container\Container;
use Worksome\CdnHeaders\CdnHeadersManager;
Expand Down
2 changes: 2 additions & 0 deletions tests/CloudFlare/CloudFlareProviderTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

use Worksome\CdnHeaders\Providers\CloudFlare\CloudFlareProvider;
use Worksome\CdnHeaders\ServerHeadersRepository;

Expand Down
Loading