Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 1 addition & 2 deletions Security/Sniffs/BadFunctions/NoEvalsSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ public function register() {
* @return void
*/
public function process(File $phpcsFile, $stackPtr) {
$tokens = $phpcsFile->getTokens();
$error = 'Please do not use eval() functions';
$error = 'Please do not use eval()';
$phpcsFile->addError($error, $stackPtr, 'NoEvals');
}

Expand Down
5 changes: 5 additions & 0 deletions Security/Tests/BadFunctions/NoEvalsUnitTest.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

eval('$var = file_get_contents(\'filename.php\');');
eval($string);
eval("\$var = file_get_contents($filename);');
44 changes: 44 additions & 0 deletions Security/Tests/BadFunctions/NoEvalsUnitTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace PHPCS_SecurityAudit\Security\Tests\BadFunctions;

use PHPCS_SecurityAudit\Security\Tests\AbstractSecurityTestCase;

/**
* Unit test class for the NoEvals sniff.
*
* @covers \PHPCS_SecurityAudit\Security\Sniffs\BadFunctions\NoEvalsSniff
*/
class NoEvalsUnitTest extends AbstractSecurityTestCase
{

/**
* Returns the lines where errors should occur.
*
* The key of the array should represent the line number and the value
* should represent the number of errors that should occur on that line.
*
* @return array<int, int>
*/
public function getErrorList()
{
return [
3 => 1,
4 => 1,
5 => 1,
];
}

/**
* Returns the lines where warnings should occur.
*
* The key of the array should represent the line number and the value
* should represent the number of warnings that should occur on that line.
*
* @return array<int, int>
*/
public function getWarningList()
{
return [];
}
}