';
@@ -410,9 +410,9 @@ function exceptionHandlerDumper($var)
function dimCommonPathPrefix($path)
{
// determine the longest shared prefix
- $prefix = dirname(__FILE__);
+ $prefix = __DIR__;
while (!empty($prefix) && $prefix !== '/' && $prefix !== '.') {
- if (strpos($path, $prefix . DIRECTORY_SEPARATOR) === 0) {
+ if (str_starts_with($path, $prefix . DIRECTORY_SEPARATOR)) {
break;
}
$prefix = dirname($prefix);
diff --git a/spoon/feed/rss.php b/spoon/feed/rss.php
index 60448eb..e86d7dc 100644
--- a/spoon/feed/rss.php
+++ b/spoon/feed/rss.php
@@ -38,7 +38,7 @@ class SpoonFeedRSS
*
* @var array
*/
- private $categories = array();
+ private $categories = [];
/**
@@ -94,7 +94,7 @@ class SpoonFeedRSS
*
* @var array
*/
- private $image = array();
+ private $image = [];
/**
@@ -102,7 +102,7 @@ class SpoonFeedRSS
*
* @var array
*/
- private $items = array();
+ private $items = [];
/**
@@ -158,7 +158,7 @@ class SpoonFeedRSS
*
* @var array
*/
- private $skipDays = array();
+ private $skipDays = [];
/**
@@ -166,7 +166,7 @@ class SpoonFeedRSS
*
* @var array
*/
- private $skipHours = array();
+ private $skipHours = [];
/**
@@ -217,7 +217,7 @@ class SpoonFeedRSS
* @param string $description The description of the feed.
* @param array[optional] $items An array with SpoonFeedRSSItems.
*/
- public function __construct($title, $link, $description, array $items = array())
+ public function __construct($title, $link, $description, array $items = [])
{
// set properties
$this->setTitle($title);
@@ -238,7 +238,7 @@ public function __construct($title, $link, $description, array $items = array())
public function addCategory($category, $domain = null)
{
// init var
- $categoryDetails = array();
+ $categoryDetails = [];
// add category
$categoryDetails['category'] = (string) $category;
@@ -270,7 +270,7 @@ public function addItem(SpoonFeedRSSItem $item)
public function addSkipDay($day)
{
// allowed days
- $allowedDays = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saterday');
+ $allowedDays = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saterday'];
// redefine var
$day = (string) SpoonFilter::getValue(strtolower($day), $allowedDays, 'sunday');
@@ -297,7 +297,7 @@ public function addSkipHour($hour)
$hour = (int) SpoonFilter::getValue($hour, $allowedHours, 0);
// validate
- if(!in_array($hour, $allowedHours)) throw new SpoonFeedException('This (' . $hour . ') isn\'t a valid hour. Only ' . join(', ', $allowedHours) . ' are allowed.)');
+ if(!in_array($hour, $allowedHours)) throw new SpoonFeedException('This (' . $hour . ') isn\'t a valid hour. Only ' . implode(', ', $allowedHours) . ' are allowed.)');
if(in_array($hour, $this->skipHours)) throw new SpoonFeedException('This (' . $hour . ') hour is already added.');
// set property
@@ -750,7 +750,7 @@ public static function isValid($URL, $type = 'url')
{
// redefine var
$URL = (string) $URL;
- $type = (string) SpoonFilter::getValue($type, array('url', 'string'), 'url');
+ $type = (string) SpoonFilter::getValue($type, ['url', 'string'], 'url');
// validate
if($type == 'url' && !SpoonFilter::isURL($URL)) throw new SpoonFeedException('This (' . $URL . ') isn\'t a valid url.');
@@ -843,7 +843,7 @@ public static function readFromFeed($URL, $type = 'url', $force = false)
{
// redefine var
$URL = (string) $URL;
- $type = (string) SpoonFilter::getValue($type, array('url', 'string'), 'url');
+ $type = (string) SpoonFilter::getValue($type, ['url', 'string'], 'url');
// validate
if($type == 'url' && !SpoonFilter::isURL($URL)) throw new SpoonFeedException('This (' . SpoonFilter::htmlentities($URL) . ') isn\'t a valid URL.');
@@ -881,7 +881,7 @@ public static function readFromFeed($URL, $type = 'url', $force = false)
}
// catch exceptions
- catch(Exception $e)
+ catch(Exception)
{
// ignore exceptions
}
@@ -911,7 +911,7 @@ public static function readFromFeed($URL, $type = 'url', $force = false)
}
// catch exception
- catch(Exception $e)
+ catch(Exception)
{
// ignore exceptions
}
@@ -931,7 +931,7 @@ public static function readFromFeed($URL, $type = 'url', $force = false)
}
// catch exception
- catch(Exception $e)
+ catch(Exception)
{
// ignore exceptions
}
@@ -997,7 +997,7 @@ public static function readFromFeed($URL, $type = 'url', $force = false)
}
// catch exception
- catch(Exception $e)
+ catch(Exception)
{
// ignore exceptions
}
@@ -1083,7 +1083,7 @@ public function setCloud($domain, $port, $path, $registerProcedure, $protocol)
$this->cloud['port'] = (int) $port;
$this->cloud['path'] = (string) $path;
$this->cloud['register_procedure'] = (string) $registerProcedure;
- $this->cloud['protocol'] = (string) SpoonFilter::getValue($protocol, array('xml-rpc', 'soap', 'http-post'), 'xml-rpc');
+ $this->cloud['protocol'] = (string) SpoonFilter::getValue($protocol, ['xml-rpc', 'soap', 'http-post'], 'xml-rpc');
}
@@ -1253,7 +1253,7 @@ public function setSorting($on = true)
*/
public function setSortingMethod($sortingMethod = 'desc')
{
- $aAllowedSortingMethods = array('asc', 'desc');
+ $aAllowedSortingMethods = ['asc', 'desc'];
// set sorting method
self::$sortingMethod = SpoonFilter::getValue($sortingMethod, $aAllowedSortingMethods, 'desc');
@@ -1302,7 +1302,7 @@ private function sort()
$items = $this->getItems();
// sort
- uasort($items, array('SpoonFeedRSS', 'compareObjects'));
+ uasort($items, ['SpoonFeedRSS', 'compareObjects']);
// set items
$this->items = $items;
diff --git a/spoon/feed/rss_item.php b/spoon/feed/rss_item.php
index f354fc0..e225863 100644
--- a/spoon/feed/rss_item.php
+++ b/spoon/feed/rss_item.php
@@ -39,7 +39,7 @@ class SpoonFeedRSSItem
*
* @var array
*/
- private $categories = array();
+ private $categories = [];
/**
@@ -71,7 +71,7 @@ class SpoonFeedRSSItem
*
* @var array
*/
- private $guid = array();
+ private $guid = [];
/**
@@ -95,7 +95,7 @@ class SpoonFeedRSSItem
*
* @var array
*/
- private $source = array();
+ private $source = [];
/**
@@ -408,7 +408,7 @@ public static function readFromXML(SimpleXMLElement $item)
}
// catch exceptions
- catch(Exception $e)
+ catch(Exception)
{
// ignore exceptions
}
@@ -430,7 +430,7 @@ public static function readFromXML(SimpleXMLElement $item)
}
// catch exceptions
- catch(Exception $e)
+ catch(Exception)
{
// ignore exceptions
}
@@ -451,7 +451,7 @@ public static function readFromXML(SimpleXMLElement $item)
}
// catch exceptions
- catch(Exception $e)
+ catch(Exception)
{
// ignore exceptions
}
@@ -475,7 +475,7 @@ public static function readFromXML(SimpleXMLElement $item)
}
// catch exceptions
- catch(Exception $e)
+ catch(Exception)
{
// ignore exceptions
}
diff --git a/spoon/file/csv.php b/spoon/file/csv.php
index c50da1a..7d22e44 100644
--- a/spoon/file/csv.php
+++ b/spoon/file/csv.php
@@ -44,7 +44,7 @@ class SpoonFileCSV
* @param string[optional] $enclosure The enclosure character of the CSV.
* @param bool[optional] $download Should the file be downloaded?
*/
- public static function arrayToFile($path, array $array, array $columns = null, array $excludeColumns = null, $delimiter = ',', $enclosure = '"', $download = false)
+ public static function arrayToFile($path, array $array, ?array $columns = null, ?array $excludeColumns = null, $delimiter = ',', $enclosure = '"', $download = false)
{
// get the content of the file
$csv = self::arrayToString($array, $columns, $excludeColumns, $delimiter, $enclosure);
@@ -68,7 +68,7 @@ public static function arrayToFile($path, array $array, array $columns = null, a
* @param string[optional] $enclosure The enclosure character of the CSV.
* @param string[optional] $lineEnding The line-ending of the CSV.
*/
- public static function arrayToString(array $array, array $columns = null, array $excludeColumns = null, $delimiter = ',', $enclosure = '"', $lineEnding = null)
+ public static function arrayToString(array $array, ?array $columns = null, ?array $excludeColumns = null, $delimiter = ',', $enclosure = '"', $lineEnding = null)
{
// validate array
if(!empty($array) && !isset($array[0])) throw new SpoonFileException('Invalid array format.');
@@ -140,7 +140,7 @@ private static function download($path)
$filename = end($explodedFilename);
// set headers for download
- $headers = array();
+ $headers = [];
$headers[] = 'Content-type: text/csv; charset=utf-8';
$headers[] = 'Content-Disposition: attachment; filename="' . $filename . '"';
@@ -171,7 +171,7 @@ private static function download($path)
public static function escapeEnclosure($row, $enclosure)
{
// init var
- $escaped = array();
+ $escaped = [];
// apply enclosure
foreach($row as $key => $value)
@@ -193,7 +193,7 @@ public static function escapeEnclosure($row, $enclosure)
* @param string[optional] $delimiter The field delimiter of the CSV.
* @param string[optional] $enclosure The enclosure character of the CSV.
*/
- public static function fileToArray($path, array $columns = array(), array $excludeColumns = null, $delimiter = ',', $enclosure = '"')
+ public static function fileToArray($path, array $columns = [], ?array $excludeColumns = null, $delimiter = ',', $enclosure = '"')
{
// reset variables
$path = (string) $path;
@@ -210,13 +210,13 @@ public static function fileToArray($path, array $columns = array(), array $exclu
@ini_set('auto_detect_line_endings', 1);
// init var
- $rows = array();
+ $rows = [];
// open file
$handle = @fopen($path, 'r');
// loop lines and store the rows
- while(($row = @fgetcsv($handle, 0, (($delimiter == '') ? ',' : $delimiter), (($enclosure == '') ? '"' : $enclosure))) !== false) $rows[] = $row;
+ while(($row = @fgetcsv($handle, 0, (($delimiter == '') ? ',' : $delimiter), (($enclosure == '') ? '"' : $enclosure), escape: '\\')) !== false) $rows[] = $row;
// close file
@fclose($handle);
@@ -231,7 +231,7 @@ public static function fileToArray($path, array $columns = array(), array $exclu
array_shift($rows);
// loop the rows
- foreach($rows as $rowId => &$row)
+ foreach($rows as &$row)
{
// the keys of this row
$keys = array_keys($row);
@@ -354,7 +354,7 @@ private static function getDelimiterAndEnclosure($string, $delimiter = null, $en
}
// return the results
- return array($delimiter, $enclosure);
+ return [$delimiter, $enclosure];
}
@@ -368,11 +368,11 @@ private static function getDelimiterAndEnclosure($string, $delimiter = null, $en
* @param string[optional] $delimiter The field delimiter of the CSV.
* @param string[optional] $enclosure The enclosure character of the CSV.
*/
- public static function stringToArray($string, array $columns = array(), array $excludeColumns = null, $delimiter = ',', $enclosure = '"')
+ public static function stringToArray($string, array $columns = [], ?array $excludeColumns = null, $delimiter = ',', $enclosure = '"')
{
// reset variables
$string = (string) $string;
- $filename = dirname(__FILE__) . '/' . uniqid();
+ $filename = __DIR__ . '/' . uniqid();
// save a tempfile
SpoonFile::setContent($filename, $string);
diff --git a/spoon/file/file.php b/spoon/file/file.php
index 2e3d410..2b529a7 100644
--- a/spoon/file/file.php
+++ b/spoon/file/file.php
@@ -73,6 +73,7 @@ public static function download($sourceURL, $destinationPath, $overwrite = true)
if($fileHandle === false) return false;
$options[CURLOPT_URL] = $sourceURL;
+ $options[CURLOPT_FOLLOWLOCATION] = true;
$options[CURLOPT_FILE] = $fileHandle;
$options[CURLOPT_HEADER] = false;
if(ini_get('open_basedir') == '' && ini_get('safe_mode' == 'Off')) $options[CURLOPT_FOLLOWLOCATION] = true;
@@ -92,7 +93,6 @@ public static function download($sourceURL, $destinationPath, $overwrite = true)
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
// close
- curl_close($curl);
fclose($fileHandle);
// validate the errornumber
@@ -177,7 +177,7 @@ public static function getInfo($filename)
$filename = (string) $filename;
// init var
- $units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
+ $units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
// fetch pathinfo
$pathInfo = pathinfo($filename);
@@ -186,7 +186,7 @@ public static function getInfo($filename)
@clearstatcache();
// build details array
- $file = array();
+ $file = [];
$file['basename'] = $pathInfo['basename'];
$file['extension'] = self::getExtension($filename);
$file['name'] = substr($file['basename'], 0, strlen($file['basename']) - strlen($file['extension']) -1);
@@ -235,7 +235,7 @@ public static function getList($path, $includeRegexp = null)
}
// define list
- $files = array();
+ $files = [];
// directory exists
if(SpoonDirectory::exists($path))
@@ -253,7 +253,7 @@ public static function getList($path, $includeRegexp = null)
if($includeRegexp !== null)
{
// init var
- $matches = array();
+ $matches = [];
// is this a match?
if(preg_match($includeRegexp, $file, $matches) != 0) $files[] = $file;
diff --git a/spoon/filter/filter.php b/spoon/filter/filter.php
index 93e0539..d714930 100644
--- a/spoon/filter/filter.php
+++ b/spoon/filter/filter.php
@@ -34,7 +34,7 @@ class SpoonFilter
*
* @var array
*/
- private static $tlds = array(
+ private static $tlds = [
'ac', 'ad', 'ae', 'aero', 'af', 'ag', 'ai', 'al', 'am', 'an', 'ao', 'aq', 'ar', 'arpa', 'as', 'asia', 'at', 'au', 'aw', 'ax', 'az',
'ba', 'bb', 'bd' ,'be', 'bf', 'bg', 'bh', 'bi', 'biz', 'bj', 'bm', 'bn', 'bo', 'br', 'bs', 'bt', 'bv', 'bw', 'by' ,'bz',
'ca', 'cat', 'cc' ,'cd', 'cf', 'cg', 'ch', 'ci', 'ck', 'cl', 'cm', 'cn', 'co', 'com', 'coop', 'cr', 'cu', 'cv', 'cx', 'cy', 'cz',
@@ -60,7 +60,7 @@ class SpoonFilter
'wf', 'ws',
'ye', 'yt', 'yu',
'za', 'zm', 'zw'
- );
+ ];
/**
@@ -74,7 +74,7 @@ class SpoonFilter
public static function arrayMapRecursive($callback, array $array, $allowedKeys = null)
{
// has no elements
- if(empty($array)) return array();
+ if(empty($array)) return [];
// check if there is a key restriction
if(!empty($allowedKeys))
@@ -84,7 +84,7 @@ public static function arrayMapRecursive($callback, array $array, $allowedKeys =
}
// declare our result array
- $results = array();
+ $results = [];
// loop the array
foreach($array as $key => $value)
@@ -106,7 +106,7 @@ public static function arrayMapRecursive($callback, array $array, $allowedKeys =
}
// more than 1 function given, so apply them all
- if(is_array($callback)) $results[$key] = call_user_func_array($callback, array($value));
+ if(is_array($callback)) $results[$key] = call_user_func_array($callback, [$value]);
// just 1 function given
else $results[$key] = $callback($value);
@@ -156,16 +156,16 @@ public static function disableMagicQuotes()
*/
function fixMagicQuotes($value)
{
- $value = is_array($value) ? array_map('fixMagicQuotes', $value) : stripslashes($value);
+ $value = is_array($value) ? array_map(fixMagicQuotes(...), $value) : stripslashes((string) $value);
return $value;
}
}
// fix the thing with magic dust!
- $_POST = array_map('fixMagicQuotes', $_POST);
- $_GET = array_map('fixMagicQuotes', $_GET);
- $_COOKIE = array_map('fixMagicQuotes', $_COOKIE);
- $_REQUEST = array_map('fixMagicQuotes', $_REQUEST);
+ $_POST = array_map(fixMagicQuotes(...), $_POST);
+ $_GET = array_map(fixMagicQuotes(...), $_GET);
+ $_COOKIE = array_map(fixMagicQuotes(...), $_COOKIE);
+ $_REQUEST = array_map(fixMagicQuotes(...), $_REQUEST);
}
}
@@ -178,7 +178,7 @@ function fixMagicQuotes($value)
* @param mixed $defaultValue The default-value.
* @param string[optional] $returnType The type that should be returned.
*/
- public static function getValue($variable, array $values = null, $defaultValue, $returnType = 'string')
+ public static function getValue($variable, ?array $values = null, $defaultValue = null, $returnType = 'string')
{
// redefine arguments
$variable = !is_array($variable) ? (string) $variable : $variable;
@@ -217,34 +217,14 @@ public static function getValue($variable, array $values = null, $defaultValue,
* We have to define the return type. Too bad we cant force it within
* a certain list of types, since that's what this method actually does.
*/
- switch($returnType)
- {
- // array
- case 'array':
- $value = ($value == '') ? array() : (array) $value;
- break;
-
- // bool
- case 'bool':
- $value = (bool) $value;
- break;
-
- // double/float
- case 'double':
- case 'float':
- $value = (float) $value;
- break;
-
- // int
- case 'int':
- $value = (int) $value;
- break;
-
- // string
- case 'string':
- $value = (string) $value;
- break;
- }
+ $value = match ($returnType) {
+ 'array' => ($value == '') ? [] : (array) $value,
+ 'bool' => (bool) $value,
+ 'double', 'float' => (float) $value,
+ 'int' => (int) $value,
+ 'string' => (string) $value,
+ default => $value,
+ };
return $value;
}
@@ -262,7 +242,7 @@ public static function htmlentities($value, $charset = null, $quoteStyle = ENT_N
{
// init vars
$charset = ($charset !== null) ? self::getValue($charset, Spoon::getCharsets(), Spoon::getCharset()) : Spoon::getCharset();
- $quoteStyle = self::getValue($quoteStyle, array(ENT_COMPAT, ENT_QUOTES, ENT_NOQUOTES), ENT_NOQUOTES);
+ $quoteStyle = self::getValue($quoteStyle, [ENT_COMPAT, ENT_QUOTES, ENT_NOQUOTES], ENT_NOQUOTES);
// apply htmlentities
$return = htmlentities((string) $value, $quoteStyle, $charset);
@@ -273,7 +253,7 @@ public static function htmlentities($value, $charset = null, $quoteStyle = ENT_N
* we're using a decent database layer, we don't need this shit and we're replacing
* the double backslashes by its' html entity equivalent.
*/
- return str_replace(array('\\'), array('\'), $return);
+ return str_replace(['\\'], ['\'], $return);
}
@@ -289,7 +269,7 @@ public static function htmlentitiesDecode($value, $charset = null, $quoteStyle =
{
// init vars
$charset = ($charset !== null) ? self::getValue($charset, Spoon::getCharsets(), Spoon::getCharset()) : Spoon::getCharset();
- $quoteStyle = self::getValue($quoteStyle, array(ENT_COMPAT, ENT_QUOTES, ENT_NOQUOTES), ENT_NOQUOTES);
+ $quoteStyle = self::getValue($quoteStyle, [ENT_COMPAT, ENT_QUOTES, ENT_NOQUOTES], ENT_NOQUOTES);
// apply method
return html_entity_decode((string) $value, $quoteStyle, $charset);
@@ -475,7 +455,7 @@ public static function isFloat($value, $allowCommas = false)
if(mb_strpos((string) $value, '.') !== false)
{
$value = rtrim($value, '0');
- if(substr($value, -1) == '.') $value = substr($value, 0, -1);
+ if(str_ends_with($value, '.')) $value = substr($value, 0, -1);
}
// validate
@@ -515,20 +495,20 @@ public static function isInteger($value)
* @return bool True if the request is coming from this site, false if not.
* @param array[optional] $domains An array containing all known domains.
*/
- public static function isInternalReferrer(array $domains = null)
+ public static function isInternalReferrer(?array $domains = null)
{
// no referrer or host found
if(!isset($_SERVER['HTTP_REFERER'])) return true;
if(!isset($_SERVER['HTTP_HOST'])) return true;
// get own & referrer host names
- $referrer = parse_url($_SERVER['HTTP_REFERER']);
+ $referrer = parse_url((string) $_SERVER['HTTP_REFERER']);
$referrer = $referrer['host'];
$hostname = $_SERVER['HTTP_HOST'];
// redefine hostname & domains
- if(strpos($referrer, 'www.') === 0) $referrer = substr($referrer, 4);
- if(strpos($hostname, 'www.') === 0) $hostname = substr($hostname, 4);
+ if(str_starts_with($referrer, 'www.')) $referrer = substr($referrer, 4);
+ if(str_starts_with((string) $hostname, 'www.')) $hostname = substr((string) $hostname, 4);
$domains = ($domains === null) ? (array) $hostname : (array) $domains;
// internal?
@@ -678,7 +658,7 @@ public static function isPrice($value, $precision = 2, $allowNegative = false, $
if(mb_strpos($value, '.') !== false)
{
$value = rtrim($value, '0');
- if(substr($value, -1) == '.') $value = substr($value, 0, -1);
+ if(str_ends_with($value, '.')) $value = substr($value, 0, -1);
}
// no negatives allowed
@@ -714,7 +694,7 @@ public static function isString($value)
{
$value = 'Array';
}
- return (bool) preg_match('/^[^\x-\x1F]+$/', (string) $value);
+ return (bool) preg_match('/^[^\x00-\x1F]+$/', (string) $value);
}
@@ -806,7 +786,7 @@ public static function replaceURLsWithAnchors($value, $noFollow = true)
$pattern = '/(((http|ftp|https):\/{2})?(([0-9a-z_-]+\.)+(' . implode('|', self::$tlds) . ')(:[0-9]+)?((\/([~0-9a-zA-Z\#\+\%@\.\/_-]+))?(\?[0-9a-zA-Z\+\%@\/&\[\];=_-]+)?)?))\b/imu';
// get matches
- $value = preg_replace_callback($pattern, array('SpoonFilter', 'replaceURLsCallback'), $value);
+ $value = preg_replace_callback($pattern, ['SpoonFilter', 'replaceURLsCallback'], $value);
// add noFollow-attribute
if($noFollow) $value = str_replace('(.*\n*)\|isU', '', $string);
- $string = preg_replace('|\(.*\n*)\|isU', '', $string);
+ $string = preg_replace('|\(.*\n*)\|isU', '', (string) $string);
+ $string = preg_replace('|\(.*\n*)\|isU', '', (string) $string);
// replace images with their alternative content
// eg. => My image
- if($replaceImagesWithAltText) $string = preg_replace('|\]*alt="(.*)".*/\>|isU', '$1', $string);
+ if($replaceImagesWithAltText) $string = preg_replace('|\]*alt="(.*)".*/\>|isU', '$1', (string) $string);
// replace links with the inner html of the link with the url between ()
// eg.: My site => My site (http://site.domain.com)
- if($replaceAnchorsWithURL) $string = preg_replace('|(.*)|isU', '$2 ($1)', $string);
+ if($replaceAnchorsWithURL) $string = preg_replace('|(.*)|isU', '$2 ($1)', (string) $string);
// check if we need to preserve paragraphs and/or breaks
$exceptions = ($preserveParagraphLinebreaks) ? $exceptions . '
' : $exceptions;
// strip HTML tags and preserve paragraphs
- $string = strip_tags($string, $exceptions);
+ $string = strip_tags((string) $string, $exceptions);
// remove multiple with a single one
$string = preg_replace('/\n\s/', PHP_EOL, $string);
- $string = preg_replace('/\n{2,}/', PHP_EOL, $string);
+ $string = preg_replace('/\n{2,}/', PHP_EOL, (string) $string);
// for each linebreak, table row or- paragraph end we want an additional linebreak at the end
if($preserveParagraphLinebreaks)
{
- $string = preg_replace('|