Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.5] Move engine to Contracts. #20464

Merged
merged 2 commits into from
Aug 7, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Move engine to Contracts.
  • Loading branch information
lucasmichot committed Aug 7, 2017
commit 42385c358bdcf54cb489fd91ed578e7836639fa7
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Illuminate\View\Engines;
namespace Illuminate\Contracts\View;

interface EngineInterface
interface Engine
{
/**
* Get the evaluated contents of the view.
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/View/Engines/EngineResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function register($engine, Closure $resolver)
* Resolver an engine instance by name.
*
* @param string $engine
* @return \Illuminate\View\Engines\EngineInterface
* @return \Illuminate\Contracts\View\Engine
* @throws \InvalidArgumentException
*/
public function resolve($engine)
Expand Down
4 changes: 3 additions & 1 deletion src/Illuminate/View/Engines/FileEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace Illuminate\View\Engines;

class FileEngine implements EngineInterface
use Illuminate\Contracts\View\Engine;

class FileEngine implements Engine
{
/**
* Get the evaluated contents of the view.
Expand Down
3 changes: 2 additions & 1 deletion src/Illuminate/View/Engines/PhpEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

use Exception;
use Throwable;
use Illuminate\Contracts\View\Engine;
use Symfony\Component\Debug\Exception\FatalThrowableError;

class PhpEngine implements EngineInterface
class PhpEngine implements Engine
{
/**
* Get the evaluated contents of the view.
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/View/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public function exists($view)
* Get the appropriate view engine for the given path.
*
* @param string $path
* @return \Illuminate\View\Engines\EngineInterface
* @return \Illuminate\Contracts\View\Engine
*
* @throws \InvalidArgumentException
*/
Expand Down
10 changes: 5 additions & 5 deletions src/Illuminate/View/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Illuminate\Support\MessageBag;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\View\Engines\EngineInterface;
use Illuminate\Contracts\View\Engine;
use Illuminate\Contracts\Support\MessageProvider;
use Illuminate\Contracts\View\View as ViewContract;

Expand All @@ -26,7 +26,7 @@ class View implements ArrayAccess, ViewContract
/**
* The engine implementation.
*
* @var \Illuminate\View\Engines\EngineInterface
* @var \Illuminate\Contracts\View\Engine
*/
protected $engine;

Expand Down Expand Up @@ -55,13 +55,13 @@ class View implements ArrayAccess, ViewContract
* Create a new view instance.
*
* @param \Illuminate\View\Factory $factory
* @param \Illuminate\View\Engines\EngineInterface $engine
* @param \Illuminate\Contracts\View\Engine $engine
* @param string $view
* @param string $path
* @param mixed $data
* @return void
*/
public function __construct(Factory $factory, EngineInterface $engine, $view, $path, $data = [])
public function __construct(Factory $factory, Engine $engine, $view, $path, $data = [])
{
$this->view = $view;
$this->path = $path;
Expand Down Expand Up @@ -287,7 +287,7 @@ public function getFactory()
/**
* Get the view's rendering engine.
*
* @return \Illuminate\View\Engines\EngineInterface
* @return \Illuminate\Contracts\View\Engine
*/
public function getEngine()
{
Expand Down
8 changes: 4 additions & 4 deletions tests/View/ViewFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function testMakeCreatesNewViewInstanceWithProperPathAndEngine()

$factory = $this->getFactory();
$factory->getFinder()->shouldReceive('find')->once()->with('view')->andReturn('path.php');
$factory->getEngineResolver()->shouldReceive('resolve')->once()->with('php')->andReturn($engine = m::mock('Illuminate\View\Engines\EngineInterface'));
$factory->getEngineResolver()->shouldReceive('resolve')->once()->with('php')->andReturn($engine = m::mock(\Illuminate\Contracts\View\Engine::class));
$factory->getFinder()->shouldReceive('addExtension')->once()->with('php');
$factory->setDispatcher(new \Illuminate\Events\Dispatcher);
$factory->creator('view', function ($view) {
Expand Down Expand Up @@ -83,7 +83,7 @@ public function testEnvironmentAddsExtensionWithCustomResolver()
$factory->getFinder()->shouldReceive('addExtension')->once()->with('foo');
$factory->getEngineResolver()->shouldReceive('register')->once()->with('bar', $resolver);
$factory->getFinder()->shouldReceive('find')->once()->with('view')->andReturn('path.foo');
$factory->getEngineResolver()->shouldReceive('resolve')->once()->with('bar')->andReturn($engine = m::mock(\Illuminate\View\Engines\EngineInterface::class));
$factory->getEngineResolver()->shouldReceive('resolve')->once()->with('bar')->andReturn($engine = m::mock(\Illuminate\Contracts\View\Engine::class));
$factory->getDispatcher()->shouldReceive('dispatch');

$factory->addExtension('foo', 'bar', $resolver);
Expand Down Expand Up @@ -409,7 +409,7 @@ public function testMakeWithSlashAndDot()
{
$factory = $this->getFactory();
$factory->getFinder()->shouldReceive('find')->twice()->with('foo.bar')->andReturn('path.php');
$factory->getEngineResolver()->shouldReceive('resolve')->twice()->with('php')->andReturn(m::mock(\Illuminate\View\Engines\EngineInterface::class));
$factory->getEngineResolver()->shouldReceive('resolve')->twice()->with('php')->andReturn(m::mock(\Illuminate\Contracts\View\Engine::class));
$factory->getDispatcher()->shouldReceive('dispatch');
$factory->make('foo/bar');
$factory->make('foo.bar');
Expand All @@ -419,7 +419,7 @@ public function testNamespacedViewNamesAreNormalizedProperly()
{
$factory = $this->getFactory();
$factory->getFinder()->shouldReceive('find')->twice()->with('vendor/package::foo.bar')->andReturn('path.php');
$factory->getEngineResolver()->shouldReceive('resolve')->twice()->with('php')->andReturn(m::mock(\Illuminate\View\Engines\EngineInterface::class));
$factory->getEngineResolver()->shouldReceive('resolve')->twice()->with('php')->andReturn(m::mock(\Illuminate\Contracts\View\Engine::class));
$factory->getDispatcher()->shouldReceive('dispatch');
$factory->make('vendor/package::foo/bar');
$factory->make('vendor/package::foo.bar');
Expand Down
4 changes: 2 additions & 2 deletions tests/View/ViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function testRenderSectionsReturnsEnvironmentSections()
{
$view = m::mock('Illuminate\View\View[render]', [
m::mock('Illuminate\View\Factory'),
m::mock('Illuminate\View\Engines\EngineInterface'),
m::mock(\Illuminate\Contracts\View\Engine::class),
'view',
'path',
[],
Expand Down Expand Up @@ -224,7 +224,7 @@ protected function getView($data = [])
{
return new View(
m::mock('Illuminate\View\Factory'),
m::mock('Illuminate\View\Engines\EngineInterface'),
m::mock(\Illuminate\Contracts\View\Engine::class),
'view',
'path',
$data
Expand Down