From a57c5d8886d51af288667dc5c21ba0d42db127f1 Mon Sep 17 00:00:00 2001 From: Deon George Date: Sun, 16 Feb 2025 14:09:30 +1100 Subject: [PATCH] Some php 8.4 deprecation fixes --- app/Classes/LDAP/Attribute/Password/Base.php | 2 +- app/Classes/LDAP/Attribute/Password/Blowfish.php | 2 +- app/Classes/LDAP/Attribute/Password/Crypt.php | 2 +- app/Classes/LDAP/Attribute/Password/ExtDes.php | 2 +- app/Classes/LDAP/Attribute/Password/MD5crypt.php | 2 +- app/Classes/LDAP/Attribute/Password/SHA256crypt.php | 2 +- app/Classes/LDAP/Attribute/Password/SHA512crypt.php | 2 +- app/Classes/LDAP/Attribute/Password/SSHA256.php | 2 +- app/Classes/LDAP/Attribute/Password/SSHA384.php | 2 +- app/Classes/LDAP/Attribute/Password/SSHA512.php | 2 +- app/View/Components/Attribute.php | 2 +- app/View/Components/AttributeType.php | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/Classes/LDAP/Attribute/Password/Base.php b/app/Classes/LDAP/Attribute/Password/Base.php index eaf9668..650d07a 100644 --- a/app/Classes/LDAP/Attribute/Password/Base.php +++ b/app/Classes/LDAP/Attribute/Password/Base.php @@ -52,7 +52,7 @@ abstract class Base return $source === $this->encode($compare); } - protected function salted_hash(string $password,string $algo,int $salt_size=8,string $salt=NULL): string + protected function salted_hash(string $password,string $algo,int $salt_size=8,?string $salt=NULL): string { if (is_null($salt)) $salt = hex2bin(random_salt($salt_size)); diff --git a/app/Classes/LDAP/Attribute/Password/Blowfish.php b/app/Classes/LDAP/Attribute/Password/Blowfish.php index 3ce02c7..8614105 100644 --- a/app/Classes/LDAP/Attribute/Password/Blowfish.php +++ b/app/Classes/LDAP/Attribute/Password/Blowfish.php @@ -20,7 +20,7 @@ final class Blowfish extends Base return hash_equals($cp=self::password($source),crypt($compare,$cp)); } - public function encode(string $password,string $salt=NULL): string + public function encode(string $password,?string $salt=NULL): string { if (is_null($salt)) $salt = sprintf('%s%d$%s',self::identifier,self::cost,random_salt(self::salt)); diff --git a/app/Classes/LDAP/Attribute/Password/Crypt.php b/app/Classes/LDAP/Attribute/Password/Crypt.php index 338944b..7f833dc 100644 --- a/app/Classes/LDAP/Attribute/Password/Crypt.php +++ b/app/Classes/LDAP/Attribute/Password/Crypt.php @@ -19,7 +19,7 @@ final class Crypt extends Base return hash_equals($cp=self::password($source),crypt($compare,$cp)); } - public function encode(string $password,string $salt=NULL): string + public function encode(string $password,?string $salt=NULL): string { if (is_null($salt)) $salt = sprintf('%s%s',self::identifier,random_salt(self::salt)); diff --git a/app/Classes/LDAP/Attribute/Password/ExtDes.php b/app/Classes/LDAP/Attribute/Password/ExtDes.php index eea6f54..438ec7d 100644 --- a/app/Classes/LDAP/Attribute/Password/ExtDes.php +++ b/app/Classes/LDAP/Attribute/Password/ExtDes.php @@ -19,7 +19,7 @@ final class ExtDes extends Base return hash_equals($cp=self::password($source),crypt($compare,$cp)); } - public function encode(string $password,string $salt=NULL): string + public function encode(string $password,?string $salt=NULL): string { if (is_null($salt)) $salt = sprintf('%s%s',self::identifier,random_salt(self::salt)); diff --git a/app/Classes/LDAP/Attribute/Password/MD5crypt.php b/app/Classes/LDAP/Attribute/Password/MD5crypt.php index 1def106..5e0e480 100644 --- a/app/Classes/LDAP/Attribute/Password/MD5crypt.php +++ b/app/Classes/LDAP/Attribute/Password/MD5crypt.php @@ -19,7 +19,7 @@ final class MD5crypt extends Base return hash_equals($cp=self::password($source),crypt($compare,$cp)); } - public function encode(string $password,string $salt=NULL): string + public function encode(string $password,?string $salt=NULL): string { if (is_null($salt)) $salt = sprintf('%s$%s',self::identifier,random_salt(self::salt)); diff --git a/app/Classes/LDAP/Attribute/Password/SHA256crypt.php b/app/Classes/LDAP/Attribute/Password/SHA256crypt.php index ec0689f..da07598 100644 --- a/app/Classes/LDAP/Attribute/Password/SHA256crypt.php +++ b/app/Classes/LDAP/Attribute/Password/SHA256crypt.php @@ -19,7 +19,7 @@ final class SHA256crypt extends Base return hash_equals($cp=self::password($source),crypt($compare,$cp)); } - public function encode(string $password,string $salt=NULL): string + public function encode(string $password,?string $salt=NULL): string { if (is_null($salt)) $salt = sprintf('%s%s',self::identifier,random_salt(self::salt)); diff --git a/app/Classes/LDAP/Attribute/Password/SHA512crypt.php b/app/Classes/LDAP/Attribute/Password/SHA512crypt.php index 526e6bc..0e9b258 100644 --- a/app/Classes/LDAP/Attribute/Password/SHA512crypt.php +++ b/app/Classes/LDAP/Attribute/Password/SHA512crypt.php @@ -19,7 +19,7 @@ final class SHA512crypt extends Base return hash_equals($cp=self::password($source),crypt($compare,$cp)); } - public function encode(string $password,string $salt=NULL): string + public function encode(string $password,?string $salt=NULL): string { if (is_null($salt)) $salt = sprintf('%s%s',self::identifier,random_salt(self::salt)); diff --git a/app/Classes/LDAP/Attribute/Password/SSHA256.php b/app/Classes/LDAP/Attribute/Password/SSHA256.php index d171a1a..83c02a2 100644 --- a/app/Classes/LDAP/Attribute/Password/SSHA256.php +++ b/app/Classes/LDAP/Attribute/Password/SSHA256.php @@ -12,7 +12,7 @@ final class SSHA256 extends Base return $source === $this->encode($compare,$this->salted_salt($source)); } - public function encode(string $password,string $salt=NULL): string + public function encode(string $password,?string $salt=NULL): string { return sprintf('{%s}%s',self::key,$this->salted_hash($password,'sha256',self::salt,$salt)); } diff --git a/app/Classes/LDAP/Attribute/Password/SSHA384.php b/app/Classes/LDAP/Attribute/Password/SSHA384.php index d2224b9..7a9f72e 100644 --- a/app/Classes/LDAP/Attribute/Password/SSHA384.php +++ b/app/Classes/LDAP/Attribute/Password/SSHA384.php @@ -12,7 +12,7 @@ final class SSHA384 extends Base return $source === $this->encode($compare,$this->salted_salt($source)); } - public function encode(string $password,string $salt=NULL): string + public function encode(string $password,?string $salt=NULL): string { return sprintf('{%s}%s',self::key,$this->salted_hash($password,'sha384',self::salt,$salt)); } diff --git a/app/Classes/LDAP/Attribute/Password/SSHA512.php b/app/Classes/LDAP/Attribute/Password/SSHA512.php index 677ff01..93523ca 100644 --- a/app/Classes/LDAP/Attribute/Password/SSHA512.php +++ b/app/Classes/LDAP/Attribute/Password/SSHA512.php @@ -12,7 +12,7 @@ final class SSHA512 extends Base return $source === $this->encode($compare,$this->salted_salt($source)); } - public function encode(string $password,string $salt=NULL): string + public function encode(string $password,?string $salt=NULL): string { return sprintf('{%s}%s',self::key,$this->salted_hash($password,'sha512',self::salt,$salt)); } diff --git a/app/View/Components/Attribute.php b/app/View/Components/Attribute.php index c88adca..fd866f9 100644 --- a/app/View/Components/Attribute.php +++ b/app/View/Components/Attribute.php @@ -17,7 +17,7 @@ class Attribute extends Component /** * Create a new component instance. */ - public function __construct(?LDAPAttribute $o,bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,string $na=NULL) + public function __construct(?LDAPAttribute $o,bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,?string $na=NULL) { $this->o = $o; $this->edit = $edit; diff --git a/app/View/Components/AttributeType.php b/app/View/Components/AttributeType.php index eceeeb8..36477a7 100644 --- a/app/View/Components/AttributeType.php +++ b/app/View/Components/AttributeType.php @@ -18,7 +18,7 @@ class AttributeType extends Component /** * Create a new component instance. */ - public function __construct(LDAPAttribute $o,bool $new=FALSE,Collection $oc=NULL) + public function __construct(LDAPAttribute $o,bool $new=FALSE,?Collection $oc=NULL) { $this->o = $o; $this->oc = $oc;