diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml new file mode 100644 index 0000000..52cc8ac --- /dev/null +++ b/.github/workflows/coding-standards.yml @@ -0,0 +1,26 @@ +name: "Check Coding Standards" + +on: + pull_request: + +jobs: + coding-standards: + name: "Check Coding Standards" + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: "7.4" + tools: composer:v2, cs2pr + + - name: Install dependencies + run: composer require phpcsstandards/php_codesniffer --no-interaction --no-progress + + - name: "Run phpcs" + run: vendor/bin/phpcs -q --standard=PSR2 classes/ tests/ --report=checkstyle | cs2pr diff --git a/.github/workflows/phpmd.yml b/.github/workflows/phpmd.yml new file mode 100644 index 0000000..4854690 --- /dev/null +++ b/.github/workflows/phpmd.yml @@ -0,0 +1,26 @@ +name: "Check phpmd" + +on: + pull_request: + +jobs: + coding-standards: + name: "Check phpmd" + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: "7.4" + tools: composer:v2 + + - name: Install dependencies + run: composer require phpmd/phpmd --no-interaction --no-progress + + - name: Run phpmd + run: vendor/bin/phpmd classes/ text cleancode,codesize,controversial,design,naming,unusedcode diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index efd4bcc..a6eb00d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,6 +23,7 @@ jobs: - '7.1' - '7.0' phpunit-version: + - '10.5.0' - '10.4.0' - '10.3.0' - '10.2.0' @@ -193,6 +194,8 @@ jobs: phpunit-version: '6.0.0' # PHP 8.0 Exclusions + - php-version: '8.0' + phpunit-version: '10.5.0' - php-version: '8.0' phpunit-version: '10.4.0' - php-version: '8.0' @@ -245,6 +248,8 @@ jobs: phpunit-version: '6.0.0' # PHP 7.4 Exclusions + - php-version: '7.4' + phpunit-version: '10.5.0' - php-version: '7.4' phpunit-version: '10.4.0' - php-version: '7.4' @@ -283,6 +288,8 @@ jobs: phpunit-version: '6.0.0' # PHP 7.3 Exclusions + - php-version: '7.3' + phpunit-version: '10.5.0' - php-version: '7.3' phpunit-version: '10.4.0' - php-version: '7.3' @@ -295,6 +302,8 @@ jobs: phpunit-version: '10.0.0' # PHP 7.2 Exclusions + - php-version: '7.2' + phpunit-version: '10.5.0' - php-version: '7.2' phpunit-version: '10.4.0' - php-version: '7.2' @@ -321,6 +330,8 @@ jobs: phpunit-version: '9.0.0' # PHP 7.1 Exclusions + - php-version: '7.1' + phpunit-version: '10.5.0' - php-version: '7.1' phpunit-version: '10.4.0' - php-version: '7.1' @@ -359,6 +370,8 @@ jobs: phpunit-version: '8.0.0' # PHP 7.0 Exclusions + - php-version: '7.0' + phpunit-version: '10.5.0' - php-version: '7.0' phpunit-version: '10.4.0' - php-version: '7.0' @@ -411,7 +424,7 @@ jobs: name: PHPUnit ${{ matrix.phpunit-version }} on PHP ${{ matrix.php-version }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install PHP uses: shivammathur/setup-php@v2 @@ -419,13 +432,7 @@ jobs: php-version: ${{ matrix.php-version }} - name: Install Dependencies - run: composer require phpunit/phpunit:~${{ matrix.phpunit-version }} squizlabs/php_codesniffer phpmd/phpmd + run: composer require phpunit/phpunit:~${{ matrix.phpunit-version }} --no-interaction --no-progress - name: PHPUnit run: vendor/bin/phpunit - - - name: PHPCS - run: vendor/bin/phpcs --standard=PSR2 classes/ tests/ - - - name: PHPMD - run: vendor/bin/phpmd classes/ text cleancode,codesize,controversial,design,naming,unusedcode diff --git a/classes/PHPMock.php b/classes/PHPMock.php index 2a12b03..543db17 100644 --- a/classes/PHPMock.php +++ b/classes/PHPMock.php @@ -210,7 +210,7 @@ private function prepareCustomTemplates() $reflectionTemplates = $reflection->getProperty('templates'); $reflectionTemplates->setAccessible(true); - $reflectionTemplates->setValue($templates); + $reflectionTemplates->setValue(null, $templates); break; } diff --git a/tests/MockObjectProxyTest.php b/tests/MockObjectProxyTest.php index e9020d4..482e052 100644 --- a/tests/MockObjectProxyTest.php +++ b/tests/MockObjectProxyTest.php @@ -34,12 +34,25 @@ public function testExpects() { $matcher = $this->getMockBuilder(Invocation::class)->getMock(); - $methods = class_exists(ConfigurableMethod::class) - ? new ConfigurableMethod( - MockDelegateFunctionBuilder::METHOD, - Mockery::mock(Type::class) - ) - : [MockDelegateFunctionBuilder::METHOD]; + if (class_exists(ConfigurableMethod::class)) { + if (class_exists(\PHPUnit\Runner\Version::class) + && version_compare(\PHPUnit\Runner\Version::id(), '10.5.0') >= 0 + ) { + $methods = new ConfigurableMethod( + MockDelegateFunctionBuilder::METHOD, + [], + 0, + Mockery::mock(Type::class) + ); + } else { + $methods = new ConfigurableMethod( + MockDelegateFunctionBuilder::METHOD, + Mockery::mock(Type::class) + ); + } + } else { + $methods = [MockDelegateFunctionBuilder::METHOD]; + } if (class_exists(\PHPUnit\Runner\Version::class) && version_compare(\PHPUnit\Runner\Version::id(), '8.4.0') >= 0