for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* New use group declaration sniff tests
*
* @package PHPCompatibility
*/
* New use declaration sniff tests
* @uses BaseSniffTest
* @author Ryan Neufeld <[email protected]>
class NewUseDeclarationsSniffTest extends BaseSniffTest
{
* Test use group declaration
* @return void
public function testUseDeclaration()
if (version_compare(PHP_CodeSniffer::VERSION, '2.3.4') >= 0) {
$file = $this->sniffFile('sniff-examples/new_use_declarations.php', '5.5');
$this->assertError($file, 4, "`use const` declarations are not allowed in PHP 5.5 or earlier");
$this->assertError($file, 5, "`use const` declarations are not allowed in PHP 5.5 or earlier");
$this->assertError($file, 7, "`use function` declarations are not allowed in PHP 5.5 or earlier");
$this->assertError($file, 8, "`use function` declarations are not allowed in PHP 5.5 or earlier");
$file = $this->sniffFile('sniff-examples/new_group_use_declarations.php', '5.6');
$this->assertNoViolation($file, 4);
$this->assertNoViolation($file, 5);
$this->assertNoViolation($file, 7);
$this->assertNoViolation($file, 8);
}