Skip to content

Commit

Permalink
tv bump 4 (#3)
Browse files Browse the repository at this point in the history
* fix lat test

* apply cs

* separate
  • Loading branch information
TomasVotruba committed Feb 18, 2024
1 parent aa99a94 commit f9aea3e
Show file tree
Hide file tree
Showing 27 changed files with 71 additions and 79 deletions.
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms
github: tomasvotruba
custom: https://www.paypal.me/rectorphp
51 changes: 34 additions & 17 deletions .github/workflows/code_analysis.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,46 @@
name: Code Analysis

on:
push: null
pull_request: null
push:
branches:
- main

jobs:
build:
code_analysis:
strategy:
fail-fast: false
matrix:
actions:
-
name: 'Composer Validate'
run: composer validate --ansi

-
name: 'PHPStan'
run: composer phpstan --ansi

-
name: 'Coding Standard'
run: composer fix-cs --ansi

-
name: 'Tests'
run: vendor/bin/phpunit

name: ${{ matrix.actions.name }}
runs-on: ubuntu-latest

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
# see https://github.com/shivammathur/setup-php
- uses: shivammathur/setup-php@v2
with:
php-version: 8.2
coverage: none

- name: Validate composer
run: composer validate
# composer install cache - https://github.com/ramsey/composer-install
- uses: "ramsey/composer-install@v2"

- name: Install dependencies
run: composer install

- name: Run static type analysis
run: vendor/bin/phpstan

- name: Run test suite
run: vendor/bin/phpunit
- run: ${{ matrix.actions.run }}
23 changes: 2 additions & 21 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,8 @@

declare(strict_types=1);

use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;

return ECSConfig::configure()
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
])

// add a single rule
->withRules([
NoUnusedImportsFixer::class,
])

// add sets - group of rules
// ->withPreparedSets(
// arrays: true,
// namespaces: true,
// spaces: true,
// docblocks: true,
// comments: true,
// )

;
->withPaths([__DIR__ . '/src', __DIR__ . '/tests'])
->withPreparedSets(psr12: true);
14 changes: 7 additions & 7 deletions src/CakePHP/PortedInflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,13 @@ public static function pluralize($word)

if (!isset(static::$_plural['cacheUninflected']) || !isset(static::$_plural['cacheIrregular'])) {
static::$_plural['cacheUninflected'] = '(?:' . implode(
'|',
static::$_plural['merged']['uninflected']
) . ')';
'|',
static::$_plural['merged']['uninflected']
) . ')';
static::$_plural['cacheIrregular'] = '(?:' . implode(
'|',
array_keys(static::$_plural['merged']['irregular'])
) . ')';
'|',
array_keys(static::$_plural['merged']['irregular'])
) . ')';
}

