Skip to content

Commit

Permalink
Merge pull request #1 from leafsphp/update-blade-version-to-latest
Browse files Browse the repository at this point in the history
  • Loading branch information
mychidarko authored Nov 27, 2023
2 parents 181e44b + b1152ec commit 5c9e60c
Show file tree
Hide file tree
Showing 10 changed files with 708 additions and 148 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Run Tests

on: ['push', 'pull_request']

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.3, 8.2, 8.1, 8.0, 7.4]

name: PHP ${{ matrix.php }} – ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: xdebug

- name: Install dependencies
run: composer update --prefer-stable --no-interaction

- name: All tests
run: php vendor/bin/pest --colors=always --coverage
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/vendor
composer.lock
.DS_Store
.idea
.phpunit.result.cache
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

14 changes: 9 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,22 @@
}
],
"require": {
"php": ">=7.0",
"illuminate/view": "^5.5|^6.0|^7.0|^8.0"
"php": ">=7.3|^8.0",
"illuminate/view": "^8.0|^9.0|^10.0"
},
"require-dev": {
"phpunit/phpunit": "^6.0|^7.0",
"satooshi/php-coveralls": "^1.0"
"pestphp/pest": "^1.0|^2.25"
},
"autoload": {
"psr-4": {
"Leaf\\": "src/"
}
},
"minimum-stability": "dev",
"prefer-stable": true
"prefer-stable": true,
"config": {
"allow-plugins": {
"pestphp/pest-plugin": true
}
}
}
25 changes: 11 additions & 14 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
<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"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
>
<testsuites>
<testsuite name="Default">
<directory>./tests/</directory>
<testsuite name="Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist addUncoveredFilesFromWhitelist="false">
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
<source>
<include>
<directory suffix=".php">./app</directory>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
16 changes: 7 additions & 9 deletions src/Blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace Leaf;

use Illuminate\Container\Container;
use Illuminate\Contracts\Container\Container as ContainerInterface;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory as FactoryContract;
use Illuminate\Contracts\View\View;
use Illuminate\Events\Dispatcher;
Expand All @@ -17,7 +15,7 @@
class Blade implements FactoryContract
{
/**
* @var Application
* @var BladeContainer
*/
protected $container;

Expand All @@ -33,7 +31,7 @@ class Blade implements FactoryContract

public function __construct($viewPaths = null, string $cachePath = null, ContainerInterface $container = null)
{
$this->container = $container ?: new Container;
$this->container = $container ?: new \Leaf\BladeContainer();

if ($viewPaths != null && $cachePath != null) {
$this->configure($viewPaths, $cachePath);
Expand All @@ -54,8 +52,8 @@ public function configure($viewPaths, $cachePath)

/**
* Render your blade template,
*
* A shorter version of the original `make` command.
*
* A shorter version of the original `make` command.
* You can optionally pass data into the view as a second parameter
*/
public function render(string $view, array $data = [], array $mergeData = []): string
Expand All @@ -65,7 +63,7 @@ public function render(string $view, array $data = [], array $mergeData = []): s

/**
* Render your blade template,
*
*
* You can optionally pass data into the view as a second parameter.
* Don't forget to chain the `render` method
*/
Expand Down Expand Up @@ -147,10 +145,10 @@ protected function setupContainer(array $viewPaths, string $cachePath)
}, true);

$this->container->bindIf('config', function () use ($viewPaths, $cachePath) {
return [
return new Config([
'view.paths' => $viewPaths,
'view.compiled' => $cachePath,
];
]);
}, true);

Facade::setFacadeApplication($this->container);
Expand Down
Loading

0 comments on commit 5c9e60c

Please sign in to comment.