Skip to content

Commit

Permalink
PHP error fixes and final phpdoc fixes (tecnickcom#348)
Browse files Browse the repository at this point in the history
* Fix a PHP array offset error

* Fix PHP 8.1 type error with TCPDF_STATIC::pregSplit on preg_split

* More phpdoc blocks fixes

* Add CHANGELOG entries

* Update file descriptions for barcode examples

Co-authored-by: Nicola Asuni <[email protected]>
  • Loading branch information
williamdes and nicolaasuni authored Apr 2, 2021
1 parent 989a00f commit c979d00
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 30 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.TXT
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@

6.4.2 (2021-04-02)
- Fix PHP 8.1 type error with TCPDF_STATIC::pregSplit on preg_split
- Fix a PHP array offset error
- Fixed phpdoc blocks
- Drop a PHP 4 polyfill and add a .gitattributes file

6.4.1 (2021-03-27)
- Update tcpdf version (no code changes)

Expand Down
4 changes: 2 additions & 2 deletions examples/barcodes/example_1d_html.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
// See LICENSE.TXT file for more information.
// -------------------------------------------------------------------
//
// Description : Example for tcpdf_barcodes_2d.php class
// Description : Example for tcpdf_barcodes_1d.php class
//
//============================================================+

/**
* @file
* Example for tcpdf_barcodes_2d.php class
* Example for tcpdf_barcodes_1d.php class
* @package com.tecnick.tcpdf
* @author Nicola Asuni
* @version 1.0.000
Expand Down
4 changes: 2 additions & 2 deletions examples/barcodes/example_1d_png.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
// See LICENSE.TXT file for more information.
// -------------------------------------------------------------------
//
// Description : Example for tcpdf_barcodes_2d.php class
// Description : Example for tcpdf_barcodes_1d.php class
//
//============================================================+

/**
* @file
* Example for tcpdf_barcodes_2d.php class
* Example for tcpdf_barcodes_1d.php class
* @package com.tecnick.tcpdf
* @author Nicola Asuni
* @version 1.0.000
Expand Down
4 changes: 2 additions & 2 deletions examples/barcodes/example_1d_svg.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
// See LICENSE.TXT file for more information.
// -------------------------------------------------------------------
//
// Description : Example for tcpdf_barcodes_2d.php class
// Description : Example for tcpdf_barcodes_1d.php class
//
//============================================================+

/**
* @file
* Example for tcpdf_barcodes_2d.php class
* Example for tcpdf_barcodes_1d.php class
* @package com.tecnick.tcpdf
* @author Nicola Asuni
* @version 1.0.000
Expand Down
4 changes: 2 additions & 2 deletions examples/barcodes/example_1d_svgi.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
// See LICENSE.TXT file for more information.
// -------------------------------------------------------------------
//
// Description : Example for tcpdf_barcodes_2d.php class
// Description : Example for tcpdf_barcodes_1d.php class
//
//============================================================+

/**
* @file
* Example for tcpdf_barcodes_2d.php class
* Example for tcpdf_barcodes_1d.php class
* @package com.tecnick.tcpdf
* @author Nicola Asuni
* @version 1.0.000
Expand Down
8 changes: 4 additions & 4 deletions include/barcodes/qrcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -2449,7 +2449,7 @@ protected function putAlignmentPattern($version, $frame, $width) {
/**
* Return BCH encoded version information pattern that is used for the symbol of version 7 or greater. Use lower 18 bits.
* @param int $version version
* @return BCH encoded version information pattern
* @return string BCH encoded version information pattern
*/
protected function getVersionPattern($version) {
if (($version < 7) OR ($version > QRSPEC_VERSION_MAX)) {
Expand All @@ -2462,7 +2462,7 @@ protected function getVersionPattern($version) {
* Return BCH encoded format information pattern.
* @param array $mask
* @param int $level error correction level
* @return BCH encoded format information pattern
* @return string BCH encoded format information pattern
*/
protected function getFormatInfo($mask, $level) {
if (($mask < 0) OR ($mask > 7)) {
Expand Down Expand Up @@ -2500,7 +2500,7 @@ protected function putFinderPattern($frame, $ox, $oy) {
/**
* Return a copy of initialized frame.
* @param int $version version
* @return Array of unsigned char.
* @return array array of unsigned char.
*/
protected function createFrame($version) {
$width = $this->capacity[$version][QRCAP_WIDTH];
Expand Down Expand Up @@ -2565,7 +2565,7 @@ protected function createFrame($version) {
/**
* Set new frame for the specified version.
* @param int $version version
* @return Array of unsigned char.
* @return array array of unsigned char.
*/
protected function newFrame($version) {
if (($version < 1) OR ($version > QRSPEC_VERSION_MAX)) {
Expand Down
22 changes: 11 additions & 11 deletions include/tcpdf_filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static function getAvailableFilters() {
* Decode data using the specified filter type.
* @param string $filter Filter name.
* @param string $data Data to decode.
* @return Decoded data string.
* @return string Decoded data string.
* @since 1.0.000 (2011-05-23)
* @public static
*/
Expand Down Expand Up @@ -131,7 +131,7 @@ public static function decodeFilter($filter, $data) {
* Standard
* Default decoding filter (leaves data unchanged).
* @param string $data Data to decode.
* @return Decoded data string.
* @return string Decoded data string.
* @since 1.0.000 (2011-05-23)
* @public static
*/
Expand All @@ -143,7 +143,7 @@ public static function decodeFilterStandard($data) {
* ASCIIHexDecode
* Decodes data encoded in an ASCII hexadecimal representation, reproducing the original binary data.
* @param string $data Data to decode.
* @return Decoded data string.
* @return string Decoded data string.
* @since 1.0.000 (2011-05-23)
* @public static
*/
Expand Down Expand Up @@ -183,7 +183,7 @@ public static function decodeFilterASCIIHexDecode($data) {
* ASCII85Decode
* Decodes data encoded in an ASCII base-85 representation, reproducing the original binary data.
* @param string $data Data to decode.
* @return Decoded data string.
* @return string Decoded data string.
* @since 1.0.000 (2011-05-23)
* @public static
*/
Expand Down Expand Up @@ -267,7 +267,7 @@ public static function decodeFilterASCII85Decode($data) {
* LZWDecode
* Decompresses data encoded using the LZW (Lempel-Ziv-Welch) adaptive compression method, reproducing the original text or binary data.
* @param string $data Data to decode.
* @return Decoded data string.
* @return string Decoded data string.
* @since 1.0.000 (2011-05-23)
* @public static
*/
Expand Down Expand Up @@ -348,7 +348,7 @@ public static function decodeFilterLZWDecode($data) {
* FlateDecode
* Decompresses data encoded using the zlib/deflate compression method, reproducing the original text or binary data.
* @param string $data Data to decode.
* @return Decoded data string.
* @return string Decoded data string.
* @since 1.0.000 (2011-05-23)
* @public static
*/
Expand Down Expand Up @@ -401,7 +401,7 @@ public static function decodeFilterRunLengthDecode($data) {
* CCITTFaxDecode (NOT IMPLEMETED - RETURN AN EXCEPTION)
* Decompresses data encoded using the CCITT facsimile standard, reproducing the original data (typically monochrome image data at 1 bit per pixel).
* @param string $data Data to decode.
* @return Decoded data string.
* @return string Decoded data string.
* @since 1.0.000 (2011-05-23)
* @public static
*/
Expand All @@ -414,7 +414,7 @@ public static function decodeFilterCCITTFaxDecode($data) {
* JBIG2Decode (NOT IMPLEMETED - RETURN AN EXCEPTION)
* Decompresses data encoded using the JBIG2 standard, reproducing the original monochrome (1 bit per pixel) image data (or an approximation of that data).
* @param string $data Data to decode.
* @return Decoded data string.
* @return string Decoded data string.
* @since 1.0.000 (2011-05-23)
* @public static
*/
Expand All @@ -427,7 +427,7 @@ public static function decodeFilterJBIG2Decode($data) {
* DCTDecode (NOT IMPLEMETED - RETURN AN EXCEPTION)
* Decompresses data encoded using a DCT (discrete cosine transform) technique based on the JPEG standard, reproducing image sample data that approximates the original data.
* @param string $data Data to decode.
* @return Decoded data string.
* @return string Decoded data string.
* @since 1.0.000 (2011-05-23)
* @public static
*/
Expand All @@ -440,7 +440,7 @@ public static function decodeFilterDCTDecode($data) {
* JPXDecode (NOT IMPLEMETED - RETURN AN EXCEPTION)
* Decompresses data encoded using the wavelet-based JPEG2000 standard, reproducing the original image data.
* @param string $data Data to decode.
* @return Decoded data string.
* @return string Decoded data string.
* @since 1.0.000 (2011-05-23)
* @public static
*/
Expand All @@ -453,7 +453,7 @@ public static function decodeFilterJPXDecode($data) {
* Crypt (NOT IMPLEMETED - RETURN AN EXCEPTION)
* Decrypts data encrypted by a security handler, reproducing the data as it was before encryption.
* @param string $data Data to decode.
* @return Decoded data string.
* @return string Decoded data string.
* @since 1.0.000 (2011-05-23)
* @public static
*/
Expand Down
8 changes: 7 additions & 1 deletion include/tcpdf_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,15 @@ public static function get_mqr() {
/**
* Check if the URL exist.
* @param string $url URL to check.
* @return Boolean true if the URl exist, false otherwise.
* @return boolean true if the URl exist, false otherwise.
* @since 5.9.204 (2013-01-28)
* @public static
*/
public static function isValidURL($url) {
$headers = @get_headers($url);
if ($headers === false) {
return false;
}
return (strpos($headers[0], '200') !== false);
}

Expand Down Expand Up @@ -1795,6 +1798,9 @@ public static function getVectorsAngle($x1, $y1, $x2, $y2) {
* @public static
*/
public static function pregSplit($pattern, $modifiers, $subject, $limit=NULL, $flags=NULL) {
// PHP 8.1 deprecates nulls for $limit and $flags
$limit = $limit === null ? -1 : $limit;
$flags = $flags === null ? 0 : $flags;
// the bug only happens on PHP 5.2 when using the u modifier
if ((strpos($modifiers, 'u') === FALSE) OR (count(preg_split('//u', "\n\t", -1, PREG_SPLIT_NO_EMPTY)) == 2)) {
return preg_split($pattern.$modifiers, $subject, $limit, $flags);
Expand Down
6 changes: 3 additions & 3 deletions tcpdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -2366,8 +2366,8 @@ public function setSpacesRE($re='/[^\S\xa0]/') {

/**
* Enable or disable Right-To-Left language mode
* @param Boolean $enable if true enable Right-To-Left language mode.
* @param Boolean $resetx if true reset the X position on direction change.
* @param boolean $enable if true enable Right-To-Left language mode.
* @param boolean $resetx if true reset the X position on direction change.
* @public
* @since 2.0.000 (2008-01-03)
*/
Expand Down Expand Up @@ -22086,7 +22086,7 @@ public function setTextShadow($params=array('enabled'=>false, 'depth_w'=>0, 'dep

/**
* Return the text shadow parameters array.
* @return Array of parameters.
* @return array array of parameters.
* @since 5.9.174 (2012-07-25)
* @public
*/
Expand Down
6 changes: 3 additions & 3 deletions tcpdf_parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public function getParsedData() {
* Get Cross-Reference (xref) table and trailer data from PDF document data.
* @param int $offset xref offset (if know).
* @param array $xref previous xref array (if any).
* @return Array containing xref and trailer data.
* @return array containing xref and trailer data.
* @protected
* @since 1.0.000 (2011-05-24)
*/
Expand Down Expand Up @@ -204,7 +204,7 @@ protected function getXrefData($offset=0, $xref=array()) {
* Decode the Cross-Reference section
* @param int $startxref Offset at which the xref section starts (position of the 'xref' keyword).
* @param array $xref Previous xref array (if any).
* @return Array containing xref and trailer data.
* @return array containing xref and trailer data.
* @protected
* @since 1.0.000 (2011-06-20)
*/
Expand Down Expand Up @@ -276,7 +276,7 @@ protected function decodeXref($startxref, $xref=array()) {
* Decode the Cross-Reference Stream section
* @param int $startxref Offset at which the xref section starts.
* @param array $xref Previous xref array (if any).
* @return Array containing xref and trailer data.
* @return array containing xref and trailer data.
* @protected
* @since 1.0.003 (2013-03-16)
*/
Expand Down

0 comments on commit c979d00

Please sign in to comment.