Skip to content

Commit 5cda502

Browse files
committed
Use Webmozart for assertions
1 parent c6240dc commit 5cda502

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

lib/Auth/Source/Hash.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace SimpleSAML\Module\authcrypt\Auth\Source;
44

5+
use Webmozart\Assert\Assert;
6+
57
/**
68
* Authentication source for username & hashed password.
79
*
@@ -31,8 +33,8 @@ class Hash extends \SimpleSAML\Module\core\Auth\UserPassBase
3133
*/
3234
public function __construct($info, $config)
3335
{
34-
assert(is_array($info));
35-
assert(is_array($config));
36+
Assert::isArray($info);
37+
Assert::isArray($config);
3638

3739
// Call the parent constructor first, as required by the interface
3840
parent::__construct($info, $config);
@@ -85,8 +87,8 @@ public function __construct($info, $config)
8587
*/
8688
protected function login($username, $password)
8789
{
88-
assert(is_string($username));
89-
assert(is_string($password));
90+
Assert::string($username);
91+
Assert::string($password);
9092

9193
foreach ($this->users as $userpass => $attrs) {
9294
$matches = explode(':', $userpass, 2);

lib/Auth/Source/Htpasswd.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* @package SimpleSAMLphp
1010
*/
1111

12+
use Webmozart\Assert\Assert;
1213
use WhiteHat101\Crypt\APR1_MD5;
1314

1415
class Htpasswd extends \SimpleSAML\Module\core\Auth\UserPassBase
@@ -38,8 +39,9 @@ class Htpasswd extends \SimpleSAML\Module\core\Auth\UserPassBase
3839
*/
3940
public function __construct($info, $config)
4041
{
41-
assert(is_array($info));
42-
assert(is_array($config));
42+
43+
Assert::isArray($info);
44+
Assert::isArray($config);
4345

4446
// Call the parent constructor first, as required by the interface
4547
parent::__construct($info, $config);
@@ -79,8 +81,8 @@ public function __construct($info, $config)
7981
*/
8082
protected function login($username, $password)
8183
{
82-
assert(is_string($username));
83-
assert(is_string($password));
84+
Assert::string($username);
85+
Assert::string($password);
8486

8587
foreach ($this->users as $userpass) {
8688
$matches = explode(':', $userpass, 2);

0 commit comments

Comments
 (0)