Skip to content

Commit

Permalink
Add PHP 8.2 support (#50)
Browse files Browse the repository at this point in the history
* Add PHP 8.1 and drop 7.4 in test coverage

* Resolve 8.2 deprecation warnings

* Update dependencies

* Update minimum Timber version

Timber v1.24 adds support for PHP 8.2

---------

Co-authored-by: Joe Lambert <[email protected]>
  • Loading branch information
joelambert and Joe Lambert authored Feb 27, 2024
1 parent e66e6d9 commit f34fbe7
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php_version: [7.4, 8.0, 8.1]
php_version: [8.0, 8.1, 8.2]
composer_flags: ['', '--prefer-lowest']

steps:
Expand Down
43 changes: 21 additions & 22 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,34 @@
"php": ">=7.3||>=8.0",
"php-di/php-di": "^6.4.0",
"rareloop/router": "^6.0.2",
"psr/container": "^1.0",
"psr/http-message": "^1.0",
"psr/http-server-middleware": "^1.0",
"psr/container": "^1.1.2",
"psr/http-message": "^1.1",
"psr/http-server-middleware": "^1.0.2",
"blast/facades": "^1.0",
"timber/timber": "^1.21.0",
"monolog/monolog": "^2.0",
"timber/timber": "^1.24.0",
"monolog/monolog": "^2.9.1",
"http-interop/response-sender": "^1.0",
"symfony/debug": "^4.1",
"illuminate/collections": "^8.53.1||^9.0.0",
"symfony/debug": "^4.4.44",
"illuminate/collections": "^8.53.1||^9.52.16",
"statamic/stringy": "^3.1.3",
"laminas/laminas-diactoros": "^2.4",
"laminas/laminas-diactoros": "^2.25.2",
"rareloop/psr7-server-request-extension": "^2.1.0",
"mmeyer2k/dcrypt": "^8.0.1",
"spatie/macroable": "^1.0",
"mindplay/middleman": "^3.0.3",
"psr/log": "^1.1",
"laminas/laminas-zendframework-bridge": "^1.4",
"symfony/var-dumper": "^5.0||^6.0"
"mmeyer2k/dcrypt": "^8.3.1",
"spatie/macroable": "^1.0.1",
"mindplay/middleman": "^3.1.0",
"psr/log": "^1.1.4",
"laminas/laminas-zendframework-bridge": "^1.7",
"symfony/var-dumper": "^5.0||^6.3.6"
},
"require-dev": {
"phpunit/phpunit": "^9.5.21",
"php-coveralls/php-coveralls": "^2.0",
"mockery/mockery": "^1.5.0",
"brain/monkey": "~2.4.2",
"squizlabs/php_codesniffer": "^3.6.0",
"php-mock/php-mock": "^2.3.1",
"phpunit/phpunit": "^9.6.13",
"php-coveralls/php-coveralls": "^2.6",
"mockery/mockery": "^1.6.6",
"brain/monkey": "^2.6.1",
"squizlabs/php_codesniffer": "^3.7.2",
"php-mock/php-mock": "^2.4.1",
"mikey179/vfsstream": "1.6.11",
"antecedent/patchwork": "^2.1.21",
"dms/phpunit-arraysubset-asserts": "^0.3.0"
"dms/phpunit-arraysubset-asserts": "^0.3.1"
},
"autoload": {
"psr-4": {
Expand Down
5 changes: 3 additions & 2 deletions src/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Timber\Post as TimberPost;
use Timber\Timber;

#[\AllowDynamicProperties]
class Post extends TimberPost
{
use Macroable {
Expand Down Expand Up @@ -46,15 +47,15 @@ public static function __callStatic($name, $arguments)
return call_user_func_array([$builder, $name], $arguments);
}

trigger_error('Call to undefined method '.__CLASS__.'::'.$name.'()', E_USER_ERROR);
trigger_error('Call to undefined method ' . __CLASS__ . '::' . $name . '()', E_USER_ERROR);
}

/**
* Create a QueryBuilder scoped to this Post type
*
* @return ScopedQueryBuilder
*/
public static function builder() : ScopedQueryBuilder
public static function builder(): ScopedQueryBuilder
{
return new ScopedQueryBuilder(static::class);
}
Expand Down
4 changes: 4 additions & 0 deletions tests/Unit/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,8 @@ public function calling_detectWhenRequestHasNotBeenHandled_adds_actions()

class BootstrapperBootstrapTester
{
public $callback;

public function __construct($callback)
{
$this->callback = $callback;
Expand All @@ -560,6 +562,8 @@ public function __construct($callback)

abstract class TestBootstrapperBase
{
private BootstrapperBootstrapTester $tester;

public function __construct(BootstrapperBootstrapTester $tester)
{
$this->tester = $tester;
Expand Down
13 changes: 11 additions & 2 deletions tests/Unit/PostQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
use Rareloop\Lumberjack\Post;
use Rareloop\Lumberjack\QueryBuilder;
use Rareloop\Lumberjack\ScopedQueryBuilder;
use Throwable;

class PostQueryBuilderTest extends TestCase
{
use \Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration,
\DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;

private Application $app;

public function setUp(): void
{
$this->app = new Application;
Expand Down Expand Up @@ -48,9 +51,15 @@ public function can_create_a_builder_from_static_functions()
*/
public function throw_error_on_missing_static_function()
{
$this->expectError();
$errorThrown = false;

try {
Post::missingStaticFunction();
} catch (Throwable $e) {
$errorThrown = true;
}

Post::missingStaticFunction();
$this->assertTrue($errorThrown);
}

private function assertQueryBuilder($function, $params, $postType)
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Providers/RouterServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function wp_loaded_action_is_bound()
$app->register($provider);
$lumberjack->bootstrap();

$this->assertTrue(has_action('wp_loaded', 'function ()'));
$this->assertNotFalse(has_action('wp_loaded', 'function ()'));
}

/** @test */
Expand Down
Loading

0 comments on commit f34fbe7

Please sign in to comment.