Skip to content

Commit

Permalink
fixed various small bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Apr 16, 2019
1 parent f8b076b commit e420253
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ public function loadClass($cls, $name, $index = null)
$this->cache->load($key);
}

$source = null;
if (!class_exists($cls, false)) {
$loader = $this->getLoader();
if (!$loader instanceof SourceContextLoaderInterface) {
Expand Down
2 changes: 1 addition & 1 deletion src/Extension/CoreExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -1658,7 +1658,7 @@ function twig_constant_is_defined($constant, $object = null)
function twig_array_batch($items, $size, $fill = null, $preserveKeys = true)
{
if (!twig_test_iterable($items)) {
throw new RuntimeError(sprintf('The "batch" filter expects an array or "Traversable", got "%s".', \is_object($from) ? \get_class($from) : \gettype($from)));
throw new RuntimeError(sprintf('The "batch" filter expects an array or "Traversable", got "%s".', \is_object($items) ? \get_class($items) : \gettype($items)));
}

$size = ceil($size);
Expand Down
4 changes: 2 additions & 2 deletions src/Extension/StringLoaderExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class_alias('Twig\Extension\StringLoaderExtension', 'Twig_Extension_StringLoader

namespace {
use Twig\Environment;
use Twig\Template;
use Twig\TemplateWrapper;

/**
* Loads a template from a string.
Expand All @@ -45,7 +45,7 @@ class_alias('Twig\Extension\StringLoaderExtension', 'Twig_Extension_StringLoader
* @param string $template A template as a string or object implementing __toString()
* @param string $name An optional name of the template to be used in error messages
*
* @return Template
* @return TemplateWrapper
*/
function twig_template_from_string(Environment $env, $template, $name = null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Loader/FilesystemLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function exists($name)
}

try {
return false !== $this->findTemplate($name, false);
return false !== $this->findTemplate($name);
} catch (LoaderError $e) {
@trigger_error(sprintf('In %s::findTemplate(), you must accept a second argument that when set to "false" returns "false" instead of throwing an exception. Not supporting this argument is deprecated since version 1.27.', \get_class($this)), E_USER_DEPRECATED);

Expand Down
2 changes: 1 addition & 1 deletion src/Test/IntegrationTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ protected function doIntegrationTest($file, $message, $condition, $templates, $e
$message = $e->getMessage();
$this->assertSame(trim($exception), trim(sprintf('%s: %s', \get_class($e), $message)));
$last = substr($message, \strlen($message) - 1);
$this->assertTrue('.' === $last || '?' === $last, $message, 'Exception message must end with a dot or a question mark.');
$this->assertTrue('.' === $last || '?' === $last, 'Exception message must end with a dot or a question mark.');

return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Test/NodeTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected function getVariableGetter($name, $line = false)
$line = $line > 0 ? "// line {$line}\n" : '';

if (\PHP_VERSION_ID >= 70000) {
return sprintf('%s($context["%s"] ?? null)', $line, $name, $name);
return sprintf('%s($context["%s"] ?? null)', $line, $name);
}

if (\PHP_VERSION_ID >= 50400) {
Expand Down

0 comments on commit e420253

Please sign in to comment.