Skip to content

Commit

Permalink
Merge pull request #3 from artemeon/feat/#23382-rector
Browse files Browse the repository at this point in the history
#23382 feat(*): run rector over source
  • Loading branch information
marcreichel authored Jan 27, 2025
2 parents fa37660 + cc3919b commit a211978
Show file tree
Hide file tree
Showing 27 changed files with 820 additions and 163 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/pest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Pest

on:
- pull_request

jobs:
type-coverage:
name: Type-Coverage
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.4
coverage: xdebug
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Composer install
run: composer install --no-interaction --no-ansi --no-progress
- name: Run Type-Coverage
run: composer test:type-coverage
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.4
coverage: xdebug
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Composer install
run: composer install --no-interaction --no-ansi --no-progress
- name: Run Tests
run: composer test:coverage
9 changes: 9 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: PHPStan
on:
pull_request:
push:
branches:
- 1.x
jobs:
phpstan:
uses: artemeon/.shared/.github/workflows/phpstan-php84-upwards.yml@main
27 changes: 27 additions & 0 deletions .github/workflows/pint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Pint

on:
- pull_request

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
pint:
name: Pint (PHP-CS-Fixer)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.4
coverage: none
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Composer install
run: composer install --no-interaction --no-ansi --no-progress
- name: Run Pint
run: ./vendor/bin/pint --test -v
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/.idea/
/vendor/
composer.lock
7 changes: 0 additions & 7 deletions CHANGELOG.de.md

This file was deleted.

6 changes: 3 additions & 3 deletions CHANGELOG.en.md → CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Stream-Context

## 0.1.1
- The enforcement of valid file extensions has been deactivated for file URLs without an explicit file extension such as ‘http://example.com/fetch_some_stream’.

## 0.1.0
- Initial release

## 0.1.1
- The enforcement of valid file extensions has been deactivated for file URLs without an explicit file extension such as ‘http://example.com/fetch_some_stream’.
26 changes: 24 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@
"type": "library",
"description": "Library to create a stream context",
"keywords": [
"php7",
"stream",
"context"
],
"scripts": {
"test": "./vendor/bin/pest",
"test:coverage": "XDEBUG_MODE=coverage ./vendor/bin/pest --mutate --parallel --min=100",
"test:type-coverage": "./vendor/bin/pest --type-coverage --min=100",
"phpstan": "php ./vendor/bin/phpstan analyse --memory-limit=4G",
"pint": "./vendor/bin/pint --test -v",
"pint:fix": "./vendor/bin/pint -v"
},
"authors": [
{
"name": "Dietmar Simons",
Expand All @@ -21,7 +28,22 @@
}
},
"require": {
"php": ">=7.4",
"php": ">=8.4",
"phpseclib/phpseclib": "~3.0"
},
"require-dev": {
"laravel/pint": "^1.20.0",
"mockery/mockery": "^1.6.12",
"phpstan/phpstan": "^2.1.2",
"rector/rector": "^2.0.7",
"pestphp/pest": "^3.7",
"pestphp/pest-plugin-type-coverage": "^3.2",
"pestphp/pest-plugin-faker": "^3.0",
"pestphp/pest-plugin-watch": "^3.0"
},
"config": {
"allow-plugins": {
"pestphp/pest-plugin": true
}
}
}
7 changes: 7 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
includes:
- phar://phpstan.phar/conf/bleedingEdge.neon