if (preg_match('/(.*?(?:\\b|_))(' . static::$_plural['cacheIrregular'] . ')$/i', $word, $regs)) {
Expand Down Expand Up @@ -272,6 +272,6 @@ public static function pluralize($word)
private static function underscore($camelCasedWord)
{
$underscoredWord = preg_replace('/(?<=\\w)([A-Z])/', '_\\1', (string) $camelCasedWord);
return mb_strtolower($underscoredWord);
return mb_strtolower($underscoredWord);
}
}
2 changes: 1 addition & 1 deletion src/ClassMethodExtension/ModelMethodExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static function (
return $methodReflection->getName() === $methodName;
}
);
if (! $methodReflections) {
if (!$methodReflections) {
throw new Exception('Method not found');
}
return reset($methodReflections);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private function getDefinedComponentsAsList(ClassReflection $classReflection): a
$definedComponents = [];

foreach (array_merge([$classReflection], $classReflection->getParents()) as $class) {
if (! $class->hasProperty('components')) {
if (!$class->hasProperty('components')) {
continue;
}

Expand All @@ -89,7 +89,7 @@ private function getDefinedComponentsAsList(ClassReflection $classReflection): a
->getDefaultValueExpression();

if (!$defaultValue instanceof Array_) {
continue;
continue;
}

foreach ($defaultValue->items as $item) {
Expand Down
1 change: 0 additions & 1 deletion src/ClassPropertyExtension/ShellClassPropertyExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace PHPStanCakePHP2\ClassPropertyExtension;


/**
* Adds {@link Model}s as properties to {@link Shell}s.
*
Expand Down
4 changes: 2 additions & 2 deletions src/ModelBehaviorMethodExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private function filterBehaviorMethods(
ExtendedMethodReflection $methodReflection
): bool {
return $methodReflection->isPublic()
&& ! $methodReflection->isStatic()
&& !$methodReflection->isStatic()
&& array_filter(
$methodReflection->getVariants(),
[$this, 'filterBehaviorMethodVariants']
Expand All @@ -87,7 +87,7 @@ private function filterBehaviorMethodVariants(
/** @var ParameterReflection|null $firstParameter */
$firstParameter = array_shift($parameters);

if (! $firstParameter) {
if (!$firstParameter) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Reflection/ClassReflectionFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private function getClassNamesFromPaths(
$classPaths = [];
foreach ($paths as $path) {
$filePaths = glob($path);
if (! is_array($filePaths)) {
if (!is_array($filePaths)) {
throw new Exception(sprintf('glob(%s) caused an error', $path));
}
$classPaths = array_merge($classPaths, $filePaths);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

use function PHPStan\Testing\assertType;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

use function PHPStan\Testing\assertType;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

use function PHPStan\Testing\assertType;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

use function PHPStan\Testing\assertType;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

use function PHPStan\Testing\assertType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace PHPStanCakePHP2\Tests\ClassPropertyExtension\ClassModelsPropertyExtension;

use Iterator;
use PHPStan\Testing\TypeInferenceTestCase;
use PHPUnit\Framework\Attributes\DataProvider;

Expand All @@ -18,10 +19,9 @@ public function test(string $assertType, string $file, ...$args): void
$this->assertFileAsserts($assertType, $file, ...$args);
}

public static function dataFileAsserts(): \Iterator
public static function dataFileAsserts(): Iterator
{
yield from self::gatherAssertTypes(__DIR__ . '/Fixture/core_model_behavior.php');
yield from self::gatherAssertTypes(__DIR__ . '/Fixture/custom_model_behavior.php');
yield from self::gatherAssertTypes(__DIR__ . '/Fixture/invalid_model_property.php');
yield from self::gatherAssertTypes(__DIR__ . '/Fixture/existing_model_model.php');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

use function PHPStan\Testing\assertType;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

use function PHPStan\Testing\assertType;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

use function PHPStan\Testing\assertType;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

use function PHPStan\Testing\assertType;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

use function PHPStan\Testing\assertType;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

use function PHPStan\Testing\assertType;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

use function PHPStan\Testing\assertType;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

use function PHPStan\Testing\assertType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public function test(string $assertType, string $file, ...$args): void
public static function dataFileAsserts(): \Iterator
{
yield from self::gatherAssertTypes(__DIR__ . '/Fixture/existing_shell_model.php');
// yield from self::gatherAssertTypes(__DIR__ . '/Fixture/existing_shell_task.php');
// yield from self::gatherAssertTypes(__DIR__ . '/Fixture/invalid_shell_property.php');
// yield from self::gatherAssertTypes(__DIR__ . '/Fixture/existing_shell_task.php');
// yield from self::gatherAssertTypes(__DIR__ . '/Fixture/invalid_shell_property.php');
}

/**
Expand Down
1 change: 1 addition & 0 deletions tests/Source/Model/Behavior/BasicBehavior.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

namespace PHPStanCakePHP2\Tests\Source\Model\Behavior;

use Model;
use ModelBehavior;

Expand Down
1 change: 1 addition & 0 deletions tests/Source/Model/SameAsModel.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

namespace PHPStanCakePHP2\Tests\Source\Model;

use Model;

class SameAsModel extends Model
Expand Down

0 comments on commit f9aea3e

Please sign in to comment.