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

Improve PHP 8 compatibility and testing #421

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Prev Previous commit
Indentation fixes
swissspidy committed Dec 13, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit ef7ec8eb73c2be0c9f4731bb995e18b784e2870b
2 changes: 1 addition & 1 deletion test/Mustache/Test/Cache/AbstractCacheTest.php
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ public function testGetSetLogger()

public function testSetLoggerThrowsExceptions()
{
$this->expectException(Mustache_Exception_InvalidArgumentException::class);
$this->expectException(Mustache_Exception_InvalidArgumentException::class);
$cache = new CacheStub();
$logger = new StdClass();
$cache->setLogger($logger);
2 changes: 1 addition & 1 deletion test/Mustache/Test/CompilerTest.php
Original file line number Diff line number Diff line change
@@ -134,7 +134,7 @@ public function getCompileValues()

public function testCompilerThrowsSyntaxException()
{
$this->expectException(Mustache_Exception_SyntaxException::class);
$this->expectException(Mustache_Exception_SyntaxException::class);
$compiler = new Mustache_Compiler();
$compiler->compile('', array(array(Mustache_Tokenizer::TYPE => 'invalid')), 'SomeClass');
}
18 changes: 9 additions & 9 deletions test/Mustache/Test/ContextTest.php
Original file line number Diff line number Diff line change
@@ -173,7 +173,7 @@ public function testAnchoredDotNotation()

public function testAnchoredDotNotationThrowsExceptions()
{
$this->expectException(Mustache_Exception_InvalidArgumentException::class);
$this->expectException(Mustache_Exception_InvalidArgumentException::class);
$context = new Mustache_Context();
$context->push(array('a' => 1));
$context->findAnchoredDot('a');
@@ -262,7 +262,7 @@ public function __construct($array)
}
}

#[\ReturnTypeWillChange]
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
if (is_null($offset)) {
@@ -272,19 +272,19 @@ public function offsetSet($offset, $value)
}
}

#[\ReturnTypeWillChange]
#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
return isset($this->container[$offset]);
}

#[\ReturnTypeWillChange]
#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
unset($this->container[$offset]);
}

#[\ReturnTypeWillChange]
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return isset($this->container[$offset]) ? $this->container[$offset] : null;
@@ -302,13 +302,13 @@ public function foo()
return 'win';
}

#[\ReturnTypeWillChange]
#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
return true;
}

#[\ReturnTypeWillChange]
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
switch ($offset) {
@@ -325,13 +325,13 @@ public function offsetGet($offset)
}
}

#[\ReturnTypeWillChange]
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
// nada
}

#[\ReturnTypeWillChange]
#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
// nada
12 changes: 6 additions & 6 deletions test/Mustache/Test/EngineTest.php
Original file line number Diff line number Diff line change
@@ -160,7 +160,7 @@ public function testWithoutLambdaCache()

