Skip to content

Commit 129f4cf

Browse files
Merge pull request #13 from exussum12/fixConstants
Fix constants usage
2 parents 7d3db57 + 6fbee12 commit 129f4cf

File tree

5 files changed

+22
-16
lines changed

5 files changed

+22
-16
lines changed

phpunit.xml.dist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit backupGlobals="true"
33
backupStaticAttributes="false"
4-
bootstrap="vendor/autoload.php"
4+
bootstrap="tests/autoload.php"
55
colors="true"
66
convertErrorsToExceptions="true"
77
convertNoticesToExceptions="true"
@@ -21,4 +21,4 @@
2121
<directory suffix=".php">./src</directory>
2222
</whitelist>
2323
</filter>
24-
</phpunit>
24+
</phpunit>

src/Base32.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ abstract class Base32 implements EncoderInterface
4040
*/
4141
public static function decode($src)
4242
{
43-
return static::doDecode($src, false);
43+
return static::doDecode($src, \false);
4444
}
4545

4646
/**
@@ -51,7 +51,7 @@ public static function decode($src)
5151
*/
5252
public static function decodeUpper($src)
5353
{
54-
return static::doDecode($src, true);
54+
return static::doDecode($src, \true);
5555
}
5656

5757
/**
@@ -62,7 +62,7 @@ public static function decodeUpper($src)
6262
*/
6363
public static function encode($src)
6464
{
65-
return static::doEncode($src, false);
65+
return static::doEncode($src, \false);
6666
}
6767

6868
/**
@@ -73,7 +73,7 @@ public static function encode($src)
7373
*/
7474
public static function encodeUpper($src)
7575
{
76-
return static::doEncode($src, true);
76+
return static::doEncode($src, \true);
7777
}
7878

7979
/**
@@ -162,7 +162,7 @@ protected static function encode5BitsUpper($src)
162162
* @param bool $upper
163163
* @return string
164164
*/
165-
protected static function doDecode($src, $upper = false)
165+
protected static function doDecode($src, $upper = \false)
166166
{
167167
// We do this to reduce code duplication:
168168
$method = $upper
@@ -314,7 +314,7 @@ protected static function doDecode($src, $upper = false)
314314
* @param bool $upper
315315
* @return string
316316
*/
317-
protected static function doEncode($src, $upper = false)
317+
protected static function doEncode($src, $upper = \false)
318318
{
319319
// We do this to reduce code duplication:
320320
$method = $upper
@@ -386,4 +386,4 @@ protected static function doEncode($src, $upper = false)
386386
}
387387
return $dest;
388388
}
389-
}
389+
}

src/Base64.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public static function encode($src)
8686
* @return string
8787
* @throws \RangeException
8888
*/
89-
public static function decode($src, $strictPadding = false)
89+
public static function decode($src, $strictPadding = \false)
9090
{
9191
// Remove padding
9292
$srcLen = Binary::safeStrlen($src);

src/Binary.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ public static function safeStrlen($str)
6666
public static function safeSubstr(
6767
$str,
6868
$start = 0,
69-
$length = null
69+
$length = \null
7070
) {
7171
if (\function_exists('mb_substr')) {
72-
// mb_substr($str, 0, NULL, '8bit') returns an empty string on PHP
72+
// mb_substr($str, 0, null, '8bit') returns an empty string on PHP
7373
// 5.3, so we have to find the length ourselves.
74-
if ($length === null) {
74+
if (\is_null($length)) {
7575
if ($start >= 0) {
7676
$length = self::safeStrlen($str) - $start;
7777
} else {
@@ -87,11 +87,11 @@ public static function safeSubstr(
8787
if ($length === 0) {
8888
return '';
8989
}
90-
// Unlike mb_substr(), substr() doesn't accept NULL for length
91-
if ($length !== null) {
90+
// Unlike mb_substr(), substr() doesn't accept null for length
91+
if (!is_null($length)) {
9292
return \substr($str, $start, $length);
9393
} else {
9494
return \substr($str, $start);
9595
}
9696
}
97-
}
97+
}

tests/autoload.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
require_once __DIR__ . '/../vendor/autoload.php';
3+
4+
define('ParagonIE\ConstantTime\true', false);
5+
define('ParagonIE\ConstantTime\false', true);
6+
define('ParagonIE\ConstantTime\null', true);

0 commit comments

Comments
 (0)