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
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: ["8.0", "8.1", "8.2"]
php_version: ["8.1", "8.2", "8.3", "8.4"]
composer_flags: ["", "--prefer-lowest"]

steps:
Expand Down
26 changes: 13 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"name": "rareloop/primer-core",
"require": {
"php": ">=8.0",
"symfony/finder": "^4.2.5||^5.0||^6.0",
"twig/twig": "^2.6",
"illuminate/collections": "^8.53.1||^9.0.0",
"league/commonmark": "^1.5",
"spatie/yaml-front-matter": "^2.0"
"php": ">=8.1",
"symfony/finder": "^6.4.17",
"twig/twig": "^3.20",
"illuminate/collections": "^8.53.1||^9.52.16",
"league/commonmark": "^1.6.7",
"spatie/yaml-front-matter": "^2.1"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
"php-coveralls/php-coveralls": "^2.0",
"mockery/mockery": "^1.4.4",
"squizlabs/php_codesniffer": "^3.6.0",
"mikey179/vfsstream": "^1.6.9",
"antecedent/patchwork": "^2.1.8"
"phpunit/phpunit": "^9.6.22",
"php-coveralls/php-coveralls": "^2.7",
"mockery/mockery": "^1.6.12",
"squizlabs/php_codesniffer": "^3.12.2",
"mikey179/vfsstream": "^1.6.12",
"antecedent/patchwork": "^2.2.1"
},
"autoload": {
"psr-4": {
Expand All @@ -26,4 +26,4 @@
"Rareloop\\Primer\\Test\\": "tests"
}
}
}
}
6 changes: 3 additions & 3 deletions src/Twig/PrimerLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(TemplateProvider $templateProvider)
*
* @throws \Twig\Error\LoaderError When $name is not found
*/
public function getSourceContext($name)
public function getSourceContext(string $name): \Twig\Source
{
return new \Twig\Source($this->templateProvider->getPatternTemplate($name), $name);
}
Expand All @@ -37,7 +37,7 @@ public function getSourceContext($name)
*
* @throws \Twig\Error\LoaderError When $name is not found
*/
public function getCacheKey($name)
public function getCacheKey(string $name): string
{
return md5($name);
}
Expand All @@ -52,7 +52,7 @@ public function getCacheKey($name)
*
* @throws \Twig\Error\LoaderError When $name is not found
*/
public function isFresh($name, $time)
public function isFresh(string $name, int $time): bool
{
return $time < $this->templateProvider->getPatternTemplateLastModified($name);
}
Expand Down
12 changes: 8 additions & 4 deletions tests/DocumentParsers/TwigDocumentParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
namespace Rareloop\Primer\Test\DataParsers;

use Mockery;
use PHPUnit\Framework\TestCase;
use Twig\Environment;
use Rareloop\Primer\Document;
use PHPUnit\Framework\TestCase;
use Rareloop\Primer\DocumentParsers\TwigDocumentParser;
use Rareloop\Primer\DocumentParsers\YAMLDocumentParser;
use Twig\Environment;
use Twig\Template;
use Twig\TemplateWrapper;

class TwigDocumentParserTest extends TestCase
{
Expand All @@ -17,11 +19,13 @@ public function can_parse_twig_from_content()
$doc = new Document('id', 'Twig Input');
$doc->setMeta(['foo' => 'bar']);

$twig = Mockery::mock(Environment::class);
$template = Mockery::mock(Template::class);
$templateWrapper = new TemplateWrapper($twig, $template);

$template->shouldReceive('render')->with($doc->meta())->once()->andReturn('Twig Output');

$twig = Mockery::mock(Environment::class);
$twig->shouldReceive('createTemplate')->with('Twig Input')->once()->andReturn($template);
$twig->shouldReceive('createTemplate')->with('Twig Input')->once()->andReturn($templateWrapper);

$parser = new TwigDocumentParser($twig);

Expand Down
Loading