Skip to content

Commit

Permalink
phpoffice/phpspreadsheet v2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
orkhanahmadov committed Jan 26, 2024
1 parent 663f703 commit 6236495
Show file tree
Hide file tree
Showing 10 changed files with 162 additions and 148 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,17 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.0, 8.1, 8.2]
laravel: [8.*, 9.*, 10.*]
php: [8.1, 8.2, 8.3]
laravel: [9.*, 10.*]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 10.*
testbench: ^8.0
- laravel: 9.*
testbench: ^7.0
- laravel: 8.*
testbench: ^6.6
exclude:
- laravel: 10.*
php: 8.0
- laravel: 8.*
php: 8.2
- laravel: 8.*
php: 8.1

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

Expand Down
204 changes: 106 additions & 98 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,125 +6,133 @@
use PhpCsFixer\Finder;

$rules = [
'array_syntax' => ['syntax' => 'short'],
'@PHP81Migration' => true,
'@PHP80Migration:risky' => true,
'@PSR12:risky' => true,
'@PHPUnit100Migration:risky' => true,

// start: psr-12 with modifications
'@PSR12' => true,
'binary_operator_spaces' => [
'default' => 'single_space',
],
'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => true,
'no_superfluous_phpdoc_tags' => true,
'blank_line_before_statement' => [
'statements' => ['return'],
'ordered_imports' => [
'sort_algorithm' => 'alpha',
],
'braces' => true,
'cast_spaces' => true,
'class_definition' => true,
'concat_space' => [
'spacing' => 'one',
'method_argument_space' => [
'keep_multiple_spaces_after_comma' => true,
'on_multiline' => 'ensure_fully_multiline'
],
'spaces_inside_parentheses' => [
'space' => 'none',
],
'braces_position' => true,
'single_import_per_statement' => true,

'no_whitespace_before_comma_in_array' => true,
'trailing_comma_in_multiline' => true,
// end: psr-12 with modifications

// start: cs-fixer with modifications
'@PhpCsFixer' => true,
'fully_qualified_strict_types' => [
'import_symbols' => false,
],
'multiline_whitespace_before_semicolons' => [
'strategy' => 'no_multi_line',
],
'declare_equal_normalize' => true,
'elseif' => true,
'encoding' => true,
'full_opening_tag' => true,
'declare_strict_types' => true,
'fully_qualified_strict_types' => true,
'function_declaration' => true,
'function_typehint_space' => true,
'heredoc_to_nowdoc' => true,
'include' => true,
'increment_style' => ['style' => 'post'],
'indentation_type' => true,
'linebreak_after_opening_tag' => true,
'line_ending' => true,
'lowercase_cast' => true,
'constant_case' => true,
'lowercase_keywords' => true,
'lowercase_static_reference' => true,
'magic_method_casing' => true,
'magic_constant_casing' => true,
'method_argument_space' => true,
'native_function_casing' => true,
'no_alias_functions' => true,
'no_extra_blank_lines' => [
'tokens' => [
'attribute',
'extra',
'break',
'continue',
'throw',
'use',
'switch',
'case',
'default',
'curly_brace_block',
'parenthesis_brace_block',
],
],
'ordered_types' => [
'null_adjustment' => 'always_last',
'sort_algorithm' => 'none',
],
'single_line_comment_style' => [
'comment_types' => ['hash'],
],
'nullable_type_declaration_for_default_null_value' => [
'use_nullable_type_declaration' => true,
],
'concat_space' => [
'spacing' => 'one',
],
'increment_style' => [
'style' => 'post',
],
'class_attributes_separation' => [
'elements' => [
'method' => 'one',
'trait_import' => 'none',
],
],
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_closing_tag' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_mixed_echo_print' => [
'use' => 'echo',
],
'no_multiline_whitespace_around_double_arrow' => true,
'multiline_whitespace_before_semicolons' => [
'strategy' => 'no_multi_line',
'new_with_parentheses' => [
'anonymous_class' => false,
],
'no_short_bool_cast' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_after_function_name' => true,
'no_spaces_around_offset' => true,
'no_spaces_inside_parenthesis' => true,
'no_trailing_comma_in_singleline' => true,
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'no_unneeded_control_parentheses' => true,
'no_unreachable_default_argument_value' => true,
'no_useless_return' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'normalize_index_brace' => true,
'ordered_class_elements' => [
'order' => [
'use_trait',
'case',
'constant_public',
'constant_protected',
'constant_private',
'property_public',
'property_protected',
'property_private',
'construct',
'magic',
'method_abstract',
'method_public',
'method_protected',
'method_private',
'destruct',
'phpunit',
],
],
// end: cs-fixer with modifications

// start: cs-fixer risky with modifications
'@PhpCsFixer:risky' => true,
'get_class_to_class_keyword' => true,
'modernize_strpos' => true,
'global_namespace_import' => true,
'phpdoc_types_order' => [
'null_adjustment' => 'always_last',
'sort_algorithm' => 'none',
],
'php_unit_test_case_static_method_calls' => [
'call_type' => 'this',
],
// end: cs-fixer risky with modifications

// extras
'not_operator_with_successor_space' => true,
'object_operator_without_whitespace' => true,
'ordered_imports' => ['sort_algorithm' => 'alpha'],
'phpdoc_indent' => true,
'general_phpdoc_tag_rename' => true,
'phpdoc_no_access' => true,
'phpdoc_no_package' => true,
'phpdoc_no_useless_inheritdoc' => true,
'phpdoc_scalar' => true,
'phpdoc_single_line_var_spacing' => true,
'phpdoc_summary' => true,
'simplified_null_return' => true,

// disabled rules
'comment_to_phpdoc' => false,
'static_lambda' => false,
'yoda_style' => false,
'is_null' => false,
'native_function_invocation' => false,
'protected_to_private' => false,
'phpdoc_to_comment' => false,
'phpdoc_trim' => true,
'phpdoc_types' => true,
'phpdoc_var_without_name' => true,
'psr_autoloading' => true,
'self_accessor' => true,
'short_scalar_cast' => true,
'simplified_null_return' => false,
'single_blank_line_at_eof' => true,
'single_blank_line_before_namespace' => true,
'single_class_element_per_statement' => true,
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'no_unused_imports' => true,
'single_line_comment_style' => [
'comment_types' => ['hash'],
],
'single_quote' => true,
'space_after_semicolon' => true,
'standardize_not_equals' => true,
'switch_case_semicolon_to_colon' => true,
'switch_case_space' => true,
'ternary_operator_spaces' => true,
'trailing_comma_in_multiline' => true,
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'whitespace_after_comma_in_array' => true,
'single_trait_insert_per_statement' => true,
'phpdoc_no_alias_tag' => false,
'php_unit_internal_class' => false,
'php_unit_test_class_requires_covers' => false,
'non_printable_character' => false,
];

$project_path = getcwd();
Expand Down
34 changes: 32 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,36 @@

All notable changes to `spreadsheet-translations` will be documented in this file

## 1.0.0 - 201X-XX-XX
## 1.3.0 - 2024-01-26

- initial release
- Add support for `phpoffice/phpspreadsheet` v2

- Add support for PHP 8.3

- Drop support for PHP 8.0

- Drop support for Laravel 8

## 1.2.0 - 2023-03-01

- Generate JSON translations instead of PHP

## 1.1.2 - 2023-03-01

- Bug fixes

## 1.1.1 - 2023-02-28

- Fixed `lang_path` backward compatibility

## 1.1.0 - 2023-02-28

- Laravel 8 support

## 1.0.1 - 2023-02-28

- Fixed bug where it parsed empty key field

## 1.0.0 - 2023-02-28

- Initial release
23 changes: 10 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,25 @@
}
],
"require": {
"php": "^8.0",
"php": "^8.1",
"guzzlehttp/guzzle": "^6.0|^7.0",
"illuminate/console": "^8.0|^9.0|^10.0",
"illuminate/contracts": "^8.0|^9.0|^10.0",
"illuminate/http": "^8.0|^9.0|^10.0",
"illuminate/support": "^8.0|^9.0|^10.0",
"phpoffice/phpspreadsheet": "^1.28"
"illuminate/console": "^9.0|^10.0",
"illuminate/contracts": "^9.0|^10.0",
"illuminate/http": "^9.0|^10.0",
"illuminate/support": "^9.0|^10.0",
"phpoffice/phpspreadsheet": "^1.28|^2.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.0|^3.14",
"mockery/mockery": "^1.4",
"nunomaduro/larastan": "^1.0|^2.4",
"orchestra/testbench": "^6.0|^7.0|^8.0",
"phpunit/phpunit": "^8.0|^9.0|^10.0"
"larastan/larastan": "^1.0|^2.4",
"orchestra/testbench": "^7.0|^8.0",
"phpunit/phpunit": "^9.0|^10.0"
},
"autoload": {
"psr-4": {
"Orkhanahmadov\\SpreadsheetTranslations\\": "src"
},
"files": [
"src/functions.php"
]
}
},
"autoload-dev": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
includes:
- ./vendor/nunomaduro/larastan/extension.neon
- ./vendor/larastan/larastan/extension.neon