parameters:
level: 10
paths:
- src
17 changes: 17 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
134 changes: 134 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
{
"preset": "psr12",
"rules": {
"align_multiline_comment": true,
"array_indentation": true,
"array_push": true,
"array_syntax": {
"syntax": "short"
},
"assign_null_coalescing_to_coalesce_equal": true,
"binary_operator_spaces": true,
"blank_line_before_statement": true,
"cast_spaces": true,
"clean_namespace": true,
"combine_consecutive_issets": true,
"combine_consecutive_unsets": true,
"compact_nullable_typehint": true,
"concat_space": {
"spacing": "one"
},
"fully_qualified_strict_types": true,
"function_to_constant": true,
"general_phpdoc_annotation_remove": {
"annotations": [
"since"
],
"case_sensitive": false
},
"get_class_to_class_keyword": true,
"is_null": true,
"lambda_not_used_import": true,
"logical_operators": true,
"method_chaining_indentation": true,
"modernize_types_casting": true,
"multiline_whitespace_before_semicolons": true,
"no_empty_comment": true,
"no_empty_phpdoc": true,
"no_empty_statement": true,
"no_extra_blank_lines": {
"tokens": [
"attribute",
"break",
"case",
"continue",
"curly_brace_block",
"default",
"extra",
"parenthesis_brace_block",
"return",
"square_brace_block",
"switch",
"throw",
"use",
"use_trait"
]
},
"no_multiline_whitespace_around_double_arrow": true,
"no_short_bool_cast": true,
"no_singleline_whitespace_before_semicolons": true,
"no_superfluous_elseif": false,
"no_superfluous_phpdoc_tags": true,
"no_trailing_comma_in_singleline": true,
"no_unneeded_control_parentheses": true,
"no_useless_concat_operator": true,
"no_useless_else": true,
"no_useless_nullsafe_operator": true,
"no_useless_return": true,
"no_whitespace_before_comma_in_array": true,
"nullable_type_declaration": true,
"object_operator_without_whitespace": true,
"ordered_imports": {
"imports_order": [
"class",
"function",
"const"
],
"sort_algorithm": "alpha"
},
"ordered_interfaces": true,
"ordered_types": {
"null_adjustment": "always_last"
},
"phpdoc_align": {
"align": "left"
},
"phpdoc_indent": true,
"phpdoc_no_useless_inheritdoc": true,
"phpdoc_order": true,
"phpdoc_scalar": true,
"phpdoc_single_line_var_spacing": true,
"phpdoc_summary": true,
"phpdoc_tag_casing": true,
"phpdoc_trim": true,
"phpdoc_trim_consecutive_blank_line_separation": true,
"phpdoc_var_without_name": true,
"php_unit_construct": true,
"php_unit_dedicate_assert": true,
"php_unit_dedicate_assert_internal_type": true,
"php_unit_internal_class": true,
"php_unit_method_casing": true,
"return_assignment": true,
"return_type_declaration": true,
"short_scalar_cast": true,
"single_line_comment_spacing": true,
"single_line_comment_style": true,
"single_quote": true,
"single_space_around_construct": true,
"ternary_to_null_coalescing": true,
"trailing_comma_in_multiline": {
"elements": [
"arguments",
"arrays",
"match",
"parameters"
]
},
"trim_array_spaces": true,
"type_declaration_spaces": true,
"types_spaces": {
"space": "single"
},
"use_arrow_functions": false,
"void_return": true,
"whitespace_after_comma_in_array": {
"ensure_single_space": true
},
"yoda_style": {
"equal": false,
"identical": false,
"less_and_greater": false,
"always_move_variable": false
}
}
}
34 changes: 34 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;

return RectorConfig::configure()
->withPhpSets()
->withRules([
Rector\CodeQuality\Rector\Ternary\ArrayKeyExistsTernaryThenValueToCoalescingRector::class,
Rector\CodeQuality\Rector\NullsafeMethodCall\CleanupUnneededNullsafeOperatorRector::class,
Rector\CodeQuality\Rector\ClassMethod\InlineArrayReturnAssignRector::class,
Rector\CodeQuality\Rector\Ternary\UnnecessaryTernaryExpressionRector::class,
Rector\DeadCode\Rector\Foreach_\RemoveUnusedForeachKeyRector::class,
Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictFluentReturnRector::class,
Rector\Php80\Rector\Class_\StringableForToStringRector::class,
Rector\CodingStyle\Rector\ArrowFunction\StaticArrowFunctionRector::class,
Rector\CodingStyle\Rector\Closure\StaticClosureRector::class,
Rector\DeadCode\Rector\Node\RemoveNonExistingVarAnnotationRector::class,
Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodParameterRector::class,
Rector\TypeDeclaration\Rector\ClassMethod\BoolReturnTypeFromBooleanStrictReturnsRector::class,
Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector::class,
Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByMethodCallTypeRector::class,
Rector\TypeDeclaration\Rector\ClassMethod\NumericReturnTypeFromStrictScalarReturnsRector::class,
Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector::class,
Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector::class,
Rector\CodeQuality\Rector\Foreach_\ForeachItemsAssignToEmptyArrayToAssignRector::class,
Rector\CodeQuality\Rector\Foreach_\ForeachToInArrayRector::class,
Rector\CodeQuality\Rector\BooleanAnd\RemoveUselessIsObjectCheckRector::class,
])
->withPaths([
__DIR__ . '/src',
])
->withTypeCoverageLevel(0);
10 changes: 10 additions & 0 deletions src/Context/HttpMethod.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Artemeon\StreamContext\Context;

enum HttpMethod: string
{
case GET = 'GET';
case POST = 'POST';
case PUT = 'PUT';
}
Loading

0 comments on commit a211978

Please sign in to comment.