1
0
mirror of https://github.com/Ne-Lexa/php-zip.git synced 2025-03-13 19:19:42 +01:00

Merge tag '4.0.1' into develop

4.0.1 version
This commit is contained in:
Ne-Lexa 2021-12-12 12:50:55 +03:00
commit 66168de897
27 changed files with 501 additions and 763 deletions

View File

@ -23,6 +23,7 @@ jobs:
php:
- '7.4'
- '8.0'
- '8.1'
runs-on: ${{ matrix.os }}

View File

@ -2,17 +2,27 @@
declare(strict_types=1);
/**
* PHP Code Style Fixer (config created for version 2.18.2 (Remote Void)).
/*
* PHP Code Style Fixer (config created for version 3.4.0 (Si!)).
*
* Use one of the following console commands to just see the
* changes that will be made.
* - `php-cs-fixer fix --config='.php_cs' --diff-format udiff --dry-run`
* - `php '.php_cs'`
* - `php-cs-fixer fix --config='.php-cs-fixer.php' --dry-run`
* - `php '.php-cs-fixer.php'`
* - `php7.1 '.php-cs-fixer.php'`
* - `php7.2 '.php-cs-fixer.php'`
* - `php7.3 '.php-cs-fixer.php'`
* - `php7.4 '.php-cs-fixer.php'`
* - `php8.0 '.php-cs-fixer.php'`
*
* Use one of the following console commands to fix PHP code:
* - `php-cs-fixer fix --config='.php_cs' --diff-format udiff`
* - `php '.php_cs' --force`
* - `php-cs-fixer fix --config='.php-cs-fixer.php'
* - `php '.php-cs-fixer.php' --force`
* - `php7.1 '.php-cs-fixer.php' --force`
* - `php7.2 '.php-cs-fixer.php' --force`
* - `php7.3 '.php-cs-fixer.php' --force`
* - `php7.4 '.php-cs-fixer.php' --force`
* - `php8.0 '.php-cs-fixer.php' --force`
*
* @see https://cs.symfony.com/
*/
@ -39,6 +49,9 @@ $rules = [
'syntax' => 'short',
],
// Use the null coalescing assignment operator `??=` where possible.
'assign_null_coalescing_to_coalesce_equal' => true,
/*
* Converts backtick operators to `shell_exec` calls.
*
@ -63,19 +76,7 @@ $rules = [
// An empty line feed must precede any configured statement.
'blank_line_before_statement' => [
'statements' => [
'continue',
'declare',
'return',
'throw',
'try',
'case',
'die',
'exit',
'do',
'foreach',
'goto',
'if',
'while',
],
],
@ -104,9 +105,6 @@ $rules = [
*/
'class_definition' => true,
// Converts `::class` keywords to FQCN strings.
'class_keyword_remove' => false,
// Namespace must not contain spacing, comments or PHPDoc.
'clean_namespace' => true,
@ -157,6 +155,12 @@ $rules = [
*/
'constant_case' => true,
/*
* Control structure continuation keyword must be on the configured
* line.
*/
'control_structure_continuation_position' => true,
/*
* Class `DateTimeImmutable` should be used instead of `DateTime`.
*
@ -172,6 +176,9 @@ $rules = [
*/
'declare_equal_normalize' => true,
// There must not be spaces around `declare` statement parentheses.
'declare_parentheses' => true,
/*
* Force strict types declaration in all files. Requires PHP >= 7.0.
*
@ -230,6 +237,14 @@ $rules = [
*/
'elseif' => true,
// Empty loop-body must be in configured style.
'empty_loop_body' => [
'style' => 'braces',
],
// Empty loop-condition must be in configured style.
'empty_loop_condition' => true,
// PHP code MUST use only UTF-8 without BOM (remove BOM).
'encoding' => true,
@ -354,9 +369,6 @@ $rules = [
*/
'final_public_method_for_abstract_class' => false,
'final_static_access' => true,
/*
* Order the flags in `fopen` calls, `b` and `t` must be last.
*
@ -482,6 +494,9 @@ $rules = [
// Code MUST use configured indentation type.
'indentation_type' => true,
// Integer literals must be in correct case.
'integer_literal_case' => true,
/*
* Replaces `is_null($var)` expression with `null === $var`.
*
@ -542,7 +557,8 @@ $rules = [
* function.
*
* Risky!
* Risky when any of the functions are overridden.
* Risky when any of the functions are overridden, or when relying
* on the string byte size rather than its length in characters.
*/
'mb_str_functions' => false,
@ -565,6 +581,16 @@ $rules = [
*/
'method_chaining_indentation' => true,
/*
* Replace `strpos()` calls with `str_starts_with()` or
* `str_contains()` if possible.
*
* Risky!
* Risky if `strpos`, `str_starts_with` or `str_contains` functions
* are overridden.
*/
'modernize_strpos' => false,
/*
* Replaces `intval`, `floatval`, `doubleval`, `strval` and
* `boolval` function calls with according type casting operator.
@ -694,19 +720,16 @@ $rules = [
*/
'no_extra_blank_lines' => [
'tokens' => [
'extra',
'case',
'continue',
'default',
'curly_brace_block',
'default',
'extra',
'parenthesis_brace_block',
'return',
'square_brace_block',
'use',
'throw',
'use_trait',
'useTrait',
'switch',
'throw',
'use',
],
],
@ -756,12 +779,15 @@ $rules = [
*/
'no_short_bool_cast' => true,
'no_short_echo_tag' => false,
// Single-line whitespace before closing semicolon are prohibited.
'no_singleline_whitespace_before_semicolons' => true,
/*
* There must be no space around double colons (also called Scope
* Resolution Operator or Paamayim Nekudotayim).
*/
'no_space_around_double_colon' => true,
/*
* When making a method or function call, there MUST NOT be a space
* between the method or function name and the opening parenthesis.
@ -784,7 +810,10 @@ $rules = [
* Removes `@param`, `@return` and `@var` tags that don't provide
* any useful information.
*/
'no_superfluous_phpdoc_tags' => true,
'no_superfluous_phpdoc_tags' => [
'allow_mixed' => true,
'allow_unused_params' => true,
],
// Remove trailing commas in list function calls.
'no_trailing_comma_in_list_call' => true,
@ -924,11 +953,14 @@ $rules = [
'nullable_type_declaration_for_default_null_value' => true,
/*
* There should not be space before or after object
* `T_OBJECT_OPERATOR` `->`.
* There should not be space before or after object operators `->`
* and `?->`.
*/
'object_operator_without_whitespace' => true,
// Literal octal must be in `0o` notation.
'octal_notation' => true,
/*
* Operators - when multiline - must always be at the beginning or
* at the end of the line.
@ -1079,9 +1111,6 @@ $rules = [
*/
'php_unit_no_expectation_annotation' => true,
'php_unit_ordered_covers' => true,
/*
* Changes the visibility of the `setUp()` and `tearDown()`
* functions of PHPUnit to `protected`, to match the PHPUnit
@ -1170,9 +1199,6 @@ $rules = [
*/
'phpdoc_indent' => true,
'phpdoc_inline_tag' => true,
// Fixes PHPDoc inline tags.
'phpdoc_inline_tag_normalizer' => true,
@ -1272,6 +1298,19 @@ $rules = [
*/
'phpdoc_to_param_type' => true,
/*
* EXPERIMENTAL: Takes `@var` annotation of non-mixed types and
* adjusts accordingly the property signature. Requires PHP >= 7.4.
*
* Risky!
* This rule is EXPERIMENTAL and [1] is not covered with backward
* compatibility promise. [2] `@var` annotation is mandatory for the
* fixer to make changes, signatures of properties without it (no
* docblock) will not be fixed. [3] Manual actions might be required
* for newly typed properties that are read before initialization.
*/
'phpdoc_to_property_type' => false,
/*
* EXPERIMENTAL: Takes `@return` annotation of non-mixed types and
* adjusts accordingly the function signature. Requires PHP >= 7.0.
@ -1281,8 +1320,7 @@ $rules = [
* compatibility promise. [2] `@return` annotation is mandatory for
* the fixer to make changes, signatures of methods without it (no
* docblock, inheritdocs) will not be fixed. [3] Manual actions are
* required if inherited signatures are not properly documented. [4]
* `@inheritdocs` support is under construction.
* required if inherited signatures are not properly documented.
*/
'phpdoc_to_return_type' => true,
@ -1333,12 +1371,6 @@ $rules = [
*/
'protected_to_private' => true,
'psr0' => false,
'psr4' => false,
/*
* Classes must be in a path that matches their namespace, be at
* least one namespace deep and the class name should match the file
@ -1352,10 +1384,11 @@ $rules = [
/*
* Replaces `rand`, `srand`, `getrandmax` functions calls with their
* `mt_*` analogs.
* `mt_*` analogs or `random_int`.
*
* Risky!
* Risky when the configured functions are overridden.
* Risky when the configured functions are overridden. Or when
* relying on the seed based generating of the numbers.
*/
'random_api_migration' => [
'replacements' => [
@ -1444,7 +1477,7 @@ $rules = [
* A return statement wishing to return `void` should not return
* `null`.
*/
'simplified_null_return' => false,
'simplified_null_return' => true,
/*
* A PHP file without end tag must always end with a single empty
@ -1533,6 +1566,17 @@ $rules = [
*/
'strict_param' => true,
/*
* String tests for empty must be done against `''`, not with
* `strlen`.
*
* Risky!
* Risky when `strlen` is overridden, when called using a
* `stringable` object, also no longer triggers warning when called
* using non-string(able).
*/
'string_length_to_empty' => true,
/*
* All multi-line strings must use correct line ending.
*
@ -1569,8 +1613,11 @@ $rules = [
*/
'ternary_to_null_coalescing' => true,
// PHP multi-line arrays should have a trailing comma.
'trailing_comma_in_multiline_array' => [
/*
* Multi-line arrays, arguments list and parameters list must have a
* trailing comma.
*/
'trailing_comma_in_multiline' => [
'after_heredoc' => true,
],
@ -1580,6 +1627,9 @@ $rules = [
*/
'trim_array_spaces' => true,
// A single space or none should be around union type operator.
'types_spaces' => true,
// Unary operators should be placed adjacent to their operands.
'unary_operator_spaces' => true,
@ -1635,389 +1685,52 @@ $rules = [
],
];
/*
# .scrutinizer.yml config
tools:
php_cs_fixer:
config:
level: custom
fixers:
align_multiline_comment: true
array_indentation: true
array_push: true
array_syntax:
syntax: short
backtick_to_shell_exec: true
binary_operator_spaces: true
blank_line_after_namespace: true
blank_line_after_opening_tag: true
blank_line_before_statement:
statements:
- continue
- declare
- return
- throw
- try
- case
- die
- exit
- do
- foreach
- goto
- if
- while
braces:
allow_single_line_anonymous_class_with_empty_body: true
allow_single_line_closure: true
cast_spaces: true
class_attributes_separation: true
class_definition: true
class_keyword_remove: false
clean_namespace: true
combine_consecutive_issets: true
combine_consecutive_unsets: true
combine_nested_dirname: true
comment_to_phpdoc:
ignored_tags:
- noinspection
compact_nullable_typehint: true
concat_space:
spacing: one
constant_case: true
date_time_immutable: true
declare_equal_normalize: true
declare_strict_types: true
dir_constant: true
doctrine_annotation_array_assignment: true
doctrine_annotation_braces: true
doctrine_annotation_indentation: true
doctrine_annotation_spaces: true
echo_tag_syntax:
format: short
long_function: echo
shorten_simple_statements_only: true
elseif: true
encoding: true
ereg_to_preg: true
error_suppression:
mute_deprecation_error: true
noise_remaining_usages: true
noise_remaining_usages_exclude:
- fclose
- fopen
- gzinflate
- iconv
- mime_content_type
- rename
- rmdir
- unlink
escape_implicit_backslashes: true
explicit_indirect_variable: true
explicit_string_variable: true
final_class: false
final_internal_class: false
final_public_method_for_abstract_class: false
final_static_access: true
fopen_flag_order: true
fopen_flags:
b_mode: true
full_opening_tag: true
fully_qualified_strict_types: true
function_declaration: true
function_to_constant:
functions:
- get_called_class
- get_class
- get_class_this
- php_sapi_name
- phpversion
- pi
function_typehint_space: true
general_phpdoc_annotation_remove:
annotations:
- author
- license
general_phpdoc_tag_rename:
replacements:
inheritDocs: inheritDoc
global_namespace_import:
import_constants: false
import_functions: false
import_classes: false
group_import: false
header_comment:
header: "This file is part of the nelexa/zip package.\n(c) Ne-Lexa <https://github.com/Ne-Lexa/php-zip>\nFor the full copyright and license information, please view the LICENSE\nfile that was distributed with this source code."
comment_type: comment
location: after_declare_strict
separate: both
heredoc_indentation: true
heredoc_to_nowdoc: true
implode_call: true
include: true
increment_style: false
indentation_type: true
is_null: true
lambda_not_used_import: true
line_ending: true
linebreak_after_opening_tag: true
list_syntax:
syntax: short
logical_operators: true
lowercase_cast: true
lowercase_keywords: true
lowercase_static_reference: true
magic_constant_casing: true
magic_method_casing: true
mb_str_functions: false
method_argument_space:
on_multiline: ensure_fully_multiline
after_heredoc: true
method_chaining_indentation: true
modernize_types_casting: true
multiline_comment_opening_closing: true
multiline_whitespace_before_semicolons:
strategy: new_line_for_chained_calls
native_constant_invocation: true
native_function_casing: true
native_function_invocation:
include:
- '@compiler_optimized'
scope: namespaced
strict: true
native_function_type_declaration_casing: true
new_with_braces: true
no_alias_functions:
sets:
- '@all'
no_alias_language_construct_call: true
no_alternative_syntax: true
no_binary_string: true
no_blank_lines_after_class_opening: true
no_blank_lines_after_phpdoc: true
no_blank_lines_before_namespace: false
no_break_comment:
comment_text: 'no break'
no_closing_tag: true
no_empty_comment: true
no_empty_phpdoc: true
no_empty_statement: true
no_extra_blank_lines:
tokens:
- extra
- case
- continue
- default
- curly_brace_block
- parenthesis_brace_block
- return
- square_brace_block
- use
- throw
- use_trait
- useTrait
- switch
no_homoglyph_names: true
no_leading_import_slash: true
no_leading_namespace_whitespace: true
no_mixed_echo_print: true
no_multiline_whitespace_around_double_arrow: true
no_null_property_initialization: true
no_php4_constructor: true
no_short_bool_cast: true
no_short_echo_tag: false
no_singleline_whitespace_before_semicolons: true
no_spaces_after_function_name: true
no_spaces_around_offset: true
no_spaces_inside_parenthesis: true
no_superfluous_elseif: true
no_superfluous_phpdoc_tags: true
no_trailing_comma_in_list_call: true
no_trailing_comma_in_singleline_array: true
no_trailing_whitespace: true
no_trailing_whitespace_in_comment: true
no_trailing_whitespace_in_string: true
no_unneeded_control_parentheses:
statements:
- break
- clone
- continue
- echo_print
- return
- switch_case
- yield
- yield_from
no_unneeded_curly_braces: true
no_unneeded_final_method: true
no_unreachable_default_argument_value: true
no_unset_cast: true
no_unset_on_property: false
no_unused_imports: true
no_useless_else: true
no_useless_return: true
no_useless_sprintf: true
no_whitespace_before_comma_in_array:
after_heredoc: true
no_whitespace_in_blank_line: true
non_printable_character: true
normalize_index_brace: true
not_operator_with_space: false
not_operator_with_successor_space: false
nullable_type_declaration_for_default_null_value: true
object_operator_without_whitespace: true
operator_linebreak: true
ordered_class_elements:
order:
- use_trait
ordered_imports:
sort_algorithm: alpha
imports_order:
- class
- const
- function
ordered_interfaces: false
ordered_traits: true
php_unit_construct: true
php_unit_dedicate_assert:
target: newest
php_unit_dedicate_assert_internal_type: true
php_unit_expectation: true
php_unit_fqcn_annotation: true
php_unit_internal_class: true
php_unit_method_casing: true
php_unit_mock: true
php_unit_mock_short_will_return: true
php_unit_namespaced: true
php_unit_no_expectation_annotation: true
php_unit_ordered_covers: true
php_unit_set_up_tear_down_visibility: true
php_unit_size_class: true
php_unit_strict: false
php_unit_test_annotation: true
php_unit_test_case_static_method_calls: true
php_unit_test_class_requires_covers: false
phpdoc_add_missing_param_annotation:
only_untyped: false
phpdoc_align:
tags:
- return
- throws
- type
- var
- property
- method
- param
align: vertical
phpdoc_annotation_without_dot: true
phpdoc_indent: true
phpdoc_inline_tag: true
phpdoc_inline_tag_normalizer: true
phpdoc_line_span:
const: single
property: single
method: multi
phpdoc_no_access: true
phpdoc_no_alias_tag: true
phpdoc_no_empty_return: true
phpdoc_no_package: true
phpdoc_no_useless_inheritdoc: true
phpdoc_order: true
phpdoc_order_by_value: true
phpdoc_return_self_reference: true
phpdoc_scalar: true
phpdoc_separation: true
phpdoc_single_line_var_spacing: true
phpdoc_summary: true
phpdoc_tag_casing: true
phpdoc_tag_type:
tags:
inheritDoc: inline
phpdoc_to_comment: false
phpdoc_to_param_type: true
phpdoc_to_return_type: true
phpdoc_trim: true
phpdoc_trim_consecutive_blank_line_separation: true
phpdoc_types: true
phpdoc_types_order:
sort_algorithm: none
null_adjustment: always_last
phpdoc_var_annotation_correct_order: true
phpdoc_var_without_name: true
pow_to_exponentiation: true
protected_to_private: true
psr0: false
psr4: false
psr_autoloading: false
random_api_migration:
replacements:
mt_rand: random_int
rand: random_int
regular_callable_call: true
return_assignment: true
return_type_declaration: true
self_accessor: true
self_static_accessor: true
semicolon_after_instruction: true
set_type_to_cast: true
short_scalar_cast: true
simple_to_complex_string_variable: true
simplified_if_return: 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
single_line_comment_style: true
single_line_throw: false
single_quote:
strings_containing_single_quote_chars: false
single_space_after_construct: true
single_trait_insert_per_statement: true
space_after_semicolon: true
standardize_increment: true
standardize_not_equals: true
static_lambda: true
strict_comparison: true
strict_param: true
string_line_ending: true
switch_case_semicolon_to_colon: true
switch_case_space: true
switch_continue_to_break: true
ternary_operator_spaces: true
ternary_to_elvis_operator: true
ternary_to_null_coalescing: true
trailing_comma_in_multiline_array:
after_heredoc: true
trim_array_spaces: true
unary_operator_spaces: true
use_arrow_functions: true
visibility_required:
elements:
- const
- method
- property
void_return: true
whitespace_after_comma_in_array: true
yoda_style:
equal: false
identical: false
less_and_greater: false
*/
if (\PHP_SAPI === 'cli' && !class_exists(\PhpCsFixer\Config::class)) {
$binFixer = __DIR__ . '/vendor/bin/php-cs-fixer';
$which = static function ($program, $default = null) {
exec(sprintf('command -v %s', escapeshellarg($program)), $output, $resultCode);
if ($resultCode === 0) {
return trim($output[0]);
}
return $default;
};
$findExistsFile = static function (array $files): ?string {
foreach ($files as $file) {
if ($file !== null && is_file($file)) {
return $file;
}
}
return null;
};
$fixerBinaries = [
__DIR__ . '/vendor/bin/php-cs-fixer',
__DIR__ . '/tools/php-cs-fixer/vendor/bin/php-cs-fixer',
$which('php-cs-fixer'),
isset($_SERVER['COMPOSER_HOME']) ? $_SERVER['COMPOSER_HOME'] . '/vendor/bin/php-cs-fixer' : null,
];
$fixerBin = $findExistsFile($fixerBinaries) ?? 'php-cs-fixer';
$phpBin = $_SERVER['_'] ?? 'php';
if (!is_file($binFixer)) {
$binFixer = 'php-cs-fixer';
}
$dryRun = !in_array('--force', $_SERVER['argv'], true);
$commandFormat = '%s %s fix --config %s --diff --ansi -vv%s';
$command = sprintf(
$commandFormat,
escapeshellarg($phpBin),
escapeshellarg($fixerBin),
escapeshellarg(__FILE__),
$dryRun ? ' --dry-run' : ''
);
$outputCommand = sprintf(
$commandFormat,
$phpBin,
strpos($fixerBin, ' ') === false ? $fixerBin : escapeshellarg($fixerBin),
escapeshellarg(__FILE__),
$dryRun ? ' --dry-run' : ''
);
$command = escapeshellarg($binFixer) . ' fix --config ' . escapeshellarg(__FILE__) . ' --diff-format udiff --ansi -vv';
if ($dryRun) {
$command .= ' --dry-run';
}
fwrite(\STDOUT, "\e[22;94m" . $outputCommand . "\e[m\n\n");
system($command, $returnCode);
if ($dryRun || $returnCode === 8) {
@ -2025,9 +1738,16 @@ if (\PHP_SAPI === 'cli' && !class_exists(\PhpCsFixer\Config::class)) {
fwrite(\STDOUT, " [DEBUG] Dry run php-cs-fixer config.\e[K\n");
fwrite(\STDOUT, " Only shows which files would have been modified.\e[K\n");
fwrite(\STDOUT, " To apply the rules, use the --force option:\e[K\n\e[K\n");
fwrite(\STDOUT, " \e[1;40;92mphp {$_SERVER['argv'][0]} --force\e[K\n\e[0m\n");
fwrite(
\STDOUT,
sprintf(
" \e[1;40;92m%s %s --force\e[K\n\e[0m\n",
basename($phpBin),
$_SERVER['argv'][0]
)
);
} elseif ($returnCode !== 0) {
fwrite(\STDERR, "\n\e[1;41;97m\e[K\n ERROR CODE: {$returnCode}\e[K\n\e[0m\n");
fwrite(\STDERR, sprintf("\n\e[1;41;97m\e[K\n ERROR CODE: %s\e[K\n\e[0m\n", $returnCode));
}
exit($returnCode);
@ -2035,11 +1755,12 @@ if (\PHP_SAPI === 'cli' && !class_exists(\PhpCsFixer\Config::class)) {
return (new \PhpCsFixer\Config())
->setUsingCache(true)
->setCacheFile(__DIR__ . '/.php_cs.cache')
->setCacheFile(__DIR__ . '/.php-cs-fixer.cache')
->setRules($rules)
->setRiskyAllowed(true)
->setFinder(
\PhpCsFixer\Finder::create()
->ignoreUnreadableDirs()
->in(__DIR__)
)
;

View File

@ -22,8 +22,8 @@
"require": {
"php": "^7.4 || ^8.0",
"ext-zlib": "*",
"psr/http-message": "^1.0",
"symfony/finder": "^3.0 || ^4.0 || ^5.0"
"psr/http-message": "*",
"symfony/finder": "*"
},
"require-dev": {
"ext-iconv": "*",
@ -34,10 +34,10 @@
"ext-dom": "*",
"guzzlehttp/psr7": "^1.6",
"phpunit/phpunit": "^9",
"symfony/var-dumper": "^5.0",
"friendsofphp/php-cs-fixer": "^2.18",
"symfony/var-dumper": "*",
"friendsofphp/php-cs-fixer": "^3.4.0",
"vimeo/psalm": "^4.6",
"symfony/http-foundation": "^5.2"
"symfony/http-foundation": "*"
},
"autoload": {
"psr-4": {

View File

@ -33,260 +33,260 @@ class PKCryptContext
private const CRC_TABLE = [
0x00000000,
0x77073096,
0xee0e612c,
0x990951ba,
0x076dc419,
0x706af48f,
0xe963a535,
0x9e6495a3,
0x0edb8832,
0x79dcb8a4,
0xe0d5e91e,
0x97d2d988,
0x09b64c2b,
0x7eb17cbd,
0xe7b82d07,
0x90bf1d91,
0x1db71064,
0x6ab020f2,
0xf3b97148,
0x84be41de,
0x1adad47d,
0x6ddde4eb,
0xf4d4b551,
0x83d385c7,
0x136c9856,
0x646ba8c0,
0xfd62f97a,
0x8a65c9ec,
0x14015c4f,
0x63066cd9,
0xfa0f3d63,
0x8d080df5,
0x3b6e20c8,
0x4c69105e,
0xd56041e4,
0xa2677172,
0x3c03e4d1,
0x4b04d447,
0xd20d85fd,
0xa50ab56b,
0x35b5a8fa,
0x42b2986c,
0xdbbbc9d6,
0xacbcf940,
0x32d86ce3,
0x45df5c75,
0xdcd60dcf,
0xabd13d59,
0x26d930ac,
0x51de003a,
0xc8d75180,
0xbfd06116,
0x21b4f4b5,
0x56b3c423,
0xcfba9599,
0xb8bda50f,
0x2802b89e,
0x5f058808,
0xc60cd9b2,
0xb10be924,
0x2f6f7c87,
0x58684c11,
0xc1611dab,
0xb6662d3d,
0x76dc4190,
0x01db7106,
0x98d220bc,
0xefd5102a,
0x71b18589,
0x06b6b51f,
0x9fbfe4a5,
0xe8b8d433,
0x7807c9a2,
0x0f00f934,
0x9609a88e,
0xe10e9818,
0x7f6a0dbb,
0x086d3d2d,
0x91646c97,
0xe6635c01,
0x6b6b51f4,
0x1c6c6162,
0x856530d8,
0xf262004e,
0x6c0695ed,
0x1b01a57b,
0x8208f4c1,
0xf50fc457,
0x65b0d9c6,
0x12b7e950,
0x8bbeb8ea,
0xfcb9887c,
0x62dd1ddf,
0x15da2d49,
0x8cd37cf3,
0xfbd44c65,
0x4db26158,
0x3ab551ce,
0xa3bc0074,
0xd4bb30e2,
0x4adfa541,
0x3dd895d7,
0xa4d1c46d,
0xd3d6f4fb,
0x4369e96a,
0x346ed9fc,
0xad678846,
0xda60b8d0,
0x44042d73,
0x33031de5,
0xaa0a4c5f,
0xdd0d7cc9,
0x5005713c,
0x270241aa,
0xbe0b1010,
0xc90c2086,
0x5768b525,
0x206f85b3,
0xb966d409,
0xce61e49f,
0x5edef90e,
0x29d9c998,
0xb0d09822,
0xc7d7a8b4,
0x59b33d17,
0x2eb40d81,
0xb7bd5c3b,
0xc0ba6cad,
0xedb88320,
0x9abfb3b6,
0x03b6e20c,
0x74b1d29a,
0xead54739,
0x9dd277af,
0x04db2615,
0x73dc1683,
0xe3630b12,
0x94643b84,
0x0d6d6a3e,
0x7a6a5aa8,
0xe40ecf0b,
0x9309ff9d,
0x0a00ae27,
0x7d079eb1,
0xf00f9344,
0x8708a3d2,
0x1e01f268,
0x6906c2fe,
0xf762575d,
0x806567cb,
0x196c3671,
0x6e6b06e7,
0xfed41b76,
0x89d32be0,
0x10da7a5a,
0x67dd4acc,
0xf9b9df6f,
0x8ebeeff9,
0x17b7be43,
0x60b08ed5,
0xd6d6a3e8,
0xa1d1937e,
0x38d8c2c4,
0x4fdff252,
0xd1bb67f1,
0xa6bc5767,
0x3fb506dd,
0x48b2364b,
0xd80d2bda,
0xaf0a1b4c,
0x36034af6,
0x41047a60,
0xdf60efc3,
0xa867df55,
0x316e8eef,
0x4669be79,
0xcb61b38c,
0xbc66831a,
0x256fd2a0,
0x5268e236,
0xcc0c7795,
0xbb0b4703,
0x220216b9,
0x5505262f,
0xc5ba3bbe,
0xb2bd0b28,
0x2bb45a92,
0x5cb36a04,
0xc2d7ffa7,
0xb5d0cf31,
0x2cd99e8b,
0x5bdeae1d,
0x9b64c2b0,
0xec63f226,
0x756aa39c,
0x026d930a,
0x9c0906a9,
0xeb0e363f,
0xEE0E612C,
0x990951BA,
0x076DC419,
0x706AF48F,
0xE963A535,
0x9E6495A3,
0x0EDB8832,
0x79DCB8A4,
0xE0D5E91E,
0x97D2D988,
0x09B64C2B,
0x7EB17CBD,
0xE7B82D07,
0x90BF1D91,
0x1DB71064,
0x6AB020F2,
0xF3B97148,
0x84BE41DE,
0x1ADAD47D,
0x6DDDE4EB,
0xF4D4B551,
0x83D385C7,
0x136C9856,
0x646BA8C0,
0xFD62F97A,
0x8A65C9EC,
0x14015C4F,
0x63066CD9,
0xFA0F3D63,
0x8D080DF5,
0x3B6E20C8,
0x4C69105E,
0xD56041E4,
0xA2677172,
0x3C03E4D1,
0x4B04D447,
0xD20D85FD,
0xA50AB56B,
0x35B5A8FA,
0x42B2986C,
0xDBBBC9D6,
0xACBCF940,
0x32D86CE3,
0x45DF5C75,
0xDCD60DCF,
0xABD13D59,
0x26D930AC,
0x51DE003A,
0xC8D75180,
0xBFD06116,
0x21B4F4B5,
0x56B3C423,
0xCFBA9599,
0xB8BDA50F,
0x2802B89E,
0x5F058808,
0xC60CD9B2,
0xB10BE924,
0x2F6F7C87,
0x58684C11,
0xC1611DAB,
0xB6662D3D,
0x76DC4190,
0x01DB7106,
0x98D220BC,
0xEFD5102A,
0x71B18589,
0x06B6B51F,
0x9FBFE4A5,
0xE8B8D433,
0x7807C9A2,
0x0F00F934,
0x9609A88E,
0xE10E9818,
0x7F6A0DBB,
0x086D3D2D,
0x91646C97,
0xE6635C01,
0x6B6B51F4,
0x1C6C6162,
0x856530D8,
0xF262004E,
0x6C0695ED,
0x1B01A57B,
0x8208F4C1,
0xF50FC457,
0x65B0D9C6,
0x12B7E950,
0x8BBEB8EA,
0xFCB9887C,
0x62DD1DDF,
0x15DA2D49,
0x8CD37CF3,
0xFBD44C65,
0x4DB26158,
0x3AB551CE,
0xA3BC0074,
0xD4BB30E2,
0x4ADFA541,
0x3DD895D7,
0xA4D1C46D,
0xD3D6F4FB,
0x4369E96A,
0x346ED9FC,
0xAD678846,
0xDA60B8D0,
0x44042D73,
0x33031DE5,
0xAA0A4C5F,
0xDD0D7CC9,
0x5005713C,
0x270241AA,
0xBE0B1010,
0xC90C2086,
0x5768B525,
0x206F85B3,
0xB966D409,
0xCE61E49F,
0x5EDEF90E,
0x29D9C998,
0xB0D09822,
0xC7D7A8B4,
0x59B33D17,
0x2EB40D81,
0xB7BD5C3B,
0xC0BA6CAD,
0xEDB88320,
0x9ABFB3B6,
0x03B6E20C,
0x74B1D29A,
0xEAD54739,
0x9DD277AF,
0x04DB2615,
0x73DC1683,
0xE3630B12,
0x94643B84,
0x0D6D6A3E,
0x7A6A5AA8,
0xE40ECF0B,
0x9309FF9D,
0x0A00AE27,
0x7D079EB1,
0xF00F9344,
0x8708A3D2,
0x1E01F268,
0x6906C2FE,
0xF762575D,
0x806567CB,
0x196C3671,
0x6E6B06E7,
0xFED41B76,
0x89D32BE0,
0x10DA7A5A,
0x67DD4ACC,
0xF9B9DF6F,
0x8EBEEFF9,
0x17B7BE43,
0x60B08ED5,
0xD6D6A3E8,
0xA1D1937E,
0x38D8C2C4,
0x4FDFF252,
0xD1BB67F1,
0xA6BC5767,
0x3FB506DD,
0x48B2364B,
0xD80D2BDA,
0xAF0A1B4C,
0x36034AF6,
0x41047A60,
0xDF60EFC3,
0xA867DF55,
0x316E8EEF,
0x4669BE79,
0xCB61B38C,
0xBC66831A,
0x256FD2A0,
0x5268E236,
0xCC0C7795,
0xBB0B4703,
0x220216B9,
0x5505262F,
0xC5BA3BBE,
0xB2BD0B28,
0x2BB45A92,
0x5CB36A04,
0xC2D7FFA7,
0xB5D0CF31,
0x2CD99E8B,
0x5BDEAE1D,
0x9B64C2B0,
0xEC63F226,
0x756AA39C,
0x026D930A,
0x9C0906A9,
0xEB0E363F,
0x72076785,
0x05005713,
0x95bf4a82,
0xe2b87a14,
0x7bb12bae,
0x0cb61b38,
0x92d28e9b,
0xe5d5be0d,
0x7cdcefb7,
0x0bdbdf21,
0x86d3d2d4,
0xf1d4e242,
0x68ddb3f8,
0x1fda836e,
0x81be16cd,
0xf6b9265b,
0x6fb077e1,
0x18b74777,
0x88085ae6,
0xff0f6a70,
0x66063bca,
0x11010b5c,
0x8f659eff,
0xf862ae69,
0x616bffd3,
0x166ccf45,
0xa00ae278,
0xd70dd2ee,
0x4e048354,
0x3903b3c2,
0xa7672661,
0xd06016f7,
0x4969474d,
0x3e6e77db,
0xaed16a4a,
0xd9d65adc,
0x40df0b66,
0x37d83bf0,
0xa9bcae53,
0xdebb9ec5,
0x47b2cf7f,
0x30b5ffe9,
0xbdbdf21c,
0xcabac28a,
0x53b39330,
0x24b4a3a6,
0xbad03605,
0xcdd70693,
0x54de5729,
0x23d967bf,
0xb3667a2e,
0xc4614ab8,
0x5d681b02,
0x2a6f2b94,
0xb40bbe37,
0xc30c8ea1,
0x5a05df1b,
0x2d02ef8d,
0x95BF4A82,
0xE2B87A14,
0x7BB12BAE,
0x0CB61B38,
0x92D28E9B,
0xE5D5BE0D,
0x7CDCEFB7,
0x0BDBDF21,
0x86D3D2D4,
0xF1D4E242,
0x68DDB3F8,
0x1FDA836E,
0x81BE16CD,
0xF6B9265B,
0x6FB077E1,
0x18B74777,
0x88085AE6,
0xFF0F6A70,
0x66063BCA,
0x11010B5C,
0x8F659EFF,
0xF862AE69,
0x616BFFD3,
0x166CCF45,
0xA00AE278,
0xD70DD2EE,
0x4E048354,
0x3903B3C2,
0xA7672661,
0xD06016F7,
0x4969474D,
0x3E6E77DB,
0xAED16A4A,
0xD9D65ADC,
0x40DF0B66,
0x37D83BF0,
0xA9BCAE53,
0xDEBB9EC5,
0x47B2CF7F,
0x30B5FFE9,
0xBDBDF21C,
0xCABAC28A,
0x53B39330,
0x24B4A3A6,
0xBAD03605,
0xCDD70693,
0x54DE5729,
0x23D967BF,
0xB3667A2E,
0xC4614AB8,
0x5D681B02,
0x2A6F2B94,
0xB40BBE37,
0xC30C8EA1,
0x5A05DF1B,
0x2D02EF8D,
];
/** @var array encryption keys */
@ -317,7 +317,7 @@ class PKCryptContext
$byte = 0;
foreach (unpack('C*', $header) as $byte) {
$byte = ($byte ^ $this->decryptByte()) & 0xff;
$byte = ($byte ^ $this->decryptByte()) & 0xFF;
$this->updateKeys($byte);
}
@ -331,7 +331,7 @@ class PKCryptContext
$decryptContent = '';
foreach (unpack('C*', $content) as $byte) {
$byte = ($byte ^ $this->decryptByte()) & 0xff;
$byte = ($byte ^ $this->decryptByte()) & 0xFF;
$this->updateKeys($byte);
$decryptContent .= \chr($byte);
}
@ -346,7 +346,7 @@ class PKCryptContext
{
$temp = $this->keys[2] | 2;
return (($temp * ($temp ^ 1)) >> 8) & 0xffffff;
return (($temp * ($temp ^ 1)) >> 8) & 0xFFFFFF;
}
/**
@ -355,9 +355,9 @@ class PKCryptContext
private function updateKeys(int $charAt): void
{
$this->keys[0] = $this->crc32($this->keys[0], $charAt);
$this->keys[1] += ($this->keys[0] & 0xff);
$this->keys[1] += ($this->keys[0] & 0xFF);
$this->keys[1] = MathUtil::toSignedInt32($this->keys[1] * 134775813 + 1);
$this->keys[2] = MathUtil::toSignedInt32($this->crc32($this->keys[2], ($this->keys[1] >> 24) & 0xff));
$this->keys[2] = MathUtil::toSignedInt32($this->crc32($this->keys[2], ($this->keys[1] >> 24) & 0xFF));
}
/**
@ -365,7 +365,7 @@ class PKCryptContext
*/
private function crc32(int $oldCrc, int $charAt): int
{
return (($oldCrc >> 8) & 0xffffff) ^ self::CRC_TABLE[($oldCrc ^ $charAt) & 0xff];
return (($oldCrc >> 8) & 0xFFFFFF) ^ self::CRC_TABLE[($oldCrc ^ $charAt) & 0xFF];
}
public function encryptString(string $content): string
@ -381,7 +381,7 @@ class PKCryptContext
private function encryptByte(int $byte): int
{
$tempVal = $byte ^ $this->decryptByte() & 0xff;
$tempVal = $byte ^ $this->decryptByte() & 0xFF;
$this->updateKeys($byte);
return $tempVal;

View File

@ -63,9 +63,9 @@ class PKDecryptionStreamFilter extends \php_user_filter
// init check byte
if ($entry->isDataDescriptorEnabled()) {
$this->checkByte = ($entry->getDosTime() >> 8) & 0xff;
$this->checkByte = ($entry->getDosTime() >> 8) & 0xFF;
} else {
$this->checkByte = ($entry->getCrc() >> 24) & 0xff;
$this->checkByte = ($entry->getCrc() >> 24) & 0xFF;
}
$this->readLength = 0;
@ -77,10 +77,15 @@ class PKDecryptionStreamFilter extends \php_user_filter
/**
* Decryption filter.
*
* @throws ZipAuthenticationException
*
* @todo USE FFI in php 7.4
* @noinspection PhpDocSignatureInspection
*
* @param mixed $in
* @param mixed $out
* @param mixed $consumed
* @param mixed $closing
*
* @throws ZipAuthenticationException
*/
public function filter($in, $out, &$consumed, $closing): int
{

View File

@ -66,7 +66,7 @@ class PKEncryptionStreamFilter extends \php_user_filter
$this->context = new PKCryptContext($password);
$crc = $entry->isDataDescriptorRequired() || $entry->getCrc() === ZipEntry::UNKNOWN
? ($entry->getDosTime() & 0x0000ffff) << 16
? ($entry->getDosTime() & 0x0000FFFF) << 16
: $entry->getCrc();
try {
@ -75,8 +75,8 @@ class PKEncryptionStreamFilter extends \php_user_filter
throw new \RuntimeException('Oops, our server is bust and cannot generate any random data.', 1, $e);
}
$headerBytes[PKCryptContext::STD_DEC_HDR_SIZE - 1] = pack('c', ($crc >> 24) & 0xff);
$headerBytes[PKCryptContext::STD_DEC_HDR_SIZE - 2] = pack('c', ($crc >> 16) & 0xff);
$headerBytes[PKCryptContext::STD_DEC_HDR_SIZE - 1] = pack('c', ($crc >> 24) & 0xFF);
$headerBytes[PKCryptContext::STD_DEC_HDR_SIZE - 2] = pack('c', ($crc >> 16) & 0xFF);
$this->headerBytes = $headerBytes;
$this->writeLength = 0;
@ -91,6 +91,11 @@ class PKEncryptionStreamFilter extends \php_user_filter
* @todo USE FFI in php 7.4
*
* @noinspection PhpDocSignatureInspection
*
* @param mixed $in
* @param mixed $out
* @param mixed $consumed
* @param mixed $closing
*/
public function filter($in, $out, &$consumed, $closing): int
{

View File

@ -70,8 +70,14 @@ class WinZipAesDecryptionStreamFilter extends \php_user_filter
}
/**
* @throws ZipAuthenticationException
* @noinspection PhpDocSignatureInspection
*
* @param mixed $in
* @param mixed $out
* @param mixed $consumed
* @param mixed $closing
*
* @throws ZipAuthenticationException
*/
public function filter($in, $out, &$consumed, $closing): int
{

View File

@ -91,7 +91,7 @@ class ResponseStream implements StreamInterface
}
/**
* {@inheritdoc}
* {@inheritDoc}
*
* @noinspection PhpMissingReturnTypeInspection
*/
@ -195,7 +195,7 @@ class ResponseStream implements StreamInterface
}
/**
* {@inheritdoc}
* {@inheritDoc}
*/
public function seek($offset, $whence = \SEEK_SET): void
{
@ -211,7 +211,7 @@ class ResponseStream implements StreamInterface
}
/**
* {@inheritdoc}
* {@inheritDoc}
*/
public function write($string)
{
@ -229,7 +229,7 @@ class ResponseStream implements StreamInterface
}
/**
* {@inheritdoc}
* {@inheritDoc}
*/
public function read($length): string
{

View File

@ -216,7 +216,7 @@ class ZipReader
protected function findEndOfCentralDirectory(): bool
{
$max = $this->size - ZipConstants::END_CD_MIN_LEN;
$min = $max >= 0xffff ? $max - 0xffff : 0;
$min = $max >= 0xFFFF ? $max - 0xFFFF : 0;
// Search for End of central directory record.
for ($position = $max; $position >= $min; $position--) {
fseek($this->inStream, $position);
@ -319,7 +319,7 @@ class ZipReader
throw new ZipException('ZIP file spanning/splitting is not supported!');
}
if ($entryCount < 0 || $entryCount > 0x7fffffff) {
if ($entryCount < 0 || $entryCount > 0x7FFFFFFF) {
throw new ZipException('Total Number Of Entries In The Central Directory out of range!');
}

View File

@ -143,13 +143,13 @@ class ZipWriter
$size = $nameLength + $extraLength;
if ($size > 0xffff) {
if ($size > 0xFFFF) {
throw new ZipException(
sprintf(
'%s (the total size of %s bytes for the name, extra fields and comment exceeds the maximum size of %d bytes)',
$entry->getName(),
$size,
0xffff
0xFFFF
)
);
}
@ -221,7 +221,7 @@ class ZipWriter
$size = \strlen($extraData);
if ($size > 0xffff) {
if ($size > 0xFFFF) {
throw new ZipException(
sprintf(
'Size extra out of range: %d. Extra data: %s',
@ -678,7 +678,7 @@ class ZipWriter
): void {
$cdEntriesCount = \count($this->zipContainer);
$cdEntriesZip64 = $cdEntriesCount > 0xffff;
$cdEntriesZip64 = $cdEntriesCount > 0xFFFF;
$cdSizeZip64 = $centralDirectorySize > ZipConstants::ZIP64_MAGIC;
$cdOffsetZip64 = $centralDirectoryOffset > ZipConstants::ZIP64_MAGIC;
@ -768,10 +768,10 @@ class ZipWriter
0,
// total number of entries in the
// central directory on this disk 2 bytes
$cdEntriesZip64 ? 0xffff : $cdEntriesCount,
$cdEntriesZip64 ? 0xFFFF : $cdEntriesCount,
// total number of entries in
// the central directory 2 bytes
$cdEntriesZip64 ? 0xffff : $cdEntriesCount,
$cdEntriesZip64 ? 0xFFFF : $cdEntriesCount,
// size of the central directory 4 bytes
$cdSizeZip64 ? ZipConstants::ZIP64_MAGIC : $centralDirectorySize,
// offset of start of central

View File

@ -53,7 +53,7 @@ class ExtraFieldsCollection implements \ArrayAccess, \Countable, \Iterator
private function validateHeaderId(int $headerId): void
{
if ($headerId < 0 || $headerId > 0xffff) {
if ($headerId < 0 || $headerId > 0xFFFF) {
throw new \InvalidArgumentException('$headerId out of range');
}
}

View File

@ -29,7 +29,7 @@ final class ApkAlignmentExtraField implements ZipExtraField
* well as for aligning the entries's data. See ZIP
* appnote.txt section 4.5 Extensible data fields.
*/
public const HEADER_ID = 0xd935;
public const HEADER_ID = 0xD935;
/** @var int */
public const ALIGNMENT_BYTES = 4;

View File

@ -56,7 +56,7 @@ use PhpZip\Model\ZipEntry;
final class AsiExtraField implements ZipExtraField
{
/** @var int Header id */
public const HEADER_ID = 0x756e;
public const HEADER_ID = 0x756E;
public const USER_GID_PID = 1000;

View File

@ -186,7 +186,7 @@ final class NewUnixExtraField implements ZipExtraField
public function setUid(int $uid): void
{
$this->uid = $uid & 0xffffffff;
$this->uid = $uid & 0xFFFFFFFF;
}
public function getGid(): int
@ -196,7 +196,7 @@ final class NewUnixExtraField implements ZipExtraField
public function setGid(int $gid): void
{
$this->gid = $gid & 0xffffffff;
$this->gid = $gid & 0xFFFFFFFF;
}
public function getVersion(): int

View File

@ -24,7 +24,7 @@ use PhpZip\Model\ZipEntry;
final class NtfsExtraField implements ZipExtraField
{
/** @var int Header id */
public const HEADER_ID = 0x000a;
public const HEADER_ID = 0x000A;
/** @var int Tag ID */
public const TIME_ATTR_TAG = 0x0001;

View File

@ -73,7 +73,7 @@ final class UnrecognizedExtraField implements ZipExtraField
}
/**
* {@inheritdoc}
* {@inheritDoc}
*/
public function packLocalFileData(): string
{
@ -81,7 +81,7 @@ final class UnrecognizedExtraField implements ZipExtraField
}
/**
* {@inheritdoc}
* {@inheritDoc}
*/
public function packCentralDirData(): string
{

View File

@ -94,7 +94,7 @@ final class ZipExtraDriver
public static function getClassNameOrNull(int $headerId): ?string
{
if ($headerId < 0 || $headerId > 0xffff) {
if ($headerId < 0 || $headerId > 0xFFFF) {
throw new \InvalidArgumentException('$headerId out of range: ' . $headerId);
}

View File

@ -252,7 +252,7 @@ class ZipContainer extends ImmutableZipContainer
if ($archiveComment !== null && $archiveComment !== '') {
$length = \strlen($archiveComment);
if ($length > 0xffff) {
if ($length > 0xFFFF) {
throw new InvalidArgumentException('Length comment out of range');
}
}

View File

@ -201,7 +201,7 @@ class ZipEntry
$length = \strlen($name);
if ($length > 0xffff) {
if ($length > 0xFFFF) {
throw new InvalidArgumentException('Illegal zip entry name parameter');
}
@ -298,7 +298,7 @@ class ZipEntry
*/
public function setCreatedOS(int $platform): self
{
if ($platform < 0x00 || $platform > 0xff) {
if ($platform < 0x00 || $platform > 0xFF) {
throw new InvalidArgumentException('Platform out of range');
}
$this->createdOS = $platform;
@ -318,7 +318,7 @@ class ZipEntry
*/
public function setExtractedOS(int $platform): self
{
if ($platform < 0x00 || $platform > 0xff) {
if ($platform < 0x00 || $platform > 0xFF) {
throw new InvalidArgumentException('Platform out of range');
}
$this->extractedOS = $platform;
@ -485,7 +485,7 @@ class ZipEntry
*/
public function setGeneralPurposeBitFlags(int $gpbf): self
{
if ($gpbf < 0x0000 || $gpbf > 0xffff) {
if ($gpbf < 0x0000 || $gpbf > 0xFFFF) {
throw new InvalidArgumentException('general purpose bit flags out of range');
}
$this->generalPurposeBitFlags = $gpbf;
@ -617,7 +617,7 @@ class ZipEntry
*/
public function setCompressionMethod(int $compressionMethod): self
{
if ($compressionMethod < 0x0000 || $compressionMethod > 0xffff) {
if ($compressionMethod < 0x0000 || $compressionMethod > 0xFFFF) {
throw new InvalidArgumentException('method out of range: ' . $compressionMethod);
}
@ -658,7 +658,7 @@ class ZipEntry
public function setDosTime(int $dosTime): self
{
if (\PHP_INT_SIZE === 8) {
if ($dosTime < 0x00000000 || $dosTime > 0xffffffff) {
if ($dosTime < 0x00000000 || $dosTime > 0xFFFFFFFF) {
throw new InvalidArgumentException('DosTime out of range');
}
}
@ -706,7 +706,7 @@ class ZipEntry
$this->externalAttributes = $externalAttributes;
if (\PHP_INT_SIZE === 8) {
if ($externalAttributes < 0x00000000 || $externalAttributes > 0xffffffff) {
if ($externalAttributes < 0x00000000 || $externalAttributes > 0xFFFFFFFF) {
throw new InvalidArgumentException('external attributes out of range: ' . $externalAttributes);
}
}
@ -735,7 +735,7 @@ class ZipEntry
*/
public function setInternalAttributes(int $internalAttributes): self
{
if ($internalAttributes < 0x0000 || $internalAttributes > 0xffff) {
if ($internalAttributes < 0x0000 || $internalAttributes > 0xFFFF) {
throw new InvalidArgumentException('internal attributes out of range');
}
$this->internalAttributes = $internalAttributes;
@ -847,7 +847,7 @@ class ZipEntry
if ($comment !== null) {
$commentLength = \strlen($comment);
if ($commentLength > 0xffff) {
if ($commentLength > 0xFFFF) {
throw new InvalidArgumentException('Comment too long');
}

View File

@ -65,12 +65,12 @@ class DateTimeConverter
}
// date_default_timezone_set('UTC');
return mktime(
(($dosTime >> 11) & 0x1f), // hours
(($dosTime >> 5) & 0x3f), // minutes
(($dosTime << 1) & 0x3e), // seconds
(($dosTime >> 21) & 0x0f), // month
(($dosTime >> 16) & 0x1f), // day
((($dosTime >> 25) & 0x7f) + 1980) // year
(($dosTime >> 11) & 0x1F), // hours
(($dosTime >> 5) & 0x3F), // minutes
(($dosTime << 1) & 0x3E), // seconds
(($dosTime >> 21) & 0x0F), // month
(($dosTime >> 16) & 0x1F), // day
((($dosTime >> 25) & 0x7F) + 1980) // year
);
}

View File

@ -24,7 +24,7 @@ final class MathUtil
public static function toSignedInt32(int $int): int
{
if (\PHP_INT_SIZE === 8) {
$int &= 0xffffffff;
$int &= 0xFFFFFFFF;
if ($int & 0x80000000) {
return $int - 0x100000000;

View File

@ -21,7 +21,7 @@ use PhpZip\Model\Extra\Fields\UnicodeCommentExtraField;
final class UnicodeCommentExtraFieldTest extends AbstractUnicodeExtraFieldTest
{
/**
* {@inheritdoc}
* {@inheritDoc}
*/
protected function getUnicodeExtraFieldClassName()
{

View File

@ -23,7 +23,7 @@ use PhpZip\Model\Extra\Fields\UnicodePathExtraField;
final class UnicodePathExtraFieldTest extends AbstractUnicodeExtraFieldTest
{
/**
* {@inheritdoc}
* {@inheritDoc}
*/
protected function getUnicodeExtraFieldClassName()
{

View File

@ -66,9 +66,9 @@ final class Zip64ExtraFieldTest extends TestCase
self::assertSame($extraField->getDiskStart(), $diskStart);
$zipEntry = new ZipEntry('entry');
$zipEntry->setUncompressedSize($uncompressedSize !== null ? ZipConstants::ZIP64_MAGIC : 0xfffff);
$zipEntry->setCompressedSize($compressedSize !== null ? ZipConstants::ZIP64_MAGIC : 0xffff);
$zipEntry->setLocalHeaderOffset($localHeaderOffset !== null ? ZipConstants::ZIP64_MAGIC : 0xfff);
$zipEntry->setUncompressedSize($uncompressedSize !== null ? ZipConstants::ZIP64_MAGIC : 0xFFFFF);
$zipEntry->setCompressedSize($compressedSize !== null ? ZipConstants::ZIP64_MAGIC : 0xFFFF);
$zipEntry->setLocalHeaderOffset($localHeaderOffset !== null ? ZipConstants::ZIP64_MAGIC : 0xFFF);
if ($localBinaryData !== null) {
self::assertSame($localBinaryData, $extraField->packLocalFileData());

View File

@ -36,7 +36,7 @@ class Zip64Test extends ZipTestCase
static::markTestSkipped('Only php-64 bit.');
}
$countFiles = 0xffff + 1;
$countFiles = 0xFFFF + 1;
$zipFile = new ZipFile();
for ($i = 0; $i < $countFiles; $i++) {

View File

@ -380,7 +380,7 @@ class ZipEntryTest extends TestCase
{
return [
[-1],
[0xff + 1],
[0xFF + 1],
];
}
@ -808,7 +808,7 @@ class ZipEntryTest extends TestCase
{
return [
[-1],
[0xffffffff + 1],
[0xFFFFFFFF + 1],
];
}
@ -951,7 +951,7 @@ class ZipEntryTest extends TestCase
{
return [
[-1],
[0xffffffff + 1],
[0xFFFFFFFF + 1],
];
}
@ -980,7 +980,7 @@ class ZipEntryTest extends TestCase
{
return [
[-1],
[0xffff + 1],
[0xFFFF + 1],
];
}
@ -1066,7 +1066,7 @@ class ZipEntryTest extends TestCase
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Comment too long');
$longComment = random_bytes(0xffff + 1);
$longComment = random_bytes(0xFFFF + 1);
$zipEntry = new ZipEntry('entry');
$zipEntry->setComment($longComment);
}

View File

@ -747,7 +747,7 @@ class ZipFileTest extends ZipTestCase
$comment = 'Very long comment' . \PHP_EOL
. 'Очень длинный комментарий' . \PHP_EOL;
$comment = str_repeat($comment, (int) ceil(0xffff / \strlen($comment)) + \strlen($comment) + 1);
$comment = str_repeat($comment, (int) ceil(0xFFFF / \strlen($comment)) + \strlen($comment) + 1);
$zipFile = new ZipFile();
$zipFile->setArchiveComment($comment);
@ -840,7 +840,7 @@ class ZipFileTest extends ZipTestCase
$comment = 'Very long comment' . \PHP_EOL
. 'Очень длинный комментарий' . \PHP_EOL;
$comment = str_repeat($comment, (int) ceil(0xffff / \strlen($comment)) + \strlen($comment) + 1);
$comment = str_repeat($comment, (int) ceil(0xFFFF / \strlen($comment)) + \strlen($comment) + 1);
$zipFile = new ZipFile();
$zipFile->addFile(__FILE__, 'test');
@ -925,7 +925,7 @@ class ZipFileTest extends ZipTestCase
[-10],
[-2],
[10],
[0xffff],
[0xFFFF],
];
}