Skip to content

Commit

Permalink
Update files to PSR12 and fix deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaasuni committed Oct 9, 2023
1 parent df0474a commit a8b0cfc
Show file tree
Hide file tree
Showing 24 changed files with 156 additions and 177 deletions.
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Ref: https://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style end of lines and a blank line at the end of the file
[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.php]
indent_style = space
indent_size = 4

[*.{js,json,scss,css,yml,vue}]
indent_style = space
indent_size = 2
62 changes: 0 additions & 62 deletions .travis.yml

This file was deleted.

6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ clean:
# Fix code style violations
.PHONY: codefix
codefix:
./vendor/bin/phpcbf --ignore="./vendor/" --standard=psr2 src test
./vendor/bin/phpcbf --ignore="./vendor/" --standard=psr12 src test

# Build a DEB package for Debian-like Linux distributions
.PHONY: deb
Expand Down Expand Up @@ -202,7 +202,7 @@ endif
# Test source code for coding standard violations
.PHONY: lint
lint:
./vendor/bin/phpcs --ignore="./vendor/" --standard=psr2 src test
./vendor/bin/phpcs --ignore="./vendor/" --standard=phpcs.xml src test
./vendor/bin/phpmd src text codesize,unusedcode,naming,design --exclude vendor
./vendor/bin/phpmd test text unusedcode,naming,design

Expand All @@ -213,8 +213,6 @@ qa: ensuretarget lint test report
# Generate various reports
.PHONY: report
report: ensuretarget
./vendor/bin/phpcpd src --exclude vendor > $(TARGETDIR)/report/phpcpd.txt
./vendor/bin/phploc src --exclude vendor > $(TARGETDIR)/report/phploc.txt
./vendor/bin/pdepend --jdepend-xml=$(TARGETDIR)/report/dependencies.xml --summary-xml=$(TARGETDIR)/report/metrics.xml --jdepend-chart=$(TARGETDIR)/report/dependecies.svg --overview-pyramid=$(TARGETDIR)/report/overview-pyramid.svg --ignore=vendor ./src
#./vendor/bartlett/php-compatinfo/bin/phpcompatinfo --no-ansi analyser:run src/ > $(TARGETDIR)/report/phpcompatinfo.txt

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
*PHP library containing PDF page formats and definitions*

