for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare(strict_types=1);
namespace ncryptf\Tests;
use ncryptf\Utils;
use PHPUnit\Framework\TestCase;
class UtilsTest extends TestCase
{
public function testKeypairGeneration()
$keypair = Utils::generateKeypair();
$this->assertEquals(32, \strlen($keypair['public']));
$this->assertEquals(32, \strlen($keypair['secret']));
}
public function testSigningKeypairGeneration()
$keypair = Utils::generateSigningKeypair();
$this->assertEquals(64, \strlen($keypair['public']));
public function testZero()
$data = \random_bytes(32);
$zero = Utils::zero($data);
$zero
ncryptf\Utils::zero($data)
ncryptf\Utils::zero()
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
class A { function getObject() { return null; } } $a = new A(); $object = $a->getObject();
The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.
getObject()
The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.
$this->assertEquals($zero, null);
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.