diff --git a/tcpdf/include/tcpdf_fonts.php b/tcpdf/include/tcpdf_fonts.php
index c692ef8..fc5fce5 100755
--- a/tcpdf/include/tcpdf_fonts.php
+++ b/tcpdf/include/tcpdf_fonts.php
@@ -79,13 +79,13 @@ class TCPDF_FONTS {
// build new font name for TCPDF compatibility
$font_path_parts = pathinfo($fontfile);
if (!isset($font_path_parts['filename'])) {
- $font_path_parts['filename'] = substr($font_path_parts['basename'], 0, -(strlen($font_path_parts['extension']) + 1));
+ $font_path_parts['filename'] = \substr($font_path_parts['basename'], 0, -(strlen($font_path_parts['extension']) + 1));
}
- $font_name = strtolower($font_path_parts['filename']);
- $font_name = preg_replace('/[^a-z0-9_]/', '', $font_name);
+ $font_name = \strtolower($font_path_parts['filename']);
+ $font_name = \preg_replace('/[^a-z0-9_]/', '', $font_name);
$search = array('bold', 'oblique', 'italic', 'regular');
$replace = array('b', 'i', 'i', '');
- $font_name = str_replace($search, $replace, $font_name);
+ $font_name = \str_replace($search, $replace, $font_name);
if (empty($font_name)) {
// set generic name
$font_name = 'tcpdffont';
@@ -102,14 +102,14 @@ class TCPDF_FONTS {
$fmetric['file'] = $font_name;
$fmetric['ctg'] = $font_name.'.ctg.z';
// get font data
- $font = file_get_contents($fontfile);
+ $font = \file_get_contents($fontfile);
$fmetric['originalsize'] = strlen($font);
// autodetect font type
if (empty($fonttype)) {
if (TCPDF_STATIC::_getULONG($font, 0) == 0x10000) {
// True Type (Unicode or not)
$fonttype = 'TrueTypeUnicode';
- } elseif (substr($font, 0, 4) == 'OTTO') {
+ } elseif (\substr($font, 0, 4) == 'OTTO') {
// Open Type (Unicode or not)
//Unsupported font format: OpenType with CFF data
return false;
@@ -145,7 +145,7 @@ class TCPDF_FONTS {
}
}
// set encoding maps (if any)
- $fmetric['enc'] = preg_replace('/[^A-Za-z0-9_\-]/', '', $enc);
+ $fmetric['enc'] = \preg_replace('/[^A-Za-z0-9_\-]/', '', $enc);
$fmetric['diff'] = '';
if (($fmetric['type'] == 'TrueType') OR ($fmetric['type'] == 'Type1')) {
if (!empty($enc) AND ($enc != 'cp1252') AND isset(TCPDF_FONT_DATA::$encmap[$enc])) {
@@ -168,21 +168,21 @@ class TCPDF_FONTS {
if ($fmetric['type'] == 'Type1') {
// ---------- TYPE 1 ----------
// read first segment
- $a = unpack('Cmarker/Ctype/Vsize', substr($font, 0, 6));
+ $a = unpack('Cmarker/Ctype/Vsize', \substr($font, 0, 6));
if ($a['marker'] != 128) {
// Font file is not a valid binary Type1
return false;
}
$fmetric['size1'] = $a['size'];
- $data = substr($font, 6, $fmetric['size1']);
+ $data = \substr($font, 6, $fmetric['size1']);
// read second segment
- $a = unpack('Cmarker/Ctype/Vsize', substr($font, (6 + $fmetric['size1']), 6));
+ $a = unpack('Cmarker/Ctype/Vsize', \substr($font, (6 + $fmetric['size1']), 6));
if ($a['marker'] != 128) {
// Font file is not a valid binary Type1
return false;
}
$fmetric['size2'] = $a['size'];
- $encrypted = substr($font, (12 + $fmetric['size1']), $fmetric['size2']);
+ $encrypted = \substr($font, (12 + $fmetric['size1']), $fmetric['size2']);
$data .= $encrypted;
// store compressed font
$fmetric['file'] .= '.z';
@@ -192,7 +192,7 @@ class TCPDF_FONTS {
// get font info
$fmetric['Flags'] = $flags;
preg_match ('#/FullName[\s]*\(([^\)]*)#', $font, $matches);
- $fmetric['name'] = preg_replace('/[^a-zA-Z0-9_\-]/', '', $matches[1]);
+ $fmetric['name'] = \preg_replace('/[^a-zA-Z0-9_\-]/', '', $matches[1]);
preg_match('#/FontBBox[\s]*{([^}]*)#', $font, $matches);
$fmetric['bbox'] = trim($matches[1]);
$bv = explode(' ', $fmetric['bbox']);
@@ -272,7 +272,7 @@ class TCPDF_FONTS {
}
$fmetric['Leading'] = 0;
// get charstring data
- $eplain = substr($eplain, (strpos($eplain, '/CharStrings') + 1));
+ $eplain = \substr($eplain, (strpos($eplain, '/CharStrings') + 1));
preg_match_all('#/([A-Za-z0-9\.]*)[\s][0-9]+[\s]RD[\s](.*)[\s]ND#sU', $eplain, $matches, PREG_SET_ORDER);
if (!empty($enc) AND isset(TCPDF_FONT_DATA::$encmap[$enc])) {
$enc_map = TCPDF_FONT_DATA::$encmap[$enc];
@@ -382,7 +382,7 @@ class TCPDF_FONTS {
// ---------- get tables ----------
for ($i = 0; $i < $numTables; ++$i) {
// get table info
- $tag = substr($font, $offset, 4);
+ $tag = \substr($font, $offset, 4);
$offset += 4;
$table[$tag] = array();
$table[$tag]['checkSum'] = TCPDF_STATIC::_getULONG($font, $offset);
@@ -508,8 +508,8 @@ class TCPDF_FONTS {
$stringOffset = TCPDF_STATIC::_getUSHORT($font, $offset);
$offset += 2;
$offset = ($table['name']['offset'] + $stringStorageOffset + $stringOffset);
- $fmetric['name'] = substr($font, $offset, $stringLength);
- $fmetric['name'] = preg_replace('/[^a-zA-Z0-9_\-]/', '', $fmetric['name']);
+ $fmetric['name'] = \substr($font, $offset, $stringLength);
+ $fmetric['name'] = \preg_replace('/[^a-zA-Z0-9_\-]/', '', $fmetric['name']);
break;
} else {
$offset += 4; // skip String length, String offset
@@ -907,9 +907,9 @@ class TCPDF_FONTS {
$pfile .= '\'MissingWidth\'=>'.$fmetric['MissingWidth'].'';
$pfile .= ');'."\n";
if (!empty($fmetric['cbbox'])) {
- $pfile .= '$cbbox=array('.substr($fmetric['cbbox'], 1).');'."\n";
+ $pfile .= '$cbbox=array('.\substr($fmetric['cbbox'], 1).');'."\n";
}
- $pfile .= '$cw=array('.substr($fmetric['cw'], 1).');'."\n";
+ $pfile .= '$cw=array('.\substr($fmetric['cw'], 1).');'."\n";
$pfile .= '// --- EOF ---'."\n";
// store file
$fp = TCPDF_STATIC::fopenLocal($outpath.$font_name.'.php', 'w');
@@ -933,7 +933,7 @@ class TCPDF_FONTS {
$tlen = ($length / 4);
$offset = 0;
for ($i = 0; $i < $tlen; ++$i) {
- $v = unpack('Ni', substr($table, $offset, 4));
+ $v = unpack('Ni', \substr($table, $offset, 4));
$sum += $v['i'];
$offset += 4;
}
@@ -969,7 +969,7 @@ class TCPDF_FONTS {
// for each table
for ($i = 0; $i < $numTables; ++$i) {
// get table info
- $tag = substr($font, $offset, 4);
+ $tag = \substr($font, $offset, 4);
$offset += 4;
$table[$tag] = array();
$table[$tag]['checkSum'] = TCPDF_STATIC::_getULONG($font, $offset);
@@ -1151,7 +1151,7 @@ class TCPDF_FONTS {
$subsetglyphs[$g] = true;
}
}
- }
+ }
break;
}
case 6: { // Format 6: Trimmed table mapping
@@ -1300,7 +1300,7 @@ class TCPDF_FONTS {
for ($i = 0; $i < $tot_num_glyphs; ++$i) {
if (isset($subsetglyphs[$i])) {
$length = ($indexToLoc[($i + 1)] - $indexToLoc[$i]);
- $glyf .= substr($font, ($glyf_offset + $indexToLoc[$i]), $length);
+ $glyf .= \substr($font, ($glyf_offset + $indexToLoc[$i]), $length);
} else {
$length = 0;
}
@@ -1318,10 +1318,10 @@ class TCPDF_FONTS {
$offset = 12;
foreach ($table as $tag => $val) {
if (in_array($tag, $table_names)) {
- $table[$tag]['data'] = substr($font, $table[$tag]['offset'], $table[$tag]['length']);
+ $table[$tag]['data'] = \substr($font, $table[$tag]['offset'], $table[$tag]['length']);
if ($tag == 'head') {
// set the checkSumAdjustment to 0
- $table[$tag]['data'] = substr($table[$tag]['data'], 0, 8)."\x0\x0\x0\x0".substr($table[$tag]['data'], 12);
+ $table[$tag]['data'] = \substr($table[$tag]['data'], 0, 8)."\x0\x0\x0\x0".\substr($table[$tag]['data'], 12);
}
$pad = 4 - ($table[$tag]['length'] % 4);
if ($pad != 4) {
@@ -1383,7 +1383,7 @@ class TCPDF_FONTS {
}
// set checkSumAdjustment on head table
$checkSumAdjustment = 0xB1B0AFBA - self::_getTTFtableChecksum($font, strlen($font));
- $font = substr($font, 0, $table['head']['offset'] + 8).pack('N', $checkSumAdjustment).substr($font, $table['head']['offset'] + 12);
+ $font = \substr($font, 0, $table['head']['offset'] + 8).pack('N', $checkSumAdjustment).\substr($font, $table['head']['offset'] + 12);
return $font;
}
@@ -1523,7 +1523,7 @@ class TCPDF_FONTS {
*/
public static function _getfontpath() {
if (!defined('K_PATH_FONTS') AND is_dir($fdir = realpath(dirname(__FILE__).'/../fonts'))) {
- if (substr($fdir, -1) != '/') {
+ if (\substr($fdir, -1) != '/') {
$fdir .= '/';
}
define('K_PATH_FONTS', $fdir);
@@ -2048,7 +2048,7 @@ class TCPDF_FONTS {
}
/**
- * Reverse the RLT substrings using the Bidirectional Algorithm (http://unicode.org/reports/tr9/).
+ * Reverse the RLT \substrings using the Bidirectional Algorithm (http://unicode.org/reports/tr9/).
* @param string $str string to manipulate.
* @param bool $setbom if true set the Byte Order Mark (BOM = 0xFEFF)
* @param bool $forcertl if true forces RTL text direction
@@ -2064,7 +2064,7 @@ class TCPDF_FONTS {
}
/**
- * Reverse the RLT substrings array using the Bidirectional Algorithm (http://unicode.org/reports/tr9/).
+ * Reverse the RLT \substrings array using the Bidirectional Algorithm (http://unicode.org/reports/tr9/).
* @param array $arr array of unicode values.
* @param string $str string to manipulate (or empty value).
* @param bool $setbom if true set the Byte Order Mark (BOM = 0xFEFF)
@@ -2081,7 +2081,7 @@ class TCPDF_FONTS {
}
/**
- * Reverse the RLT substrings using the Bidirectional Algorithm (http://unicode.org/reports/tr9/).
+ * Reverse the RLT \substrings using the Bidirectional Algorithm (http://unicode.org/reports/tr9/).
* @param array $ta array of characters composing the string.
* @param string $str string to process
* @param bool $forcertl if 'R' forces RTL, if 'L' forces LTR
diff --git a/tcpdf/include/tcpdf_static.php b/tcpdf/include/tcpdf_static.php
index ef96378..fff08eb 100755
--- a/tcpdf/include/tcpdf_static.php
+++ b/tcpdf/include/tcpdf_static.php
@@ -173,7 +173,7 @@ class TCPDF_STATIC {
if ($headers === false) {
return false;
}
- return (strpos($headers[0], '200') !== false);
+ return (\strpos($headers[0], '200') !== false);
}
/**
@@ -185,7 +185,7 @@ class TCPDF_STATIC {
*
HTML Entity (named): "­"
* How to type in Microsoft Windows: [Alt +00AD] or [Alt 0173]
* UTF-8 (hex): 0xC2 0xAD (c2ad)
- * UTF-8 character: chr(194).chr(173)
+ * UTF-8 character: \chr(194).\chr(173)
*
* @param string $txt input string
* @param boolean $unicode True if we are in unicode mode, false otherwise.
@@ -194,9 +194,9 @@ class TCPDF_STATIC {
* @public static
*/
public static function removeSHY($txt='', $unicode=true) {
- $txt = preg_replace('/([\\xc2]{1}[\\xad]{1})/', '', $txt);
+ $txt = \preg_replace('/([\\xc2]{1}[\\xad]{1})/', '', $txt);
if (!$unicode) {
- $txt = preg_replace('/([\\xad]{1})/', '', $txt);
+ $txt = \preg_replace('/([\\xad]{1})/', '', $txt);
}
return $txt;
}
@@ -220,8 +220,8 @@ class TCPDF_STATIC {
}
if (is_string($brd)) {
// convert string to array
- $slen = strlen($brd);
- $newbrd = array();
+ $slen = \strlen($brd);
+ $newbrd = [];
for ($i = 0; $i < $slen; ++$i) {
$newbrd[$brd[$i]] = array('cap' => 'square', 'join' => 'miter');
}
@@ -230,10 +230,10 @@ class TCPDF_STATIC {
foreach ($brd as $border => $style) {
switch ($position) {
case 'start': {
- if (strpos($border, 'B') !== false) {
+ if (\strpos($border, 'B') !== false) {
// remove bottom line
- $newkey = str_replace('B', '', $border);
- if (strlen($newkey) > 0) {
+ $newkey = \str_replace('B', '', $border);
+ if (\strlen($newkey) > 0) {
$brd[$newkey] = $style;
}
unset($brd[$border]);
@@ -241,19 +241,19 @@ class TCPDF_STATIC {
break;
}
case 'middle': {
- if (strpos($border, 'B') !== false) {
+ if (\strpos($border, 'B') !== false) {
// remove bottom line
- $newkey = str_replace('B', '', $border);
- if (strlen($newkey) > 0) {
+ $newkey = \str_replace('B', '', $border);
+ if (\strlen($newkey) > 0) {
$brd[$newkey] = $style;
}
unset($brd[$border]);
$border = $newkey;
}
- if (strpos($border, 'T') !== false) {
+ if (\strpos($border, 'T') !== false) {
// remove bottom line
- $newkey = str_replace('T', '', $border);
- if (strlen($newkey) > 0) {
+ $newkey = \str_replace('T', '', $border);
+ if (\strlen($newkey) > 0) {
$brd[$newkey] = $style;
}
unset($brd[$border]);
@@ -261,10 +261,10 @@ class TCPDF_STATIC {
break;
}
case 'end': {
- if (strpos($border, 'T') !== false) {
+ if (\strpos($border, 'T') !== false) {
// remove bottom line
- $newkey = str_replace('T', '', $border);
- if (strlen($newkey) > 0) {
+ $newkey = \str_replace('T', '', $border);
+ if (\strlen($newkey) > 0) {
$brd[$newkey] = $style;
}
unset($brd[$border]);
@@ -284,7 +284,7 @@ class TCPDF_STATIC {
* @public static
*/
public static function empty_string($str) {
- return (is_null($str) OR (is_string($str) AND (strlen($str) == 0)));
+ return (is_null($str) OR (is_string($str) AND (\strlen($str) == 0)));
}
/**
@@ -306,8 +306,8 @@ class TCPDF_STATIC {
* @public static
*/
public static function _escape($s) {
- // the chr(13) substitution fixes the Bugs item #1421290.
- return strtr($s, array(')' => '\\)', '(' => '\\(', '\\' => '\\\\', chr(13) => '\r'));
+ // the \chr(13) substitution fixes the Bugs item #1421290.
+ return strtr($s, array(')' => '\\)', '(' => '\\(', '\\' => '\\\\', \chr(13) => '\r'));
}
/**
@@ -364,8 +364,8 @@ class TCPDF_STATIC {
public static function replacePageNumAliases($page, $replace, $diff=0) {
foreach ($replace as $rep) {
foreach ($rep[3] as $a) {
- if (strpos($page, $a) !== false) {
- $page = str_replace($a, $rep[0], $page);
+ if (\strpos($page, $a) !== false) {
+ $page = \str_replace($a, $rep[0], $page);
$diff += ($rep[2] - $rep[1]);
}
}
@@ -383,9 +383,9 @@ class TCPDF_STATIC {
public static function getTimestamp($date) {
if (($date[0] == 'D') AND ($date[1] == ':')) {
// remove date prefix if present
- $date = substr($date, 2);
+ $date = \substr($date, 2);
}
- return strtotime($date);
+ return \strtotime($date);
}
/**
@@ -396,7 +396,7 @@ class TCPDF_STATIC {
* @public static
*/
public static function getFormattedDate($time) {
- return substr_replace(date('YmdHisO', intval($time)), '\'', (0 - 2), 0).'\'';
+ return \substr_replace(date('YmdHisO', \intval($time)), '\'', (0 - 2), 0).'\'';
}
/**
@@ -409,10 +409,10 @@ class TCPDF_STATIC {
*/
public static function getRandomSeed($seed='') {
$rnd = uniqid(rand().microtime(true), true);
- if (function_exists('posix_getpid')) {
+ if (\function_exists('posix_getpid')) {
$rnd .= posix_getpid();
}
- if (function_exists('openssl_random_pseudo_bytes') AND (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')) {
+ if (\function_exists('openssl_random_pseudo_bytes') AND (strtoupper(\substr(PHP_OS, 0, 3)) !== 'WIN')) {
// this is not used on windows systems because it is very slow for a know bug
$rnd .= openssl_random_pseudo_bytes(512);
} else {
@@ -446,11 +446,11 @@ class TCPDF_STATIC {
*/
public static function _AES($key, $text) {
// padding (RFC 2898, PKCS #5: Password-Based Cryptography Specification Version 2.0)
- $padding = 16 - (strlen($text) % 16);
- $text .= str_repeat(chr($padding), $padding);
+ $padding = 16 - (\strlen($text) % 16);
+ $text .= \str_repeat(\chr($padding), $padding);
if (extension_loaded('openssl')) {
$algo = 'aes-256-cbc';
- if (strlen($key) == 16) {
+ if (\strlen($key) == 16) {
$algo = 'aes-128-cbc';
}
$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($algo));
@@ -476,14 +476,14 @@ class TCPDF_STATIC {
public static function _AESnopad($key, $text) {
if (extension_loaded('openssl')) {
$algo = 'aes-256-cbc';
- if (strlen($key) == 16) {
+ if (\strlen($key) == 16) {
$algo = 'aes-128-cbc';
}
- $iv = str_repeat("\x00", openssl_cipher_iv_length($algo));
+ $iv = \str_repeat("\x00", openssl_cipher_iv_length($algo));
$text = openssl_encrypt($text, $algo, $key, OPENSSL_RAW_DATA, $iv);
- return substr($text, 0, -16);
+ return \substr($text, 0, -16);
}
- $iv = str_repeat("\x00", mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC));
+ $iv = \str_repeat("\x00", mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC));
$text = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $text, MCRYPT_MODE_CBC, $iv);
return $text;
}
@@ -501,17 +501,17 @@ class TCPDF_STATIC {
* @public static
*/
public static function _RC4($key, $text, &$last_enc_key, &$last_enc_key_c) {
- if (function_exists('mcrypt_encrypt') AND ($out = @mcrypt_encrypt(MCRYPT_ARCFOUR, $key, $text, MCRYPT_MODE_STREAM, ''))) {
+ if (\function_exists('mcrypt_encrypt') AND ($out = @mcrypt_encrypt(MCRYPT_ARCFOUR, $key, $text, MCRYPT_MODE_STREAM, ''))) {
// try to use mcrypt function if exist
return $out;
}
if ($last_enc_key != $key) {
- $k = str_repeat($key, (int) ((256 / strlen($key)) + 1));
+ $k = \str_repeat($key, (int) ((256 / \strlen($key)) + 1));
$rc4 = range(0, 255);
$j = 0;
for ($i = 0; $i < 256; ++$i) {
$t = $rc4[$i];
- $j = ($j + $t + ord($k[$i])) % 256;
+ $j = ($j + $t + \ord($k[$i])) % 256;
$rc4[$i] = $rc4[$j];
$rc4[$j] = $t;
}
@@ -520,7 +520,7 @@ class TCPDF_STATIC {
} else {
$rc4 = $last_enc_key_c;
}
- $len = strlen($text);
+ $len = \strlen($text);
$a = 0;
$b = 0;
$out = '';
@@ -531,7 +531,7 @@ class TCPDF_STATIC {
$rc4[$a] = $rc4[$b];
$rc4[$b] = $t;
$k = $rc4[($rc4[$a] + $rc4[$b]) % 256];
- $out .= chr(ord($text[$i]) ^ $k);
+ $out .= \chr(\ord($text[$i]) ^ $k);
}
return $out;
}
@@ -583,14 +583,14 @@ class TCPDF_STATIC {
*/
public static function convertHexStringToString($bs) {
$string = ''; // string to be returned
- $bslength = strlen($bs);
+ $bslength = \strlen($bs);
if (($bslength % 2) != 0) {
// padding
$bs .= '0';
++$bslength;
}
for ($i = 0; $i < $bslength; $i += 2) {
- $string .= chr(hexdec($bs[$i].$bs[($i + 1)]));
+ $string .= \chr(hexdec($bs[$i].$bs[($i + 1)]));
}
return $string;
}
@@ -605,9 +605,9 @@ class TCPDF_STATIC {
*/
public static function convertStringToHexString($s) {
$bs = '';
- $chars = preg_split('//', $s, -1, PREG_SPLIT_NO_EMPTY);
+ $chars = \preg_split('//', $s, -1, PREG_SPLIT_NO_EMPTY);
foreach ($chars as $c) {
- $bs .= sprintf('%02s', dechex(ord($c)));
+ $bs .= \sprintf('%02s', dechex(\ord($c)));
}
return $bs;
}
@@ -621,11 +621,11 @@ class TCPDF_STATIC {
* @public static
*/
public static function getEncPermissionsString($protection) {
- $binprot = sprintf('%032b', $protection);
- $str = chr(bindec(substr($binprot, 24, 8)));
- $str .= chr(bindec(substr($binprot, 16, 8)));
- $str .= chr(bindec(substr($binprot, 8, 8)));
- $str .= chr(bindec(substr($binprot, 0, 8)));
+ $binprot = \sprintf('%032b', $protection);
+ $str = \chr(bindec(\substr($binprot, 24, 8)));
+ $str .= \chr(bindec(\substr($binprot, 16, 8)));
+ $str .= \chr(bindec(\substr($binprot, 8, 8)));
+ $str .= \chr(bindec(\substr($binprot, 0, 8)));
return $str;
}
@@ -639,13 +639,13 @@ class TCPDF_STATIC {
*/
public static function encodeNameObject($name) {
$escname = '';
- $length = strlen($name);
+ $length = \strlen($name);
for ($i = 0; $i < $length; ++$i) {
$chr = $name[$i];
- if (preg_match('/[0-9a-zA-Z#_=-]/', $chr) == 1) {
+ if (\preg_match('/[0-9a-zA-Z#_=-]/', $chr) == 1) {
$escname .= $chr;
} else {
- $escname .= sprintf('#%02X', ord($chr));
+ $escname .= \sprintf('#%02X', \ord($chr));
}
}
return $escname;
@@ -662,11 +662,11 @@ class TCPDF_STATIC {
* @public static
*/
public static function getAnnotOptFromJSProp($prop, &$spot_colors, $rtl=false) {
- if (isset($prop['aopt']) AND is_array($prop['aopt'])) {
+ if (isset($prop['aopt']) AND \is_array($prop['aopt'])) {
// the annotation options are already defined
return $prop['aopt'];
}
- $opt = array(); // value to be returned
+ $opt = []; // value to be returned
// alignment: Controls how the text is laid out within the text field.
if (isset($prop['alignment'])) {
switch ($prop['alignment']) {
@@ -690,7 +690,7 @@ class TCPDF_STATIC {
}
// lineWidth: Specifies the thickness of the border when stroking the perimeter of a field's rectangle.
if (isset($prop['lineWidth'])) {
- $linewidth = intval($prop['lineWidth']);
+ $linewidth = \intval($prop['lineWidth']);
} else {
$linewidth = 1;
}
@@ -732,14 +732,14 @@ class TCPDF_STATIC {
}
}
}
- if (isset($prop['border']) AND is_array($prop['border'])) {
+ if (isset($prop['border']) AND \is_array($prop['border'])) {
$opt['border'] = $prop['border'];
}
if (!isset($opt['mk'])) {
- $opt['mk'] = array();
+ $opt['mk'] = [];
}
if (!isset($opt['mk']['if'])) {
- $opt['mk']['if'] = array();
+ $opt['mk']['if'] = [];
}
$opt['mk']['if']['a'] = array(0.5, 0.5);
// buttonAlignX: Controls how space is distributed from the left of the button face with respect to the icon.
@@ -830,7 +830,7 @@ class TCPDF_STATIC {
}
// fillColor: Specifies the background color for a field.
if (isset($prop['fillColor'])) {
- if (is_array($prop['fillColor'])) {
+ if (\is_array($prop['fillColor'])) {
$opt['mk']['bg'] = $prop['fillColor'];
} else {
$opt['mk']['bg'] = TCPDF_COLORS::convertHTMLColorToDec($prop['fillColor'], $spot_colors);
@@ -838,7 +838,7 @@ class TCPDF_STATIC {
}
// strokeColor: Specifies the stroke color for a field that is used to stroke the rectangle of the field with a line as large as the line width.
if (isset($prop['strokeColor'])) {
- if (is_array($prop['strokeColor'])) {
+ if (\is_array($prop['strokeColor'])) {
$opt['mk']['bc'] = $prop['strokeColor'];
} else {
$opt['mk']['bc'] = TCPDF_COLORS::convertHTMLColorToDec($prop['strokeColor'], $spot_colors);
@@ -850,7 +850,7 @@ class TCPDF_STATIC {
}
// charLimit: Limits the number of characters that a user can type into a text field.
if (isset($prop['charLimit'])) {
- $opt['maxlen'] = intval($prop['charLimit']);
+ $opt['maxlen'] = \intval($prop['charLimit']);
}
if (!isset($ff)) {
$ff = 0; // default value
@@ -951,13 +951,13 @@ class TCPDF_STATIC {
}
$opt['f'] = $f;
// currentValueIndices: Reads and writes single or multiple values of a list box or combo box.
- if (isset($prop['currentValueIndices']) AND is_array($prop['currentValueIndices'])) {
+ if (isset($prop['currentValueIndices']) AND \is_array($prop['currentValueIndices'])) {
$opt['i'] = $prop['currentValueIndices'];
}
// value: The value of the field data that the user has entered.
if (isset($prop['value'])) {
- if (is_array($prop['value'])) {
- $opt['opt'] = array();
+ if (\is_array($prop['value'])) {
+ $opt['opt'] = [];
foreach ($prop['value'] AS $key => $optval) {
// exportValues: An array of strings representing the export values for the field.
if (isset($prop['exportValues'][$key])) {
@@ -1055,30 +1055,30 @@ class TCPDF_STATIC {
*/
public static function extractCSSproperties($cssdata) {
if (empty($cssdata)) {
- return array();
+ return [];
}
// remove comments
- $cssdata = preg_replace('/\/\*[^\*]*\*\//', '', $cssdata);
+ $cssdata = \preg_replace('/\/\*[^\*]*\*\//', '', $cssdata);
// remove newlines and multiple spaces
- $cssdata = preg_replace('/[\s]+/', ' ', $cssdata);
+ $cssdata = \preg_replace('/[\s]+/', ' ', $cssdata);
// remove some spaces
- $cssdata = preg_replace('/[\s]*([;:\{\}]{1})[\s]*/', '\\1', $cssdata);
+ $cssdata = \preg_replace('/[\s]*([;:\{\}]{1})[\s]*/', '\\1', $cssdata);
// remove empty blocks
- $cssdata = preg_replace('/([^\}\{]+)\{\}/', '', $cssdata);
+ $cssdata = \preg_replace('/([^\}\{]+)\{\}/', '', $cssdata);
// replace media type parenthesis
- $cssdata = preg_replace('/@media[\s]+([^\{]*)\{/i', '@media \\1§', $cssdata);
- $cssdata = preg_replace('/\}\}/si', '}§', $cssdata);
+ $cssdata = \preg_replace('/@media[\s]+([^\{]*)\{/i', '@media \\1§', $cssdata);
+ $cssdata = \preg_replace('/\}\}/si', '}§', $cssdata);
// trim string
- $cssdata = trim($cssdata);
+ $cssdata = \trim($cssdata);
// find media blocks (all, braille, embossed, handheld, print, projection, screen, speech, tty, tv)
- $cssblocks = array();
- $matches = array();
- if (preg_match_all('/@media[\s]+([^\§]*)§([^§]*)§/i', $cssdata, $matches) > 0) {
+ $cssblocks = [];
+ $matches = [];
+ if (\preg_match_all('/@media[\s]+([^\§]*)§([^§]*)§/i', $cssdata, $matches) > 0) {
foreach ($matches[1] as $key => $type) {
$cssblocks[$type] = $matches[2][$key];
}
// remove media blocks
- $cssdata = preg_replace('/@media[\s]+([^\§]*)§([^§]*)§/i', '', $cssdata);
+ $cssdata = \preg_replace('/@media[\s]+([^\§]*)§([^§]*)§/i', '', $cssdata);
}
// keep 'all' and 'print' media, other media types are discarded
if (isset($cssblocks['all']) AND !empty($cssblocks['all'])) {
@@ -1088,17 +1088,17 @@ class TCPDF_STATIC {
$cssdata .= $cssblocks['print'];
}
// reset css blocks array
- $cssblocks = array();
- $matches = array();
+ $cssblocks = [];
+ $matches = [];
// explode css data string into array
- if (substr($cssdata, -1) == '}') {
+ if (\substr($cssdata, -1) == '}') {
// remove last parethesis
- $cssdata = substr($cssdata, 0, -1);
+ $cssdata = \substr($cssdata, 0, -1);
}
- $matches = explode('}', $cssdata);
+ $matches = \explode('}', $cssdata);
foreach ($matches as $key => $block) {
// index 0 contains the CSS selector, index 1 contains CSS properties
- $cssblocks[$key] = explode('{', $block);
+ $cssblocks[$key] = \explode('{', $block);
if (!isset($cssblocks[$key][1])) {
// remove empty definitions
unset($cssblocks[$key]);
@@ -1106,26 +1106,26 @@ class TCPDF_STATIC {
}
// split groups of selectors (comma-separated list of selectors)
foreach ($cssblocks as $key => $block) {
- if (strpos($block[0], ',') > 0) {
- $selectors = explode(',', $block[0]);
+ if (\strpos($block[0], ',') > 0) {
+ $selectors = \explode(',', $block[0]);
foreach ($selectors as $sel) {
- $cssblocks[] = array(0 => trim($sel), 1 => $block[1]);
+ $cssblocks[] = array(0 => \trim($sel), 1 => $block[1]);
}
unset($cssblocks[$key]);
}
}
// covert array to selector => properties
- $cssdata = array();
+ $cssdata = [];
foreach ($cssblocks as $block) {
$selector = $block[0];
// calculate selector's specificity
- $matches = array();
+ $matches = [];
$a = 0; // the declaration is not from is a 'style' attribute
- $b = intval(preg_match_all('/[\#]/', $selector, $matches)); // number of ID attributes
- $c = intval(preg_match_all('/[\[\.]/', $selector, $matches)); // number of other attributes
- $c += intval(preg_match_all('/[\:]link|visited|hover|active|focus|target|lang|enabled|disabled|checked|indeterminate|root|nth|first|last|only|empty|contains|not/i', $selector, $matches)); // number of pseudo-classes
- $d = intval(preg_match_all('/[\>\+\~\s]{1}[a-zA-Z0-9]+/', ' '.$selector, $matches)); // number of element names
- $d += intval(preg_match_all('/[\:][\:]/', $selector, $matches)); // number of pseudo-elements
+ $b = \intval(\preg_match_all('/[\#]/', $selector, $matches)); // number of ID attributes
+ $c = \intval(\preg_match_all('/[\[\.]/', $selector, $matches)); // number of other attributes
+ $c += \intval(\preg_match_all('/[\:]link|visited|hover|active|focus|target|lang|enabled|disabled|checked|indeterminate|root|nth|first|last|only|empty|contains|not/i', $selector, $matches)); // number of pseudo-classes
+ $d = \intval(\preg_match_all('/[\>\+\~\s]{1}[a-zA-Z0-9]+/', ' '.$selector, $matches)); // number of element names
+ $d += \intval(\preg_match_all('/[\:][\:]/', $selector, $matches)); // number of pseudo-elements
$specificity = $a.$b.$c.$d;
// add specificity to the beginning of the selector
$cssdata[$specificity.' '.$selector] = $block[1];
@@ -1178,13 +1178,13 @@ class TCPDF_STATIC {
// get the CSS part
$tidy_head = tidy_get_head($tidy);
$css = $tidy_head->value;
- $css = preg_replace('/