[![Latest Stable Version](https://poser.pugx.org/tecnickcom/tc-lib-pdf-page/version)](https://packagist.org/packages/tecnickcom/tc-lib-pdf-page)
[![Master Build Status](https://secure.travis-ci.org/tecnickcom/tc-lib-pdf-page.png?branch=main)](https://travis-ci.org/tecnickcom/tc-lib-pdf-page?branch=main)
[![Master Coverage Status](https://coveralls.io/repos/tecnickcom/tc-lib-pdf-page/badge.svg?branch=main&service=github)](https://coveralls.io/github/tecnickcom/tc-lib-pdf-page?branch=main)
![Build](https://github.com/tecnickcom/tc-lib-pdf-page/actions/workflows/check.yml/badge.svg)
[![Coverage](https://coveralls.io/repos/tecnickcom/tc-lib-pdf-page/badge.svg?branch=main&service=github)](https://coveralls.io/github/tecnickcom/tc-lib-pdf-page?branch=main)
[![License](https://poser.pugx.org/tecnickcom/tc-lib-pdf-page/license)](https://packagist.org/packages/tecnickcom/tc-lib-pdf-page)
[![Total Downloads](https://poser.pugx.org/tecnickcom/tc-lib-pdf-page/downloads)](https://packagist.org/packages/tecnickcom/tc-lib-pdf-page)
[![Downloads](https://poser.pugx.org/tecnickcom/tc-lib-pdf-page/downloads)](https://packagist.org/packages/tecnickcom/tc-lib-pdf-page)

[![Donate via PayPal](https://img.shields.io/badge/donate-paypal-87ceeb.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&currency_code=GBP&[email protected]&item_name=donation%20for%20tc-lib-pdf-page%20project)
*Please consider supporting this project by making a donation via [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&currency_code=GBP&[email protected]&item_name=donation%20for%20tc-lib-pdf-page%20project)*

* **category** Library
* **package** \Com\Tecnick\Pdf\Page
* **author** Nicola Asuni <[email protected]>
* **copyright** 2011-2022 Nicola Asuni - Tecnick.com LTD
* **copyright** 2011-2023 Nicola Asuni - Tecnick.com LTD
* **license** http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* **link** https://github.com/tecnickcom/tc-lib-pdf-page
* **SRC DOC** https://tcpdf.org/docs/srcdoc/tc-lib-pdf-page
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.0
3.2.1
4 changes: 1 addition & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@
"ext-date": "*",
"ext-zlib": "*",
"tecnickcom/tc-lib-color": "^1.14",
"tecnickcom/tc-lib-pdf-encrypt": "^1.6.0"
"tecnickcom/tc-lib-pdf-encrypt": "^1.6"
},
"require-dev": {
"pdepend/pdepend": "2.13.0",
"phploc/phploc": "7.0.2 || 6.0.2 || 5.0.0 || 4.0.1 || 3.0.1 || 2.1.5",
"phpmd/phpmd": "2.13.0",
"phpunit/phpunit": "10.1.2 || 9.6.7 || 8.5.31 || 7.5.20 || 6.5.14 || 5.7.27 || 4.8.36",
"sebastian/phpcpd": "6.0.3 || 5.0.2 || 4.1.0 || 3.0.1 || 2.0.4",
"squizlabs/php_codesniffer": "3.7.2 || 2.9.2"
},
"autoload": {
Expand Down
7 changes: 7 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<ruleset name="backward-compatibility">
<description>PSR-12 for PHP less than 7.1</description>
<rule ref="PSR12">
<exclude name="PSR12.Properties.ConstantVisibility"/>
</rule>
</ruleset>
2 changes: 1 addition & 1 deletion resources/debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ Vcs-Git: https://github.com/~#VENDOR#~/~#PROJECT#~.git
Package: ~#PKGNAME#~
Provides: php-~#PROJECT#~
Architecture: all
Depends: php (>= 5.4.0), php-date, php-zip, php-tecnickcom-tc-lib-color (<< 2.0.0), php-tecnickcom-tc-lib-color (>= 1.14.28), php-tecnickcom-tc-lib-pdf-encrypt (<< 2.0.0), php-tecnickcom-tc-lib-pdf-encrypt (>= 1.6.24), ${misc:Depends}
Depends: php (>= 5.4.0), php-date, php-zip, php-tecnickcom-tc-lib-color (<< 2.0.0), php-tecnickcom-tc-lib-color (>= 1.14.29), php-tecnickcom-tc-lib-pdf-encrypt (<< 2.0.0), php-tecnickcom-tc-lib-pdf-encrypt (>= 1.6.25), ${misc:Depends}
Description: PHP PDF Page Library
PHP library containing PDF page formats and definitions.
4 changes: 2 additions & 2 deletions resources/rpm/rpm.spec
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ Requires: php(language) >= 5.4.0
Requires: php-date
Requires: php-zlib
Requires: php-composer(%{c_vendor}/tc-lib-color) < 2.0.0
Requires: php-composer(%{c_vendor}/tc-lib-color) >= 1.14.28
Requires: php-composer(%{c_vendor}/tc-lib-color) >= 1.14.29
Requires: php-composer(%{c_vendor}/tc-lib-pdf-encrypt) < 2.0.0
Requires: php-composer(%{c_vendor}/tc-lib-pdf-encrypt) >= 1.6.24
Requires: php-composer(%{c_vendor}/tc-lib-pdf-encrypt) >= 1.6.25

Provides: php-composer(%{c_vendor}/%{gh_project}) = %{version}
Provides: php-%{gh_project} = %{version}
Expand Down
25 changes: 13 additions & 12 deletions src/Box.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Box.php
*
Expand All @@ -15,7 +16,7 @@

namespace Com\Tecnick\Pdf\Page;

use \Com\Tecnick\Pdf\Page\Exception as PageException;
use Com\Tecnick\Pdf\Page\Exception as PageException;

/**
* Com\Tecnick\Pdf\Page\Box
Expand Down Expand Up @@ -87,7 +88,7 @@ public function setBox($dims, $type, $llx, $lly, $urx, $ury, array $bci = array(
$dims = array();
}
if (!in_array($type, self::$box)) {
throw new PageException('unknown page box type: '.$type);
throw new PageException('unknown page box type: ' . $type);
}
$dims[$type]['llx'] = $llx;
$dims[$type]['lly'] = $lly;
Expand Down Expand Up @@ -141,13 +142,13 @@ protected function getBox(array $dims)
continue;
// @codeCoverageIgnoreEnd
}
$out .= '/'.$box.' ['.sprintf(
$out .= '/' . $box . ' [' . sprintf(
'%F %F %F %F',
$dims[$box]['llx'],
$dims[$box]['lly'],
$dims[$box]['urx'],
$dims[$box]['ury']
).']'."\n";
) . ']' . "\n";
}
return $out;
}
Expand All @@ -161,37 +162,37 @@ protected function getBox(array $dims)
*/
protected function getBoxColorInfo(array $dims)
{
$out = '/BoxColorInfo <<'."\n";
$out = '/BoxColorInfo <<' . "\n";
foreach (self::$box as $box) {
if (empty($dims[$box])) {
// @codeCoverageIgnoreStart
continue;
// @codeCoverageIgnoreEnd
}
$out .= '/'.$box.' <<'."\n";
$out .= '/' . $box . ' <<' . "\n";
if (!empty($dims[$box]['bci']['color'])) {
$out .= '/C ['.$this->col->getPdfRgbComponents($dims[$box]['bci']['color']).']'."\n";
$out .= '/C [' . $this->col->getPdfRgbComponents($dims[$box]['bci']['color']) . ']' . "\n";
}
if (!empty($dims[$box]['bci']['width'])) {
$out .= '/W '.sprintf('%F', ($dims[$box]['bci']['width'] * $this->kunit))."\n";
$out .= '/W ' . sprintf('%F', ($dims[$box]['bci']['width'] * $this->kunit)) . "\n";
}
if (!empty($dims[$box]['bci']['style'])) {
$mode = strtoupper($dims[$box]['bci']['style'][0]);
if ($mode !== 'D') {
$mode = 'S';
}
$out .= '/S /'.$mode."\n";
$out .= '/S /' . $mode . "\n";
}
if (!empty($dims[$box]['bci']['dash'])) {
$out .= '/D [';
foreach ($dims[$box]['bci']['dash'] as $dash) {
$out .= sprintf(' %F', ((float) $dash * $this->kunit));
}
$out .= ' ]'."\n";
$out .= ' ]' . "\n";
}
$out .= '>>'."\n";
$out .= '>>' . "\n";
}
$out .= '>>'."\n";
$out .= '>>' . "\n";
return $out;
}
}
1 change: 1 addition & 0 deletions src/Exception.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Exception.php
*
Expand Down
9 changes: 5 additions & 4 deletions src/Format.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Format.php
*
Expand All @@ -15,7 +16,7 @@

namespace Com\Tecnick\Pdf\Page;

use \Com\Tecnick\Pdf\Page\Exception as PageException;
use Com\Tecnick\Pdf\Page\Exception as PageException;

/**
* Com\Tecnick\Pdf\Page\Format
Expand Down Expand Up @@ -453,7 +454,7 @@ abstract class Format
'JP_SANGO_BAN_B20_DORI' => array( 515.906, 583.937), // = ( 182 x 206 ) mm = ( 7.17 x 8.11 ) in
'JP_SANGO_BAN_B36_DORI' => array( 342.992, 484.724), // = ( 121 x 171 ) mm = ( 4.76 x 6.73 ) in
'JP_SANGO_BAN_B40_DORI' => array( 238.110, 419.528), // = ( 84 x 148 ) mm = ( 3.31 x 5.83 ) in
'JP_SANROKU_BAN_B48_DORI'=> array( 257.953, 484.724), // = ( 91 x 171 ) mm = ( 3.58 x 6.73 ) in
'JP_SANROKU_BAN_B48_DORI' => array( 257.953, 484.724), // = ( 91 x 171 ) mm = ( 3.58 x 6.73 ) in
'JP_SANSAN_BAN' => array( 1975.748, 2834.646), // = ( 697 x 1000 ) mm = ( 27.44 x 39.37 ) in
'JP_SANSHI_BAN' => array( 2060.787, 2834.646), // = ( 727 x 1000 ) mm = ( 28.62 x 39.37 ) in
'JP_SHIKISHIBAN' => array( 581.102, 651.969), // = ( 205 x 230 ) mm = ( 8.07 x 9.06 ) in
Expand Down Expand Up @@ -487,7 +488,7 @@ abstract class Format
public function getPageFormatSize($format, $orientation = '', $unit = '', $dec = 6)
{
if (!isset(self::$format[$format])) {
throw new PageException('unknown page format: '.$format);
throw new PageException('unknown page format: ' . $format);
}
return $this->getPageOrientedSize(
$this->convertPoints(self::$format[$format][0], $unit, $dec),
Expand Down Expand Up @@ -544,7 +545,7 @@ public function getUnitRatio($unit)
{
$unit = strtolower($unit);
if (!isset(self::$unitratio[$unit])) {
throw new PageException('unknown unit: '.$unit);
throw new PageException('unknown unit: ' . $unit);
}
return self::$unitratio[$unit];
}
Expand Down
1 change: 1 addition & 0 deletions src/Mode.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Mode.php
*
Expand Down
Loading

0 comments on commit a8b0cfc

Please sign in to comment.