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
13 changes: 9 additions & 4 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,25 @@ on: [push]
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [8.3, 8.4]
name: PHP ${{ matrix.php }}
steps:
- name: Checkout code
uses: actions/checkout@v1
uses: actions/checkout@v4

- name: Cache dependencies
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: ~/.composer/cache/files
key: dependencies-composer-${{ hashFiles('composer.json') }}
key: dependencies-composer-${{ matrix.php }}-${{ hashFiles('composer.json') }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
coverage: none
env:
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ composer.lock
vendor
coverage
.phpunit.result.cache

#nix dev env
.envrc
.devenv
.direnv
177 changes: 93 additions & 84 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,92 +1,101 @@
{
"name": "spatie/laravel-blade-x",
"description": "Supercharged Blade components",
"keywords": [
"spatie",
"blade",
"components",
"html",
"laravel-blade-x"
],
"homepage": "https://github.com/spatie/laravel-blade-x",
"license": "MIT",
"authors": [
{
"name": "Sebastian De Deyne",
"email": "sebastian@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
},
{
"name": "Brent Roose",
"email": "brent@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
},
{
"name": "Ruben Van Assche",
"email": "ruben@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
},
{
"name": "Freek Van der Herten",
"email": "freek@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
},
{
"name": "Alex Vanderbist",
"email": "alex@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
}
],
"require": {
"php": "^7.2|^8.1",
"laravel/framework": ">=4.1,<4.3",
"symfony/filesystem": "^6.4"
"name": "spatie/laravel-blade-x",
"description": "Supercharged Blade components",
"keywords": [
"spatie",
"blade",
"components",
"html",
"laravel-blade-x"
],
"homepage": "https://github.com/spatie/laravel-blade-x",
"license": "MIT",
"authors": [
{
"name": "Sebastian De Deyne",
"email": "sebastian@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
},
"require-dev": {
"anlutro/l4-testing": "dev-master",
"laravel/laravel": "dev-master",
"phpunit/phpunit": "^9.5"
{
"name": "Brent Roose",
"email": "brent@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
},
"autoload": {
"files": [
"src/Laravel/helpers.php"
],
"psr-4": {
"Spatie\\BladeX\\": "src"
}
{
"name": "Ruben Van Assche",
"email": "ruben@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
},
"autoload-dev": {
"psr-4": {
"Spatie\\BladeX\\Tests\\": "tests"
}
{
"name": "Freek Van der Herten",
"email": "freek@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
},
"scripts": {
"test": "vendor/bin/phpunit",
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
{
"name": "Alex Vanderbist",
"email": "alex@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
}
],
"require": {
"php": "^7.2|^8.1",
"laravel/framework": ">=4.1,<4.3",
"symfony/filesystem": "^6.4"
},
"require-dev": {
"laravel/laravel": "dev-master",
"phpunit/phpunit": "^9.5",
"rector/rector": "^2.5"
},
"autoload": {
"files": [
"src/Laravel/helpers.php"
],
"psr-4": {
"Spatie\\BladeX\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Spatie\\BladeX\\Tests\\": "tests"
}
},
"scripts": {
"test": "vendor/bin/phpunit",
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
},
"config": {
"sort-packages": true,
"allow-plugins": {
"kylekatarnls/update-helper": true
},
"config": {
"sort-packages": true,
"allow-plugins": {
"kylekatarnls/update-helper": true
}
"audit": {
"ignore": {
"PKSA-8qx3-n5y5-vvnd": "nested array validation with wildcard is not supported in laravel 4.2",
"PKSA-w7xr-vk7n-rstm": "affected only when register_argc_argv is 'on' in php.ini",
"PKSA-3qhw-gzjt-j63j": "affected only laravel 5.5.40 and 5.6.x through 5.6.29",
"PKSA-17kp-jm2n-vxzz": "there is no link() function in Laravel 4.2 Filesystem/Filesystem.php",
"PKSA-7ywf-hktb-jkn9": "JSON nested attribute handling not implemented in 4.2, JSON columns is treated as string in 4.2",
"PKSA-njrm-6dtg-m2pc": "this is only affected newer blade engine such as laravel >5.x because it use hashed parent placeholder and inserted into raw HTML",
"PKSA-nrj3-r2wg-yt8b": "this is only affected when we use 'cookie' driver in session ",
"PKSA-m5cs-t1y6-qpcs": "update or not update still vulnerable, because affected to < 12.61.1",
"PKSA-3r5d-mb8f-1qw9": "update or not update still vulnerable, because affected to < 12.60.0"
}
}
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/dicoding-dev/L42x"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/dicoding-dev/L42x"
},
{
"type": "vcs",
"url": "https://github.com/dicoding-dev/L42x-app"
},
{
"type": "vcs",
"url": "https://github.com/dicoding-dev/laravel-testing"
}
]
{
"type": "vcs",
"url": "https://github.com/dicoding-dev/L42x-app"
}
]
}
32 changes: 32 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Php83\Rector\BooleanAnd\JsonValidateRector;
use Rector\Php83\Rector\ClassConst\AddTypeToConstRector;
use Rector\Php83\Rector\ClassMethod\AddOverrideAttributeToOverriddenMethodsRector;
use Rector\Php83\Rector\FuncCall\CombineHostPortLdapUriRector;
use Rector\Php83\Rector\FuncCall\DynamicClassConstFetchRector;
use Rector\Php83\Rector\FuncCall\RemoveGetClassGetParentClassNoArgsRector;
use Rector\Php83\Rector\Class_\ReadOnlyAnonymousClassRector;
use Rector\Php84\Rector\FuncCall\AddEscapeArgumentRector;
use Rector\Php84\Rector\Param\ExplicitNullableParamTypeRector;

return RectorConfig::configure()
->withPhpVersion(80400)
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
])
->withRules([
DynamicClassConstFetchRector::class,
CombineHostPortLdapUriRector::class,
RemoveGetClassGetParentClassNoArgsRector::class,
JsonValidateRector::class,
AddTypeToConstRector::class,
ReadOnlyAnonymousClassRector::class,
AddOverrideAttributeToOverriddenMethodsRector::class,
ExplicitNullableParamTypeRector::class,
AddEscapeArgumentRector::class,
]);
3 changes: 3 additions & 0 deletions src/BladeXServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

class BladeXServiceProvider extends ViewServiceProvider
{
#[\Override]
public function register()
{
parent::register();
Expand All @@ -19,6 +20,7 @@ public function register()
$this->registerBladeXCompiler();
}

#[\Override]
public function registerFactory()
{
$this->app->bindShared('view', function($app) {
Expand All @@ -35,6 +37,7 @@ public function registerFactory()
});
}

#[\Override]
public function registerBladeEngine($resolver)
{
$this->app->bindShared('blade.compiler', function($app)
Expand Down
1 change: 1 addition & 0 deletions src/ComponentDirectory/NamespacedDirectory.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function getAbsoluteDirectory(): string
return $viewPath ? "{$absoluteDirectory}/{$viewPath}" : $absoluteDirectory;
}

#[\Override]
public function getViewName(SplFileInfo $viewFile): string
{
return "{$this->namespace}::".parent::getViewName($viewFile);
Expand Down
9 changes: 8 additions & 1 deletion src/Laravel/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

class Collection extends L4Collection
{
public function filter(Closure $callback = null)
#[\Override]
public function filter(?Closure $callback = null)
{
if ($callback) {
// return new static(Arr::where($this->items, $callback));
Expand All @@ -17,6 +18,7 @@ public function filter(Closure $callback = null)
return new static(array_filter($this->items));
}

#[\Override]
public function implode($value, $glue = null)
{
$first = $this->first();
Expand All @@ -28,6 +30,7 @@ public function implode($value, $glue = null)
return implode($value, $this->items);
}

#[\Override]
public function mapWithKeys(callable $callback)
{
$result = [];
Expand All @@ -48,6 +51,7 @@ public function pluck($value, $key = null)
return new static(array_pluck($this->items, $value, $key));
}

#[\Override]
public function unique($key = null, $strict = false)
{
$callback = $this->valueRetriever($key);
Expand All @@ -63,6 +67,7 @@ public function unique($key = null, $strict = false)
});
}

#[\Override]
public function reject($callback)
{
$useAsCallable = $this->useAsCallable($callback);
Expand All @@ -74,11 +79,13 @@ public function reject($callback)
});
}

#[\Override]
protected function useAsCallable($value)
{
return ! is_string($value) && is_callable($value);
}

#[\Override]
protected function valueRetriever($value)
{
if ($this->useAsCallable($value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SelectViewModel extends ViewModel
/** @var string */
private $selected;

public function __construct(string $name, array $options, string $selected = null)
public function __construct(string $name, array $options, ?string $selected = null)
{
$this->name = $name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SelectFieldViewModel extends ViewModel
* @todo $name and $options should not have default value
* need to revert back after solving the test problem
*/
public function __construct(string $name = '', array $options = [], string $selected = null)
public function __construct(string $name = '', array $options = [], ?string $selected = null)
{
$this->name = $name;

Expand Down
15 changes: 14 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,23 @@
use Spatie\BladeX\Facades\BladeX;
use Spatie\BladeX\Tests\SnapshotAssertions\MatchesSnapshots;

abstract class TestCase extends \anlutro\LaravelTesting\PkgAppTestCase
abstract class TestCase extends \Illuminate\Foundation\Testing\TestCase
{
use MatchesSnapshots;

// ponytail: inlined from anlutro/l4-testing PkgAppTestCase (only the <5.0 branch we use)
public function createApplication(): Application
{
$unitTesting = true;
$testEnvironment = 'testing';

$app = new Application();
$app->bindInstallPaths(require $this->getVendorPath() . '/laravel/laravel/bootstrap/paths.php');
require Application::getBootstrapFile();

return $app;
}

protected function setUp(): void
{
parent::setUp();
Expand Down
Loading