Skip to content

Commit

Permalink
Merge pull request #7 from stayforlong/PLAT-1848_Update-api-to-Larave…
Browse files Browse the repository at this point in the history
…l-10-latest-stable-version

PLAT-1848 Update from upstream to support laravel 10 and 11
  • Loading branch information
averges authored Aug 20, 2024
2 parents 91c9a70 + be92059 commit 01aa000
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 78 deletions.
46 changes: 14 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,11 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [ '7.2', '7.3', '7.4', '8.0', '8.1' ]
laravel: ['6', '7', '8', '9' ]
php: [ '8.1', '8.2', '8.3']
laravel: [ '9', '10', '11' ]
exclude:
- php: '7.2'
laravel: '8'
- php: '7.2'
laravel: '9'
- php: '7.3'
laravel: '9'
- php: '7.4'
laravel: '9'
- php: '8.1'
laravel: '6'
- php: '8.1'
laravel: '7'
- laravel: 11
php: 8.1

name: PHP ${{ matrix.php }}; Laravel ${{ matrix.laravel }}

Expand All @@ -43,37 +33,29 @@ jobs:
- name: Setup Problem Matchers
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Select Laravel 6
- name: Select Laravel 9
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer require "laravel/framework:6.*" "phpunit/phpunit:^8.5.8|^9.3.7" --no-update --no-interaction
if: "matrix.laravel == '6'"
command: composer require "laravel/framework:9.*" "phpunit/phpunit:^9.3.7" --no-update --no-interaction
if: "matrix.laravel == '9'"

- name: Select Laravel 7
- name: Select Laravel 10
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer require "laravel/framework:7.*" "phpunit/phpunit:^8.5.8|^9.3.7" --no-update --no-interaction
if: "matrix.laravel == '7'"
command: composer require "laravel/framework:10.*" "phpunit/phpunit:^9.3.7" --no-update --no-interaction
if: "matrix.laravel == '10'"

- name: Select Laravel 8
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer require "laravel/framework:8.*" "phpunit/phpunit:^9.3.7" --no-update --no-interaction
if: "matrix.laravel == '8'"

- name: Select Laravel 9
- name: Select Laravel 11
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer require "laravel/framework:9.*" "phpunit/phpunit:^9.3.7" --no-update --no-interaction
if: "matrix.laravel == '9'"
command: composer require "laravel/framework:11.*" "phpunit/phpunit:^9.3.7" --no-update --no-interaction
if: "matrix.laravel == '11'"

- name: Install PHP Dependencies
uses: nick-invision/retry@v1
Expand All @@ -86,7 +68,7 @@ jobs:
run: ./vendor/bin/phpunit --coverage-clover clover.xml

- name: Execute code style checks
run: ./vendor/bin/phpcs --standard=PSR2 -p --ignore=./tests/storage/* --report=full --report-checkstyle=build/logs/checkstyle.xml src/ tests/
run: ./vendor/bin/phpcs --standard=PSR2 -p --ignore=./tests/storage/* src/ tests/

- name: Check code coverage
if: ${{ matrix.php == '8.1' }}
Expand Down
18 changes: 7 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,18 @@
}
],
"require": {
"php": "^7.4 || ^8.0",
"twig/twig": "~3.0",
"illuminate/support": "^6|^7|^8|^9",
"illuminate/view": "^6|^7|^8|^9"
"php": "^8.1",
"twig/twig": "~3.9",
"illuminate/support": "^9|^10|^11",
"illuminate/view": "^9|^10|^11"
},
"require-dev": {
"ext-json": "*",
"laravel/framework": "^6|^7|^8|^9",
"laravel/framework": "^9|^10|^11",
"mockery/mockery": "^1.3.1",
"phpunit/phpunit": "^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.7",
"phpunit/phpunit": "^8.5.8 || ^9.3.7",
"squizlabs/php_codesniffer": "^3.6"
},
"suggest": {
"twig/extensions": "~1.0",
"laravelcollective/html": "For bringing back html/form in Laravel 5.x"
},
"autoload": {
"psr-4": {
"TwigBridge\\": "src",
Expand All @@ -38,7 +34,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "0.13-dev"
"dev-master": "0.14-dev"
},
"laravel": {
"providers": [
Expand Down
25 changes: 0 additions & 25 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,5 @@
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./src</directory>
<exclude>
<directory suffix=".php">./src/config</directory>
</exclude>
</whitelist>
</filter>
<logging>
<log type="coverage-html"
target="build/coverage"
title="TwigBridge"
charset="UTF-8"
yui="true"
highlight="true" />

<log type="coverage-text"
target="php://stdout"
title="TwigBridge"
charset="UTF-8"
lowUpperBound="50"
highLowerBound="90" />

<log type="coverage-clover" target="build/logs/clover.xml"/>
<log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="false"/>
</logging>
</phpunit>
5 changes: 4 additions & 1 deletion src/Extension/Laravel/Dump.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
*/
class Dump extends AbstractExtension
{
private VarCloner $cloner;
/**
* @var \Symfony\Component\VarDumper\Cloner\VarCloner
*/
protected $cloner;

public function __construct()
{
Expand Down
5 changes: 5 additions & 0 deletions src/Extension/Loader/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ abstract class Loader extends AbstractExtension
{
protected Config $config;

/**
* @var \Illuminate\Config\Repository
*/
protected $config;

/**
* Create a new loader extension.
*
Expand Down
7 changes: 3 additions & 4 deletions src/Node/EventNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@
use Illuminate\Support\Str;
use Illuminate\View\View;
use Illuminate\View\ViewName;
use Twig\Attribute\YieldReady;
use Twig\Compiler;
use Twig\Node\Node;

#[YieldReady]
class EventNode extends Node
{

public function compile(Compiler $compiler): void
{
$compiler
->write(
sprintf(
'$context = ' .
EventNode::class . '::triggerLaravelEvents($this->getTemplateName(), $context);'
)
'$context = ' . EventNode::class . '::triggerLaravelEvents($this->getTemplateName(), $context);'
)
->raw("\n");
}
Expand Down
9 changes: 5 additions & 4 deletions src/Node/GetAttrNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
*/
namespace TwigBridge\Node;

use Twig\Attribute\YieldReady;
use Twig\Compiler;
use Twig\Environment;
use Twig\Error\RuntimeError;
use Twig\Extension\CoreExtension;
use Twig\Extension\SandboxExtension;
use Twig\Node\Expression\GetAttrExpression;
use Twig\Node\Node;
Expand All @@ -23,6 +25,7 @@
* - https://github.com/rcrowe/TwigBridge/issues/362
* - https://github.com/rcrowe/TwigBridge/issues/265
*/
#[YieldReady]
class GetAttrNode extends GetAttrExpression
{
/**
Expand Down Expand Up @@ -144,17 +147,15 @@ public static function attribute(
return $object->$item;
}

return \twig_get_attribute(
return CoreExtension::getAttribute(
$env,
$source,
$object,
$item,
$arguments,
$type,
$isDefinedTest,
$ignoreStrictCheck,
$sandboxed,
$lineno
$ignoreStrictCheck
);
}
}
2 changes: 1 addition & 1 deletion tests/Node/GetAttrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function getTests()
$tests[] = [
$node,
sprintf(
'%s%s, "bar", [0 => %s, 1 => "bar"], "method", false, false, false, 1)',
'%s%s, "bar", [%s, "bar"], "method", false, false, false, 1)',
$this->getAttributeGetter(),
$this->getVariableGetter('foo', 1),
$this->getVariableGetter('foo')
Expand Down

0 comments on commit 01aa000

Please sign in to comment.