parameters:
paths:
Expand Down
12 changes: 6 additions & 6 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Test Suite">
<directory>tests</directory>
Expand All @@ -14,4 +9,9 @@
<env name="APP_ENV" value="testing"/>
<env name="APP_KEY" value="base64:9THNcImd2wXLtqiliHe1fHRr9ZkAorMbYE6efvmGFzc="/>
</php>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
</source>
</phpunit>
3 changes: 1 addition & 2 deletions src/SpreadsheetFileHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ public function __construct(
protected Application $application,
protected Repository $config,
protected Factory $http
) {
}
) {}

public function getFilePath(): string
{
Expand Down
6 changes: 3 additions & 3 deletions src/SpreadsheetParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ class SpreadsheetParser
public function __construct(
protected Repository $config,
protected SpreadsheetFileHandler $fileHandler
) {
}
) {}

public function getTranslations(): array
{
Expand Down Expand Up @@ -57,7 +56,8 @@ protected function rowShouldBeIgnored(Row $row): bool
// ignore if row is one of the ignored rows
return in_array(
$row->getRowIndex(),
$this->config->get('spreadsheet-translations.ignored_rows')
$this->config->get('spreadsheet-translations.ignored_rows'),
true
);
}

Expand Down
Loading

0 comments on commit 6236495

Please sign in to comment.