public function testEmptyTemplatePrefixThrowsException()
{
$this->expectException(Mustache_Exception_InvalidArgumentException::class);
$this->expectException(Mustache_Exception_InvalidArgumentException::class);
new Mustache_Engine(array(
'template_class_prefix' => '',
));
@@ -171,7 +171,7 @@ public function testEmptyTemplatePrefixThrowsException()
*/
public function testNonCallableEscapeThrowsException($escape)
{
$this->expectException(Mustache_Exception_InvalidArgumentException::class);
$this->expectException(Mustache_Exception_InvalidArgumentException::class);
new Mustache_Engine(array('escape' => $escape));
}

@@ -185,7 +185,7 @@ public function getBadEscapers()

public function testImmutablePartialsLoadersThrowException()
{
$this->expectException(Mustache_Exception_RuntimeException::class);
$this->expectException(Mustache_Exception_RuntimeException::class);
$mustache = new Mustache_Engine(array(
'partials_loader' => new Mustache_Loader_StringLoader(),
));
@@ -248,14 +248,14 @@ public static function wrapWithUnderscores($text)

public function testSetHelpersThrowsExceptions()
{
$this->expectException(Mustache_Exception_InvalidArgumentException::class);
$this->expectException(Mustache_Exception_InvalidArgumentException::class);
$mustache = new Mustache_Engine();
$mustache->setHelpers('monkeymonkeymonkey');
}

public function testSetLoggerThrowsExceptions()
{
$this->expectException(Mustache_Exception_InvalidArgumentException::class);
$this->expectException(Mustache_Exception_InvalidArgumentException::class);
$mustache = new Mustache_Engine();
$mustache->setLogger(new StdClass());
}
@@ -325,7 +325,7 @@ public function testVerboseLoggingIsVerbose()

public function testUnknownPragmaThrowsException()
{
$this->expectException(Mustache_Exception_InvalidArgumentException::class);
$this->expectException(Mustache_Exception_InvalidArgumentException::class);
new Mustache_Engine(array(
'pragmas' => array('UNKNOWN'),
));
2 changes: 1 addition & 1 deletion test/Mustache/Test/FiveThree/Functional/FiltersTest.php
Original file line number Diff line number Diff line change
@@ -132,7 +132,7 @@ public function interpolateFirstData()
*/
public function testThrowsExceptionForBrokenPipes($tpl, $data)
{
$this->expectException(Mustache_Exception_UnknownFilterException::class);
$this->expectException(Mustache_Exception_UnknownFilterException::class);
$this->mustache->render($tpl, $data);
}

4 changes: 2 additions & 2 deletions test/Mustache/Test/Functional/DynamicPartialsTest.php
Original file line number Diff line number Diff line change
@@ -61,8 +61,8 @@ public function getDynamicNameParseErrors()
*/
public function testDynamicNameParseErrors($template)
{
$this->expectException(Mustache_Exception_SyntaxException::class);
$this->expectExceptionMessage('Nesting error:');
$this->expectException(Mustache_Exception_SyntaxException::class);
$this->expectExceptionMessage('Nesting error:');
$this->mustache->render($template);
}

14 changes: 7 additions & 7 deletions test/Mustache/Test/Functional/HigherOrderSectionsTest.php
Original file line number Diff line number Diff line change
@@ -76,11 +76,11 @@ public function testMonsters()
public function testPassthroughOptimization()
{
$mustache = $this->getMockBuilder('Mustache_Engine');
if (method_exists($mustache, 'onlyMethods')) {
$mustache->onlyMethods(array('loadLambda'));
} else {
$mustache->setMethods(array('loadLambda'));
}
if (method_exists($mustache, 'onlyMethods')) {
$mustache->onlyMethods(array('loadLambda'));
} else {
$mustache->setMethods(array('loadLambda'));
}
$mustache = $mustache->getMock();

$mustache->expects($this->never())
@@ -98,9 +98,9 @@ public function testWithoutPassthroughOptimization()
{
$mustache = $this->getMockBuilder('Mustache_Engine');
if (method_exists($mustache, 'onlyMethods')) {
$mustache->onlyMethods(array('loadLambda'));
$mustache->onlyMethods(array('loadLambda'));
} else {
$mustache->setMethods(array('loadLambda'));
$mustache->setMethods(array('loadLambda'));
}
$mustache = $mustache->getMock();

4 changes: 2 additions & 2 deletions test/Mustache/Test/Functional/InheritanceTest.php
Original file line number Diff line number Diff line change
@@ -524,8 +524,8 @@ public function testInheritanceWithLazyEvaluationAndSections()
*/
public function testIllegalInheritanceExamples($partials, $data, $template)
{
$this->expectException(Mustache_Exception_SyntaxException::class);
$this->expectExceptionMessage('Illegal content in < parent tag');
$this->expectException(Mustache_Exception_SyntaxException::class);
$this->expectExceptionMessage('Illegal content in < parent tag');
$this->mustache->setPartials($partials);
$tpl = $this->mustache->loadTemplate($template);
$tpl->render($data);
2 changes: 1 addition & 1 deletion test/Mustache/Test/HelperCollectionTest.php
Original file line number Diff line number Diff line change
@@ -97,7 +97,7 @@ public function testMagicMethods()
public function testHelperCollectionIsntAfraidToThrowExceptions($helpers = array(), $actions = array(), $exception = null)
{
if ($exception) {
$this->expectException($exception);
$this->expectException($exception);
}

$helpers = new Mustache_HelperCollection($helpers);
2 changes: 1 addition & 1 deletion test/Mustache/Test/Loader/ArrayLoaderTest.php
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ public function testSetAndLoadTemplates()

public function testMissingTemplatesThrowExceptions()
{
$this->expectException(Mustache_Exception_UnknownTemplateException::class);
$this->expectException(Mustache_Exception_UnknownTemplateException::class);
$loader = new Mustache_Loader_ArrayLoader();
$loader->load('not_a_real_template');
}
2 changes: 1 addition & 1 deletion test/Mustache/Test/Loader/CascadingLoaderTest.php
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ public function testLoadTemplates()

public function testMissingTemplatesThrowExceptions()
{
$this->expectException(Mustache_Exception_UnknownTemplateException::class);
$this->expectException(Mustache_Exception_UnknownTemplateException::class);
$loader = new Mustache_Loader_CascadingLoader(array(
new Mustache_Loader_ArrayLoader(array('foo' => '{{ foo }}')),
new Mustache_Loader_ArrayLoader(array('bar' => '{{#bar}}BAR{{/bar}}')),
4 changes: 2 additions & 2 deletions test/Mustache/Test/Loader/FilesystemLoaderTest.php
Original file line number Diff line number Diff line change
@@ -61,13 +61,13 @@ public function testEmptyExtensionString()

public function testMissingBaseDirThrowsException()
{
$this->expectException(Mustache_Exception_RuntimeException::class);
$this->expectException(Mustache_Exception_RuntimeException::class);
new Mustache_Loader_FilesystemLoader(dirname(__FILE__) . '/not_a_directory');
}

public function testMissingTemplateThrowsException()
{
$this->expectException(Mustache_Exception_UnknownTemplateException::class);
$this->expectException(Mustache_Exception_UnknownTemplateException::class);
$baseDir = realpath(dirname(__FILE__) . '/../../../fixtures/templates');
$loader = new Mustache_Loader_FilesystemLoader($baseDir);

6 changes: 3 additions & 3 deletions test/Mustache/Test/Loader/InlineLoaderTest.php
Original file line number Diff line number Diff line change
@@ -23,20 +23,20 @@ public function testLoadTemplates()

public function testMissingTemplatesThrowExceptions()
{
$this->expectException(Mustache_Exception_UnknownTemplateException::class);
$this->expectException(Mustache_Exception_UnknownTemplateException::class);
$loader = new Mustache_Loader_InlineLoader(__FILE__, __COMPILER_HALT_OFFSET__);
$loader->load('not_a_real_template');
}

public function testInvalidOffsetThrowsException()
{
$this->expectException(Mustache_Exception_InvalidArgumentException::class);
$this->expectException(Mustache_Exception_InvalidArgumentException::class);
new Mustache_Loader_InlineLoader(__FILE__, 'notanumber');
}

public function testInvalidFileThrowsException()
{
$this->expectException(Mustache_Exception_InvalidArgumentException::class);
$this->expectException(Mustache_Exception_InvalidArgumentException::class);
new Mustache_Loader_InlineLoader('notarealfile', __COMPILER_HALT_OFFSET__);
}
}
4 changes: 2 additions & 2 deletions test/Mustache/Test/Loader/ProductionFilesystemLoaderTest.php
Original file line number Diff line number Diff line change
@@ -63,13 +63,13 @@ public function testEmptyExtensionString()

public function testMissingBaseDirThrowsException()
{
$this->expectException(Mustache_Exception_RuntimeException::class);
$this->expectException(Mustache_Exception_RuntimeException::class);
new Mustache_Loader_ProductionFilesystemLoader(dirname(__FILE__) . '/not_a_directory');
}

public function testMissingTemplateThrowsException()
{
$this->expectException(Mustache_Exception_UnknownTemplateException::class);
$this->expectException(Mustache_Exception_UnknownTemplateException::class);
$baseDir = realpath(dirname(__FILE__) . '/../../../fixtures/templates');
$loader = new Mustache_Loader_ProductionFilesystemLoader($baseDir);

6 changes: 3 additions & 3 deletions test/Mustache/Test/Logger/StreamLoggerTest.php
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ public function acceptsStreamData()

public function testPrematurelyClosedStreamThrowsException()
{
$this->expectException(Mustache_Exception_LogicException::class);
$this->expectException(Mustache_Exception_LogicException::class);
$stream = tmpfile();
$logger = new Mustache_Logger_StreamLogger($stream);
fclose($stream);
@@ -189,14 +189,14 @@ public function testChangeLoggingLevels()

public function testThrowsInvalidArgumentExceptionWhenSettingUnknownLevels()
{
$this->expectException(Mustache_Exception_InvalidArgumentException::class);
$this->expectException(Mustache_Exception_InvalidArgumentException::class);
$logger = new Mustache_Logger_StreamLogger(tmpfile());
$logger->setLevel('bacon');
}

public function testThrowsInvalidArgumentExceptionWhenLoggingUnknownLevels()
{
$this->expectException(Mustache_Exception_InvalidArgumentException::class);
$this->expectException(Mustache_Exception_InvalidArgumentException::class);
$logger = new Mustache_Logger_StreamLogger(tmpfile());
$logger->log('bacon', 'CODE BACON ERROR!');
}
2 changes: 1 addition & 1 deletion test/Mustache/Test/ParserTest.php
Original file line number Diff line number Diff line change
@@ -320,7 +320,7 @@ public function getInheritanceTokenSets()
*/
public function testParserThrowsExceptions($tokens)
{
$this->expectException(Mustache_Exception_SyntaxException::class);
$this->expectException(Mustache_Exception_SyntaxException::class);
$parser = new Mustache_Parser();
$parser->parse($tokens);
}
2 changes: 1 addition & 1 deletion test/Mustache/Test/Source/FilesystemSourceTest.php
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ class Mustache_Test_Source_FilesystemSourceTest extends Yoast\PHPUnitPolyfills\T
{
public function testMissingTemplateThrowsException()
{
$this->expectException(Mustache_Exception_RuntimeException::class);
$this->expectException(Mustache_Exception_RuntimeException::class);
$source = new Mustache_Source_FilesystemSource(dirname(__FILE__) . '/not_a_file.mustache', array('mtime'));
$source->getKey();
}
6 changes: 3 additions & 3 deletions test/Mustache/Test/TokenizerTest.php
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ public function testScan($text, $delimiters, $expected)

public function testUnevenBracesThrowExceptions()
{
$this->expectException(Mustache_Exception_SyntaxException::class);
$this->expectException(Mustache_Exception_SyntaxException::class);
$tokenizer = new Mustache_Tokenizer();

$text = '{{{ name }}';
@@ -34,7 +34,7 @@ public function testUnevenBracesThrowExceptions()

public function testUnevenBracesWithCustomDelimiterThrowExceptions()
{
$this->expectException(Mustache_Exception_SyntaxException::class);
$this->expectException(Mustache_Exception_SyntaxException::class);
$tokenizer = new Mustache_Tokenizer();

$text = '<%{ name %>';
@@ -353,7 +353,7 @@ public function getTokens()
*/
public function testUnclosedTagsThrowExceptions($text)
{
$this->expectException(Mustache_Exception_SyntaxException::class);
$this->expectException(Mustache_Exception_SyntaxException::class);
$tokenizer = new Mustache_Tokenizer();
$tokenizer->scan($text, null);
}