Skip to content

Commit

Permalink
Upgrade PHP and dev dependencies
Browse files Browse the repository at this point in the history
/!\ Removed PHP 7.2 support /!\

- PHPUnit 8 => 9 (+ fix the tests)
- PHP-CS-Fixer 2 => 3 (+ fix the code)
- Introduced PHP stan
  • Loading branch information
adrilo committed Jan 12, 2022
1 parent 6a10ec3 commit 6b7366b
Show file tree
Hide file tree
Showing 46 changed files with 249 additions and 253 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
tests-on-older-php:
strategy:
matrix:
php-versions: ['7.2', '7.3', '7.4']
php-versions: ['7.3', '7.4']
runs-on: ubuntu-latest
name: Tests - PHP ${{ matrix.php-versions }}
env:
Expand Down Expand Up @@ -209,7 +209,7 @@ jobs:
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Run PHP-CS-Fixer
run: vendor/bin/php-cs-fixer fix --verbose --diff --dry-run --diff-format=udiff
run: vendor/bin/php-cs-fixer fix --verbose --diff --dry-run

static-analysis:
name: Static Analysis
Expand Down Expand Up @@ -260,4 +260,4 @@ jobs:
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Static Analysis using PHPStan
run: phpstan analyse --no-progress src/
run: phpstan analyse --no-progress src tests
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
/tests/coverage
/vendor
/composer.lock
/.php_cs.cache
/.php-cs-fixer.cache
/.phpunit.result.cache
27 changes: 11 additions & 16 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<?php

$config = PhpCsFixer\Config::create()
$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->name('*.php')
->exclude('vendor');

$config = new PhpCsFixer\Config();
return $config
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
Expand All @@ -13,8 +19,8 @@
'declare_equal_normalize' => ['space' => 'single'],
'heredoc_to_nowdoc' => true,
'increment_style' => ['style' => 'post'],
'is_null' => ['use_yoda_style' => false],
'method_argument_space' => ['ensure_fully_multiline' => true],
'is_null' => true,
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
'modernize_types_casting' => true,
'no_break_comment' => ['comment_text' => 'do nothing'],
'no_empty_phpdoc' => false,
Expand Down Expand Up @@ -44,16 +50,5 @@
'single_line_comment_style' => ['comment_types' => ['hash']],
'strict_comparison' => true,
'yoda_style' => ['equal' => false, 'identical' => false],
]);

$config->setFinder(
PhpCsFixer\Finder::create()
->exclude('vendor')
->in(__DIR__)
->name('*.php')
);

$cacheDir = getenv('TRAVIS') ? getenv('HOME') . '/.php-cs-fixer' : __DIR__;
$config->setCacheFile($cacheDir . '/.php_cs.cache');

return $config;
])
->setFinder($finder);
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
}
],
"require": {
"php": ">=7.2.0",
"php": ">=7.3.0",
"ext-zip": "*",
"ext-xmlreader": "*",
"ext-dom": "*"
},
"require-dev": {
"phpunit/phpunit": "^8",
"friendsofphp/php-cs-fixer": "^2"
"phpunit/phpunit": "^9",
"friendsofphp/php-cs-fixer": "^3",
"phpstan/phpstan": "^1"
},
"suggest": {
"ext-iconv": "To handle non UTF-8 CSV files (if \"php-intl\" is not already installed or is too limited)",
Expand All @@ -37,7 +38,7 @@
},
"config": {
"platform": {
"php": "7.2"
"php": "7.3"
}
}
}
14 changes: 7 additions & 7 deletions src/Spout/Common/Entity/Cell.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,38 @@ class Cell
/**
* Numeric cell type (whole numbers, fractional numbers, dates)
*/
const TYPE_NUMERIC = 0;
public const TYPE_NUMERIC = 0;

/**
* String (text) cell type
*/
const TYPE_STRING = 1;
public const TYPE_STRING = 1;

/**
* Formula cell type
* Not used at the moment
*/
const TYPE_FORMULA = 2;
public const TYPE_FORMULA = 2;

