Skip to content

Commit

Permalink
Handle both class names and instances with getExtensionsOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
kylekatarnls committed Oct 6, 2017
1 parent 5cc7bf9 commit 237b25f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Phug/Phug.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ public static function getExtensionsOptions(array $extensions, array $options =
{
$methods = static::getExtensionsGetters();
foreach ($extensions as $extensionClassName) {
$extension = new $extensionClassName();
$extension = is_string($extensionClassName)
? new $extensionClassName()
: $extensionClassName;
foreach (['getOptions', 'getEvents'] as $method) {
$value = $extension->$method();
if (!empty($value)) {
Expand Down
9 changes: 9 additions & 0 deletions tests/Phug/PhugTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,15 @@ public function testExtensions()
self::assertFalse(Phug::hasExtension(VerbatimExtension::class));
}

/**
* @covers ::getExtensionsOptions
*/
public function testGetExtensionsOptions()
{
self::assertSame([], Phug::getExtensionsOptions([new VerbatimExtension()]));
self::assertSame([], Phug::getExtensionsOptions([VerbatimExtension::class]));
}

/**
* @covers ::addExtension
* @expectedException \Phug\PhugException
Expand Down

0 comments on commit 237b25f

Please sign in to comment.