]> git.mxchange.org Git - friendica.git/commitdiff
Address some PHP 8.1 deprecation notices
authorHypolite Petovan <hypolite@mrpetovan.com>
Wed, 30 Nov 2022 00:31:16 +0000 (19:31 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Wed, 30 Nov 2022 02:37:41 +0000 (21:37 -0500)
- Replace a strstr call by strpos in Model\APContact
- Simplify conditions in Protocol\DFRN
- Address part of https://github.com/friendica/friendica/issues/12011#issuecomment-1331012289

src/Model/APContact.php
src/Navigation/Notifications/ValueObject/Introduction.php
src/Protocol/DFRN.php

index 3b568f39f1d85c5c7be8880668adfe97d7c94e43..67ce2b66bf73d9c689ef5f778404edc42c1fb358 100644 (file)
@@ -305,8 +305,8 @@ class APContact
 
                $apcontact['pubkey'] = null;
                if (!empty($compacted['w3id:publicKey'])) {
-                       $apcontact['pubkey'] = trim(JsonLD::fetchElement($compacted['w3id:publicKey'], 'w3id:publicKeyPem', '@value'));
-                       if (strstr($apcontact['pubkey'], 'RSA ')) {
+                       $apcontact['pubkey'] = trim(JsonLD::fetchElement($compacted['w3id:publicKey'], 'w3id:publicKeyPem', '@value') ?? '');
+                       if (strpos($apcontact['pubkey'], 'RSA ') !== false) {
                                $apcontact['pubkey'] = Crypto::rsaToPem($apcontact['pubkey']);
                        }
                }
index cb27b388866bc298105a2bc38e73e3a34326e93b..da664ce8e55ab8dc92c1d5d85c7eef2321a77338 100644 (file)
@@ -226,6 +226,7 @@ class Introduction implements \JsonSerializable
        /**
         * @inheritDoc
         */
+       #[\ReturnTypeWillChange]
        public function jsonSerialize()
        {
                return $this->toArray();
index da4db5d9ad9dba04639881ad1501941e277d3922..a86cf2094dc2343fc353426da5bbd52810dfb3df 100644 (file)
@@ -538,7 +538,7 @@ class DFRN
 
                        XML::addElement($doc, $author, 'poco:utcOffset', DateTimeFormat::timezoneNow($profile['timezone'], 'P'));
 
-                       if (trim($profile['homepage']) != '') {
+                       if (trim($profile['homepage'])) {
                                $urls = $doc->createElement('poco:urls');
                                XML::addElement($doc, $urls, 'poco:type', 'homepage');
                                XML::addElement($doc, $urls, 'poco:value', $profile['homepage']);
@@ -546,7 +546,7 @@ class DFRN
                                $author->appendChild($urls);
                        }
 
-                       if (trim($profile['pub_keywords']) != '') {
+                       if (trim($profile['pub_keywords'] ?? '')) {
                                $keywords = explode(',', $profile['pub_keywords']);
 
                                foreach ($keywords as $keyword) {
@@ -554,7 +554,7 @@ class DFRN
                                }
                        }
 
-                       if (trim($profile['xmpp']) != '') {
+                       if (trim($profile['xmpp'])) {
                                $ims = $doc->createElement('poco:ims');
                                XML::addElement($doc, $ims, 'poco:type', 'xmpp');
                                XML::addElement($doc, $ims, 'poco:value', $profile['xmpp']);
@@ -562,7 +562,7 @@ class DFRN
                                $author->appendChild($ims);
                        }
 
-                       if (trim($profile['locality'] . $profile['region'] . $profile['country-name']) != '') {
+                       if (trim($profile['locality'] . $profile['region'] . $profile['country-name'])) {
                                $element = $doc->createElement('poco:address');
 
                                XML::addElement($doc, $element, 'poco:formatted', Profile::formatLocation($profile));