Remove useless NewInstance

Bugfix: BodyStructure->SearchCharset return value
This commit is contained in:
djmaze 2020-05-08 11:49:18 +02:00
parent 82e560bc53
commit 693e0f4c10
61 changed files with 802 additions and 1345 deletions

View file

@ -17,6 +17,14 @@ namespace MailSo\Base;
*/
abstract class Collection extends \ArrayObject
{
function __construct($input = array(), int $flags = 0, string $iterator_class = "ArrayIterator")
{
parent::__construct();
foreach ($input as $item) {
$this->append($item);
}
}
/**
* @param mixed $mItem
*/

View file

@ -446,7 +446,7 @@ abstract class HtmlUtils
{
if ($oTextNode && 0 < \strlen($oTextNode->wholeText)/* && \preg_match('/http[s]?:\/\//i', $oTextNode->wholeText)*/)
{
$sText = \MailSo\Base\LinkFinder::NewInstance()
$sText = (new \MailSo\Base\LinkFinder)
->Text($oTextNode->wholeText)
->UseDefaultWrappers(true)
->CompileText()
@ -1037,7 +1037,7 @@ abstract class HtmlUtils
return '';
}
$sText = \MailSo\Base\LinkFinder::NewInstance()
$sText = (new \MailSo\Base\LinkFinder)
->Text($sText)
->UseDefaultWrappers($bLinksWithTargetBlank)
->CompileText()

View file

@ -17,11 +17,6 @@ namespace MailSo\Base;
*/
class Http
{
public static function NewInstance() : self
{
return new self();
}
/**
* @staticvar \MailSo\Base\Http $oInstance;
*/
@ -30,7 +25,7 @@ class Http
static $oInstance = null;
if (null === $oInstance)
{
$oInstance = self::NewInstance();
$oInstance = new self;
}
return $oInstance;

View file

@ -53,7 +53,7 @@ class LinkFinder
*/
private $iOptimizationLimit;
private function __construct()
function __construct()
{
$this->iHtmlSpecialCharsFlags = (\defined('ENT_QUOTES') && \defined('ENT_SUBSTITUTE') && \defined('ENT_HTML401'))
? ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401 : ENT_QUOTES;
@ -68,11 +68,6 @@ class LinkFinder
$this->Clear();
}
public static function NewInstance() : self
{
return new self();
}
public function Clear() : self
{
$this->aPrepearPlainStringUrls = array();

View file

@ -1083,8 +1083,7 @@ END;
public static function Trim(string $sValue) : string
{
return \trim(\preg_replace('/^[\x00-\x1F]+/u', '',
\preg_replace('/[\x00-\x1F]+$/u', '', \trim($sValue))));
return \trim(\preg_replace('/^[\x00-\x1F]+|[\x00-\x1F]+$/Du', '', \trim($sValue)));
}
public static function RecRmDir(string $sDir) : bool
@ -1859,7 +1858,7 @@ END;
if (null === $oIdn)
{
include_once dirname(__DIR__).'/Vendors/Net/IDNA2.php';
$oIdn = new \Net_IDNA2();
$oIdn = new \Net_IDNA2;
$oIdn->setParams('utf8', true);
}