/**
* Empty cell type
*/
const TYPE_EMPTY = 3;
public const TYPE_EMPTY = 3;

/**
* Boolean cell type
*/
const TYPE_BOOLEAN = 4;
public const TYPE_BOOLEAN = 4;

/**
* Date cell type
*/
const TYPE_DATE = 5;
public const TYPE_DATE = 5;

/**
* Error cell type
*/
const TYPE_ERROR = 6;
public const TYPE_ERROR = 6;

/**
* The value of this cell
Expand Down
24 changes: 12 additions & 12 deletions src/Spout/Common/Entity/Style/Border.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
*/
class Border
{
const LEFT = 'left';
const RIGHT = 'right';
const TOP = 'top';
const BOTTOM = 'bottom';
public const LEFT = 'left';
public const RIGHT = 'right';
public const TOP = 'top';
public const BOTTOM = 'bottom';

const STYLE_NONE = 'none';
const STYLE_SOLID = 'solid';
const STYLE_DASHED = 'dashed';
const STYLE_DOTTED = 'dotted';
const STYLE_DOUBLE = 'double';
public const STYLE_NONE = 'none';
public const STYLE_SOLID = 'solid';
public const STYLE_DASHED = 'dashed';
public const STYLE_DOTTED = 'dotted';
public const STYLE_DOUBLE = 'double';

const WIDTH_THIN = 'thin';
const WIDTH_MEDIUM = 'medium';
const WIDTH_THICK = 'thick';
public const WIDTH_THIN = 'thin';
public const WIDTH_MEDIUM = 'medium';
public const WIDTH_THICK = 'thick';

/** @var array A list of BorderPart objects for this border. */
private $parts = [];
Expand Down
8 changes: 4 additions & 4 deletions src/Spout/Common/Entity/Style/CellAlignment.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
*/
abstract class CellAlignment
{
const LEFT = 'left';
const RIGHT = 'right';
const CENTER = 'center';
const JUSTIFY = 'justify';
public const LEFT = 'left';
public const RIGHT = 'right';
public const CENTER = 'center';
public const JUSTIFY = 'justify';

private static $VALID_ALIGNMENTS = [
self::LEFT => 1,
Expand Down
24 changes: 12 additions & 12 deletions src/Spout/Common/Entity/Style/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
abstract class Color
{
/** Standard colors - based on Office Online */
const BLACK = '000000';
const WHITE = 'FFFFFF';
const RED = 'FF0000';
const DARK_RED = 'C00000';
const ORANGE = 'FFC000';
const YELLOW = 'FFFF00';
const LIGHT_GREEN = '92D040';
const GREEN = '00B050';
const LIGHT_BLUE = '00B0E0';
const BLUE = '0070C0';
const DARK_BLUE = '002060';
const PURPLE = '7030A0';
public const BLACK = '000000';
public const WHITE = 'FFFFFF';
public const RED = 'FF0000';
public const DARK_RED = 'C00000';
public const ORANGE = 'FFC000';
public const YELLOW = 'FFFF00';
public const LIGHT_GREEN = '92D040';
public const GREEN = '00B050';
public const LIGHT_BLUE = '00B0E0';
public const BLUE = '0070C0';
public const DARK_BLUE = '002060';
public const PURPLE = '7030A0';

/**
* Returns an RGB color from R, G and B values
Expand Down
6 changes: 3 additions & 3 deletions src/Spout/Common/Entity/Style/Style.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
class Style
{
/** Default values */
const DEFAULT_FONT_SIZE = 11;
const DEFAULT_FONT_COLOR = Color::BLACK;
const DEFAULT_FONT_NAME = 'Arial';
public const DEFAULT_FONT_SIZE = 11;
public const DEFAULT_FONT_COLOR = Color::BLACK;
public const DEFAULT_FONT_NAME = 'Arial';

/** @var int|null Style ID */
private $id;
Expand Down
20 changes: 10 additions & 10 deletions src/Spout/Common/Helper/EncodingHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
class EncodingHelper
{
/** Definition of the encodings that can have a BOM */
const ENCODING_UTF8 = 'UTF-8';
const ENCODING_UTF16_LE = 'UTF-16LE';
const ENCODING_UTF16_BE = 'UTF-16BE';
const ENCODING_UTF32_LE = 'UTF-32LE';
const ENCODING_UTF32_BE = 'UTF-32BE';
public const ENCODING_UTF8 = 'UTF-8';
public const ENCODING_UTF16_LE = 'UTF-16LE';
public const ENCODING_UTF16_BE = 'UTF-16BE';
public const ENCODING_UTF32_LE = 'UTF-32LE';
public const ENCODING_UTF32_BE = 'UTF-32BE';

/** Definition of the BOMs for the different encodings */
const BOM_UTF8 = "\xEF\xBB\xBF";
const BOM_UTF16_LE = "\xFF\xFE";
const BOM_UTF16_BE = "\xFE\xFF";
const BOM_UTF32_LE = "\xFF\xFE\x00\x00";
const BOM_UTF32_BE = "\x00\x00\xFE\xFF";
public const BOM_UTF8 = "\xEF\xBB\xBF";
public const BOM_UTF16_LE = "\xFF\xFE";
public const BOM_UTF16_BE = "\xFE\xFF";
public const BOM_UTF32_LE = "\xFF\xFE\x00\x00";
public const BOM_UTF32_BE = "\x00\x00\xFE\xFF";

/** @var \Box\Spout\Common\Helper\GlobalFunctionsHelper Helper to work with global functions */
protected $globalFunctionsHelper;
Expand Down
2 changes: 1 addition & 1 deletion src/Spout/Common/Manager/OptionsManagerAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
abstract class OptionsManagerAbstract implements OptionsManagerInterface
{
const PREFIX_OPTION = 'OPTION_';
public const PREFIX_OPTION = 'OPTION_';

/** @var string[] List of all supported option names */
private $supportedOptions = [];
Expand Down
6 changes: 3 additions & 3 deletions src/Spout/Common/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
abstract class Type
{
const CSV = 'csv';
const XLSX = 'xlsx';
const ODS = 'ods';
public const CSV = 'csv';
public const XLSX = 'xlsx';
public const ODS = 'ods';
}
2 changes: 1 addition & 1 deletion src/Spout/Reader/CSV/RowIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class RowIterator implements IteratorInterface
/**
* Value passed to fgetcsv. 0 means "unlimited" (slightly slower but accomodates for very long lines).
*/
const MAX_READ_BYTES_PER_LINE = 0;
public const MAX_READ_BYTES_PER_LINE = 0;

/** @var resource Pointer to the CSV file to read */
protected $filePointer;
Expand Down
14 changes: 7 additions & 7 deletions src/Spout/Reader/Common/Entity/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
abstract class Options
{
// Common options
const SHOULD_FORMAT_DATES = 'shouldFormatDates';
const SHOULD_PRESERVE_EMPTY_ROWS = 'shouldPreserveEmptyRows';
public const SHOULD_FORMAT_DATES = 'shouldFormatDates';
public const SHOULD_PRESERVE_EMPTY_ROWS = 'shouldPreserveEmptyRows';

// CSV specific options
const FIELD_DELIMITER = 'fieldDelimiter';
const FIELD_ENCLOSURE = 'fieldEnclosure';
const ENCODING = 'encoding';
public const FIELD_DELIMITER = 'fieldDelimiter';
public const FIELD_ENCLOSURE = 'fieldEnclosure';
public const ENCODING = 'encoding';

// XLSX specific options
const TEMP_FOLDER = 'tempFolder';
const SHOULD_USE_1904_DATES = 'shouldUse1904Dates';
public const TEMP_FOLDER = 'tempFolder';
public const SHOULD_USE_1904_DATES = 'shouldUse1904Dates';
}
12 changes: 6 additions & 6 deletions src/Spout/Reader/Common/XMLProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
class XMLProcessor
{
/* Node types */
const NODE_TYPE_START = XMLReader::ELEMENT;
const NODE_TYPE_END = XMLReader::END_ELEMENT;
public const NODE_TYPE_START = XMLReader::ELEMENT;
public const NODE_TYPE_END = XMLReader::END_ELEMENT;

/* Keys associated to reflection attributes to invoke a callback */
const CALLBACK_REFLECTION_METHOD = 'reflectionMethod';
const CALLBACK_REFLECTION_OBJECT = 'reflectionObject';
public const CALLBACK_REFLECTION_METHOD = 'reflectionMethod';
public const CALLBACK_REFLECTION_OBJECT = 'reflectionObject';

/* Values returned by the callbacks to indicate what the processor should do next */
const PROCESSING_CONTINUE = 1;
const PROCESSING_STOP = 2;
public const PROCESSING_CONTINUE = 1;
public const PROCESSING_STOP = 2;

/** @var \Box\Spout\Reader\Wrapper\XMLReader The XMLReader object that will help read sheet's XML data */
protected $xmlReader;
Expand Down
42 changes: 21 additions & 21 deletions src/Spout/Reader/ODS/Helper/CellValueFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,31 @@
class CellValueFormatter
{
/** Definition of all possible cell types */
const CELL_TYPE_STRING = 'string';
const CELL_TYPE_FLOAT = 'float';
const CELL_TYPE_BOOLEAN = 'boolean';
const CELL_TYPE_DATE = 'date';
const CELL_TYPE_TIME = 'time';
const CELL_TYPE_CURRENCY = 'currency';
const CELL_TYPE_PERCENTAGE = 'percentage';
const CELL_TYPE_VOID = 'void';
public const CELL_TYPE_STRING = 'string';
public const CELL_TYPE_FLOAT = 'float';
public const CELL_TYPE_BOOLEAN = 'boolean';
public const CELL_TYPE_DATE = 'date';
public const CELL_TYPE_TIME = 'time';
public const CELL_TYPE_CURRENCY = 'currency';
public const CELL_TYPE_PERCENTAGE = 'percentage';
public const CELL_TYPE_VOID = 'void';

/** Definition of XML nodes names used to parse data */
const XML_NODE_P = 'p';
const XML_NODE_TEXT_A = 'text:a';
const XML_NODE_TEXT_SPAN = 'text:span';
const XML_NODE_TEXT_S = 'text:s';
const XML_NODE_TEXT_TAB = 'text:tab';
const XML_NODE_TEXT_LINE_BREAK = 'text:line-break';
public const XML_NODE_P = 'p';
public const XML_NODE_TEXT_A = 'text:a';
public const XML_NODE_TEXT_SPAN = 'text:span';
public const XML_NODE_TEXT_S = 'text:s';
public const XML_NODE_TEXT_TAB = 'text:tab';
public const XML_NODE_TEXT_LINE_BREAK = 'text:line-break';

/** Definition of XML attributes used to parse data */
const XML_ATTRIBUTE_TYPE = 'office:value-type';
const XML_ATTRIBUTE_VALUE = 'office:value';
const XML_ATTRIBUTE_BOOLEAN_VALUE = 'office:boolean-value';
const XML_ATTRIBUTE_DATE_VALUE = 'office:date-value';
const XML_ATTRIBUTE_TIME_VALUE = 'office:time-value';
const XML_ATTRIBUTE_CURRENCY = 'office:currency';
const XML_ATTRIBUTE_C = 'text:c';
public const XML_ATTRIBUTE_TYPE = 'office:value-type';
public const XML_ATTRIBUTE_VALUE = 'office:value';
public const XML_ATTRIBUTE_BOOLEAN_VALUE = 'office:boolean-value';
public const XML_ATTRIBUTE_DATE_VALUE = 'office:date-value';
public const XML_ATTRIBUTE_TIME_VALUE = 'office:time-value';
public const XML_ATTRIBUTE_CURRENCY = 'office:currency';
public const XML_ATTRIBUTE_C = 'text:c';

/** @var bool Whether date/time values should be returned as PHP objects or be formatted as strings */
protected $shouldFormatDates;
Expand Down
Loading

0 comments on commit 6b7366b

Please sign in to comment.