Skip to content

Commit

Permalink
Changed Twig Class names #8
Browse files Browse the repository at this point in the history
  • Loading branch information
odan committed Apr 12, 2019
1 parent 5ef9ea9 commit 0d92d26
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/Twig/TwigAssetsCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private function removeDirectory(string $path): bool

$files = new FilesystemIterator($path);

/* @var SplFileInfo $file */
/** @var SplFileInfo $file */
foreach ($files as $file) {
$fileName = $file->getPathname();
unlink($fileName);
Expand Down
14 changes: 7 additions & 7 deletions src/Twig/TwigAssetsEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ public function __construct(Environment $env, array $options)
/**
* Render and compress JavaScript assets.
*
* @param array $assets
* @param array $options
* @param array $assets assets
* @param array $options options
*
* @return string content
*/
Expand Down Expand Up @@ -144,7 +144,7 @@ public function assets(array $assets, array $options = []): string
/**
* Resolve real asset filenames.
*
* @param array $assets
* @param array $assets assets
*
* @return array assets
*/
Expand All @@ -161,7 +161,7 @@ private function prepareAssets(array $assets): array
/**
* Returns full path and filename.
*
* @param string $file
* @param string $file file
*
* @throws LoaderError
*
Expand All @@ -179,10 +179,10 @@ private function getRealFilename(string $file): string
/**
* Get cache key.
*
* @param array $assets
* @param array $settings
* @param array $assets assets
* @param array $settings settings
*
* @return string
* @return string key
*/
private function getCacheKey(array $assets, array $settings): string
{
Expand Down
16 changes: 8 additions & 8 deletions src/Twig/TwigAssetsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
namespace Odan\Twig;

use Exception;
use Twig_Environment;
use Twig_Extension;
use Twig_SimpleFunction;
use Twig\Environment;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

/**
* TwigAssetsExtension.
* Twig Assets Extension.
*/
class TwigAssetsExtension extends Twig_Extension
class TwigAssetsExtension extends AbstractExtension
{
/**
* @var TwigAssetsEngine
Expand All @@ -20,12 +20,12 @@ class TwigAssetsExtension extends Twig_Extension
/**
* TwigAssetsExtension constructor.
*
* @param Twig_Environment $env
* @param Environment $env
* @param array $options
*
* @throws Exception
*/
public function __construct(Twig_Environment $env, array $options)
public function __construct(Environment $env, array $options)
{
$this->engine = new TwigAssetsEngine($env, $options);
}
Expand All @@ -37,7 +37,7 @@ public function __construct(Twig_Environment $env, array $options)
*/
public function getFunctions()
{
$function = new Twig_SimpleFunction('assets', [$this, 'assets'], [
$function = new TwigFunction('assets', [$this, 'assets'], [
'needs_environment' => false,
'is_safe' => ['html'],
]);
Expand Down
12 changes: 6 additions & 6 deletions tests/AbstractTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamDirectory;
use PHPUnit\Framework\TestCase;
use Twig_Environment;
use Twig_Loader_Filesystem;
use Twig\Environment;
use Twig\Loader\FilesystemLoader;

/**
* BaseTest.
*/
abstract class AbstractTest extends TestCase
{
/**
* @var Twig_Loader_Filesystem
* @var FilesystemLoader
*/
protected $loader;

/**
* @var Twig_Environment
* @var Environment
*/
protected $env;

Expand Down Expand Up @@ -79,7 +79,7 @@ public function setUp()
vfsStream::newDirectory('templates')->at($this->root);

$templatePath = vfsStream::url('root/templates');
$this->loader = new Twig_Loader_Filesystem([$templatePath]);
$this->loader = new FilesystemLoader([$templatePath]);

// Add alias path: @public/ -> root/public
$this->loader->addPath(vfsStream::url('root/public'), 'public');
Expand All @@ -90,7 +90,7 @@ public function setUp()
//'cache_path' => $config['temp'] . '/twig-cache'
];

$this->env = new \Twig_Environment($this->loader, $options);
$this->env = new Environment($this->loader, $options);
$this->extension = $this->newExtensionInstance();
}

Expand Down

0 comments on commit 0d92d26

Please sign in to comment.