2
0
forked from Wavyzz/dolibarr

Fixing style errors.

This commit is contained in:
stickler-ci
2019-11-02 23:53:11 +00:00
parent d797ea590e
commit c2d66a9e64
11 changed files with 109 additions and 109 deletions

View File

@@ -3,7 +3,7 @@
* Users who do not have 'composer' to manage dependencies, include this * Users who do not have 'composer' to manage dependencies, include this
* file to provide auto-loading of the classes in this library. * file to provide auto-loading of the classes in this library.
*/ */
spl_autoload_register ( function ($class) { spl_autoload_register( function ($class) {
/* /*
* PSR-4 autoloader, based on PHP Framework Interop Group snippet (Under MIT License.) * PSR-4 autoloader, based on PHP Framework Interop Group snippet (Under MIT License.)
* https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader-examples.md * https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader-examples.md
@@ -12,15 +12,15 @@ spl_autoload_register ( function ($class) {
$base_dir = __DIR__ . "/src/Mike42/"; $base_dir = __DIR__ . "/src/Mike42/";
/* Only continue for classes in this namespace */ /* Only continue for classes in this namespace */
$len = strlen ( $prefix ); $len = strlen($prefix);
if (strncmp ( $prefix, $class, $len ) !== 0) { if (strncmp($prefix, $class, $len) !== 0) {
return; return;
} }
/* Require the file if it exists */ /* Require the file if it exists */
$relative_class = substr ( $class, $len ); $relative_class = substr($class, $len);
$file = $base_dir . str_replace ( '\\', '/', $relative_class ) . '.php'; $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
if (file_exists ( $file )) { if (file_exists($file)) {
require $file; require $file;
} }
} ); } );

View File

@@ -85,8 +85,8 @@ abstract class EscposImage
* *
* @param string $filename Path to image filename, or null to create an empty image. * @param string $filename Path to image filename, or null to create an empty image.
* @param boolean $allowOptimisations True (default) to use any library-specific tricks * @param boolean $allowOptimisations True (default) to use any library-specific tricks
* to speed up rendering, false to force the image to be read in pixel-by-pixel, * to speed up rendering, false to force the image to be read in pixel-by-pixel,
* which is easier to unit test and more reproducible between systems, but slower. * which is easier to unit test and more reproducible between systems, but slower.
*/ */
public function __construct($filename = null, $allowOptimisations = true) public function __construct($filename = null, $allowOptimisations = true)
{ {
@@ -107,7 +107,7 @@ abstract class EscposImage
*/ */
public function getHeightBytes() public function getHeightBytes()
{ {
return (int)(($this -> imgHeight + 7) / 8); return (int) (($this -> imgHeight + 7) / 8);
} }
/** /**
@@ -123,7 +123,7 @@ abstract class EscposImage
*/ */
public function getWidthBytes() public function getWidthBytes()
{ {
return (int)(($this -> imgWidth + 7) / 8); return (int) (($this -> imgWidth + 7) / 8);
} }
/** /**
@@ -279,7 +279,7 @@ abstract class EscposImage
return $data; return $data;
} }
do { do {
$byteVal |= (int)$this -> imgData[$y * $widthPixels + $x] << (7 - $bit); $byteVal |= (int) $this -> imgData[$y * $widthPixels + $x] << (7 - $bit);
$x++; $x++;
$bit++; $bit++;
if ($x >= $widthPixels) { if ($x >= $widthPixels) {
@@ -356,7 +356,7 @@ abstract class EscposImage
do { do {
$yReal = $y + $yStart; $yReal = $y + $yStart;
if ($yReal < $heightPixels) { if ($yReal < $heightPixels) {
$byteVal |= (int)$this -> imgData[$yReal * $widthPixels + $x] << (7 - $bit); $byteVal |= (int) $this -> imgData[$yReal * $widthPixels + $x] << (7 - $bit);
} }
$y++; $y++;
$bit++; $bit++;

View File

@@ -73,7 +73,7 @@ class GdEscposImage extends EscposImage
/* Faster to average channels, blend alpha and negate the image here than via filters (tested!) */ /* Faster to average channels, blend alpha and negate the image here than via filters (tested!) */
$cols = imagecolorsforindex($im, imagecolorat($im, $x, $y)); $cols = imagecolorsforindex($im, imagecolorat($im, $x, $y));
// 1 for white, 0 for black, ignoring transparency // 1 for white, 0 for black, ignoring transparency
$greyness = (int)(($cols['red'] + $cols['green'] + $cols['blue']) / 3) >> 7; $greyness = (int) (($cols['red'] + $cols['green'] + $cols['blue']) / 3) >> 7;
// 1 for black, 0 for white, taking into account transparency // 1 for black, 0 for white, taking into account transparency
$black = (1 - $greyness) >> ($cols['alpha'] >> 6); $black = (1 - $greyness) >> ($cols['alpha'] >> 6);
$imgData[$y * $imgWidth + $x] = $black; $imgData[$y * $imgWidth + $x] = $black;

View File

@@ -44,7 +44,7 @@ class ImagickEscposImage extends EscposImage
/* Faster to average channels, blend alpha and negate the image here than via filters (tested!) */ /* Faster to average channels, blend alpha and negate the image here than via filters (tested!) */
$cols = $im -> getImagePixelColor($x, $y); $cols = $im -> getImagePixelColor($x, $y);
$cols = $cols -> getcolor(); $cols = $cols -> getcolor();
$greyness = (int)(($cols['r'] + $cols['g'] + $cols['b']) / 3) >> 7; // 1 for white, 0 for black $greyness = (int) (($cols['r'] + $cols['g'] + $cols['b']) / 3) >> 7; // 1 for white, 0 for black
$imgData[$y * $imgWidth + $x] = (1 - $greyness); // 1 for black, 0 for white $imgData[$y * $imgWidth + $x] = (1 - $greyness); // 1 for black, 0 for white
} }
} }

View File

@@ -136,7 +136,7 @@ class EscposPrintBuffer implements PrintBuffer
if ($c == "\r") { if ($c == "\r") {
/* Skip past Windows line endings (raw usage). */ /* Skip past Windows line endings (raw usage). */
continue; continue;
} else if (self::asciiCheck($c, true)) { } elseif (self::asciiCheck($c, true)) {
$outp[$j] = $c; $outp[$j] = $c;
} }
$j++; $j++;

View File

@@ -380,12 +380,12 @@ class Printer
* *
* @param string $content The information to encode. * @param string $content The information to encode.
* @param int $type The barcode standard to output. Supported values are * @param int $type The barcode standard to output. Supported values are
* `Printer::BARCODE_UPCA`, `Printer::BARCODE_UPCE`, `Printer::BARCODE_JAN13`, * `Printer::BARCODE_UPCA`, `Printer::BARCODE_UPCE`, `Printer::BARCODE_JAN13`,
* `Printer::BARCODE_JAN8`, `Printer::BARCODE_CODE39`, `Printer::BARCODE_ITF`, * `Printer::BARCODE_JAN8`, `Printer::BARCODE_CODE39`, `Printer::BARCODE_ITF`,
* `Printer::BARCODE_CODABAR`, `Printer::BARCODE_CODE93`, and `Printer::BARCODE_CODE128`. * `Printer::BARCODE_CODABAR`, `Printer::BARCODE_CODE93`, and `Printer::BARCODE_CODE128`.
* If not specified, `Printer::BARCODE_CODE39` will be used. Note that some * If not specified, `Printer::BARCODE_CODE39` will be used. Note that some
* barcode formats only support specific lengths or sets of characters, and that * barcode formats only support specific lengths or sets of characters, and that
* available barcode types vary between printers. * available barcode types vary between printers.
* @throws InvalidArgumentException Where the length or characters used in $content is invalid for the requested barcode format. * @throws InvalidArgumentException Where the length or characters used in $content is invalid for the requested barcode format.
*/ */
public function barcode($content, $type = Printer::BARCODE_CODE39) public function barcode($content, $type = Printer::BARCODE_CODE39)
@@ -451,8 +451,8 @@ class Printer
* *
* @param EscposImage $img The image to print * @param EscposImage $img The image to print
* @param int $size Size modifier for the image. Must be either `Printer::IMG_DEFAULT` * @param int $size Size modifier for the image. Must be either `Printer::IMG_DEFAULT`
* (default), or any combination of the `Printer::IMG_DOUBLE_HEIGHT` and * (default), or any combination of the `Printer::IMG_DOUBLE_HEIGHT` and
* `Printer::IMG_DOUBLE_WIDTH` flags. * `Printer::IMG_DOUBLE_WIDTH` flags.
*/ */
public function bitImage(EscposImage $img, $size = Printer::IMG_DEFAULT) public function bitImage(EscposImage $img, $size = Printer::IMG_DEFAULT)
{ {
@@ -471,8 +471,8 @@ class Printer
* *
* @param EscposImage $img The image to print * @param EscposImage $img The image to print
* @param int $size Size modifier for the image. Must be either `Printer::IMG_DEFAULT` * @param int $size Size modifier for the image. Must be either `Printer::IMG_DEFAULT`
* (default), or any combination of the `Printer::IMG_DOUBLE_HEIGHT` and * (default), or any combination of the `Printer::IMG_DOUBLE_HEIGHT` and
* `Printer::IMG_DOUBLE_WIDTH` flags. * `Printer::IMG_DOUBLE_WIDTH` flags.
*/ */
public function bitImageColumnFormat(EscposImage $img, $size = Printer::IMG_DEFAULT) public function bitImageColumnFormat(EscposImage $img, $size = Printer::IMG_DEFAULT)
{ {
@@ -606,8 +606,8 @@ class Printer
* *
* @param EscposImage $img The image to print. * @param EscposImage $img The image to print.
* @param int $size Size modifier for the image. Must be either `Printer::IMG_DEFAULT` * @param int $size Size modifier for the image. Must be either `Printer::IMG_DEFAULT`
* (default), or any combination of the `Printer::IMG_DOUBLE_HEIGHT` and * (default), or any combination of the `Printer::IMG_DOUBLE_HEIGHT` and
* `Printer::IMG_DOUBLE_WIDTH` flags. * `Printer::IMG_DOUBLE_WIDTH` flags.
*/ */
public function graphics(EscposImage $img, $size = Printer::IMG_DEFAULT) public function graphics(EscposImage $img, $size = Printer::IMG_DEFAULT)
{ {
@@ -637,15 +637,15 @@ class Printer
* *
* @param string $content Text or numbers to store in the code * @param string $content Text or numbers to store in the code
* @param int $width Width of a module (pixel) in the printed code. * @param int $width Width of a module (pixel) in the printed code.
* Default is 3 dots. * Default is 3 dots.
* @param int $heightMultiplier Multiplier for height of a module. * @param int $heightMultiplier Multiplier for height of a module.
* Default is 3 times the width. * Default is 3 times the width.
* @param int $dataColumnCount Number of data columns to use. 0 (default) * @param int $dataColumnCount Number of data columns to use. 0 (default)
* is to auto-calculate. Smaller numbers will result in a narrower code, * is to auto-calculate. Smaller numbers will result in a narrower code,
* making larger pixel sizes possible. Larger numbers require smaller pixel sizes. * making larger pixel sizes possible. Larger numbers require smaller pixel sizes.
* @param float $ec Error correction ratio, from 0.01 to 4.00. Default is 0.10 (10%). * @param float $ec Error correction ratio, from 0.01 to 4.00. Default is 0.10 (10%).
* @param int $options Standard code Printer::PDF417_STANDARD with * @param int $options Standard code Printer::PDF417_STANDARD with
* start/end bars, or truncated code Printer::PDF417_TRUNCATED with start bars only. * start/end bars, or truncated code Printer::PDF417_TRUNCATED with start bars only.
* @throws Exception If this profile indicates that PDF417 code is not supported * @throws Exception If this profile indicates that PDF417 code is not supported
*/ */
public function pdf417Code($content, $width = 3, $heightMultiplier = 3, $dataColumnCount = 0, $ec = 0.10, $options = Printer::PDF417_STANDARD) public function pdf417Code($content, $width = 3, $heightMultiplier = 3, $dataColumnCount = 0, $ec = 0.10, $options = Printer::PDF417_STANDARD)
@@ -672,7 +672,7 @@ class Printer
$this -> wrapperSend2dCodeData(chr(67), $cn, chr($width)); $this -> wrapperSend2dCodeData(chr(67), $cn, chr($width));
$this -> wrapperSend2dCodeData(chr(68), $cn, chr($heightMultiplier)); $this -> wrapperSend2dCodeData(chr(68), $cn, chr($heightMultiplier));
// Set error correction ratio: 1% to 400% // Set error correction ratio: 1% to 400%
$ec_int = (int)ceil(floatval($ec) * 10); $ec_int = (int) ceil(floatval($ec) * 10);
$this -> wrapperSend2dCodeData(chr(69), $cn, chr($ec_int), '1'); $this -> wrapperSend2dCodeData(chr(69), $cn, chr($ec_int), '1');
// Send content & print // Send content & print
$this -> wrapperSend2dCodeData(chr(80), $cn, $content, '0'); $this -> wrapperSend2dCodeData(chr(80), $cn, $content, '0');
@@ -788,7 +788,7 @@ class Printer
* Set barcode bar width. * Set barcode bar width.
* *
* @param int $width Bar width in dots. If not specified, 3 will be used. * @param int $width Bar width in dots. If not specified, 3 will be used.
* Values above 6 appear to have no effect. * Values above 6 appear to have no effect.
*/ */
public function setBarcodeWidth($width = 3) public function setBarcodeWidth($width = 3)
{ {
@@ -800,8 +800,8 @@ class Printer
* Set the position for the Human Readable Interpretation (HRI) of barcode characters. * Set the position for the Human Readable Interpretation (HRI) of barcode characters.
* *
* @param int $position. Use Printer::BARCODE_TEXT_NONE to hide the text (default), * @param int $position. Use Printer::BARCODE_TEXT_NONE to hide the text (default),
* or any combination of Printer::BARCODE_TEXT_ABOVE and Printer::BARCODE_TEXT_BELOW * or any combination of Printer::BARCODE_TEXT_ABOVE and Printer::BARCODE_TEXT_BELOW
* flags to display the text. * flags to display the text.
*/ */
public function setBarcodeTextPosition($position = Printer::BARCODE_TEXT_NONE) public function setBarcodeTextPosition($position = Printer::BARCODE_TEXT_NONE)
{ {
@@ -870,7 +870,7 @@ class Printer
* Some printers will allow you to overlap lines with a smaller line feed. * Some printers will allow you to overlap lines with a smaller line feed.
* *
* @param int|null $height The height of each line, in dots. If not set, the printer * @param int|null $height The height of each line, in dots. If not set, the printer
* will reset to its default line spacing. * will reset to its default line spacing.
*/ */
public function setLineSpacing($height = null) public function setLineSpacing($height = null)
{ {
@@ -995,7 +995,7 @@ class Printer
public function text($str = "") public function text($str = "")
{ {
self::validateString($str, __FUNCTION__); self::validateString($str, __FUNCTION__);
$this -> buffer -> writeText((string)$str); $this -> buffer -> writeText((string) $str);
} }
/** /**
@@ -1010,7 +1010,7 @@ class Printer
self::validateString($str, __FUNCTION__); self::validateString($str, __FUNCTION__);
$this -> connector -> write(self::FS . "&"); $this -> connector -> write(self::FS . "&");
$str = iconv("UTF-8", "GBK//IGNORE", $str); $str = iconv("UTF-8", "GBK//IGNORE", $str);
$this -> buffer -> writeTextRaw((string)$str); $this -> buffer -> writeTextRaw((string) $str);
$this -> connector -> write(self::FS . "."); $this -> connector -> write(self::FS . ".");
} }
@@ -1025,7 +1025,7 @@ class Printer
public function textRaw($str = "") public function textRaw($str = "")
{ {
self::validateString($str, __FUNCTION__); self::validateString($str, __FUNCTION__);
$this -> buffer -> writeTextRaw((string)$str); $this -> buffer -> writeTextRaw((string) $str);
} }
/** /**
@@ -1098,7 +1098,7 @@ class Printer
$outp = ""; $outp = "";
for ($i = 0; $i < $length; $i++) { for ($i = 0; $i < $length; $i++) {
$outp .= chr($input % 256); $outp .= chr($input % 256);
$input = (int)($input / 256); $input = (int) ($input / 256);
} }
return $outp; return $outp;
} }