-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade PHPStan to v1.10.57 #437
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,7 +115,9 @@ public static function intValueSupported($num) { | |
// check if integers are 64-bit | ||
static $hasINT64 = null; | ||
if ($hasINT64 === null) { // 10x faster than is_null() | ||
$hasINT64 = is_int(pow(2, 31)); // 32-bit int are limited to (2^31)-1 | ||
/** @var int|float|false $bigInt */ | ||
$bigInt = pow(2, 31); | ||
$hasINT64 = is_int($bigInt); // 32-bit int are limited to (2^31)-1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if (!$hasINT64 && !defined('PHP_INT_MIN')) { | ||
define('PHP_INT_MIN', ~PHP_INT_MAX); | ||
} | ||
|
@@ -1517,7 +1519,7 @@ public static function RGADamplitude2dB($amplitude) { | |
public static function GetDataImageSize($imgData, &$imageinfo=array()) { | ||
if (PHP_VERSION_ID >= 50400) { | ||
$GetDataImageSize = @getimagesizefromstring($imgData, $imageinfo); | ||
if ($GetDataImageSize === false || !isset($GetDataImageSize[0], $GetDataImageSize[1])) { | ||
if ($GetDataImageSize === false) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
return false; | ||
} | ||
$GetDataImageSize['height'] = $GetDataImageSize[0]; | ||
|
@@ -1545,7 +1547,7 @@ public static function GetDataImageSize($imgData, &$imageinfo=array()) { | |
fwrite($tmp, $imgData); | ||
fclose($tmp); | ||
$GetDataImageSize = @getimagesize($tempfilename, $imageinfo); | ||
if (($GetDataImageSize === false) || !isset($GetDataImageSize[0]) || !isset($GetDataImageSize[1])) { | ||
if ($GetDataImageSize === false) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
return false; | ||
} | ||
$GetDataImageSize['height'] = $GetDataImageSize[0]; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -409,10 +409,10 @@ public function __construct() { | |
$memoryLimit = ini_get('memory_limit'); | ||
if (preg_match('#([0-9]+) ?M#i', $memoryLimit, $matches)) { | ||
// could be stored as "16M" rather than 16777216 for example | ||
$memoryLimit = $matches[1] * 1048576; | ||
$memoryLimit = (int) $matches[1] * 1048576; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} elseif (preg_match('#([0-9]+) ?G#i', $memoryLimit, $matches)) { // The 'G' modifier is available since PHP 5.1.0 | ||
// could be stored as "2G" rather than 2147483648 for example | ||
$memoryLimit = $matches[1] * 1073741824; | ||
$memoryLimit = (int) $matches[1] * 1073741824; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
$this->memory_limit = $memoryLimit; | ||
|
||
|
@@ -446,7 +446,7 @@ public function __construct() { | |
} | ||
// Check for magic_quotes_gpc | ||
if (function_exists('get_magic_quotes_gpc')) { | ||
if (get_magic_quotes_gpc()) { // @phpstan-ignore-line | ||
if (get_magic_quotes_gpc()) { | ||
$this->startup_error .= 'magic_quotes_gpc must be disabled before running getID3(). Surround getid3 block by set_magic_quotes_gpc(0) and set_magic_quotes_gpc(1).'."\n"; | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -499,13 +499,17 @@ public function Analyze() { | |
$offset += 2; | ||
$thisfile_asf_scriptcommandobject['command_types_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); | ||
$offset += 2; | ||
for ($CommandTypesCounter = 0; $CommandTypesCounter < $thisfile_asf_scriptcommandobject['command_types_count']; $CommandTypesCounter++) { | ||
$CommandTypeNameLength = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2; // 2 bytes per character | ||
$offset += 2; | ||
$thisfile_asf_scriptcommandobject['command_types'][$CommandTypesCounter]['name'] = substr($ASFHeaderData, $offset, $CommandTypeNameLength); | ||
$offset += $CommandTypeNameLength; | ||
if ($thisfile_asf_scriptcommandobject['command_types_count'] > 0) { | ||
$thisfile_asf_scriptcommandobject['command_types'] = array(); | ||
for ($CommandTypesCounter = 0; $CommandTypesCounter < (int) $thisfile_asf_scriptcommandobject['command_types_count']; $CommandTypesCounter++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. False positive
|
||
$CommandTypeNameLength = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2; // 2 bytes per character | ||
$offset += 2; | ||
$thisfile_asf_scriptcommandobject['command_types'][$CommandTypesCounter] = array(); | ||
$thisfile_asf_scriptcommandobject['command_types'][$CommandTypesCounter]['name'] = substr($ASFHeaderData, $offset, $CommandTypeNameLength); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
$offset += $CommandTypeNameLength; | ||
} | ||
} | ||
for ($CommandsCounter = 0; $CommandsCounter < $thisfile_asf_scriptcommandobject['commands_count']; $CommandsCounter++) { | ||
for ($CommandsCounter = 0; $CommandsCounter < (int) $thisfile_asf_scriptcommandobject['commands_count']; $CommandsCounter++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. False positive
|
||
$thisfile_asf_scriptcommandobject['commands'][$CommandsCounter]['presentation_time'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4)); | ||
$offset += 4; | ||
$thisfile_asf_scriptcommandobject['commands'][$CommandsCounter]['type_index'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); | ||
|
@@ -554,6 +558,8 @@ public function Analyze() { | |
break; | ||
} | ||
$thisfile_asf_markerobject['markers_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4)); | ||
/** @var int|float|false $totalMakersCount */ | ||
$totalMakersCount = $thisfile_asf_markerobject['markers_count']; | ||
$offset += 4; | ||
$thisfile_asf_markerobject['reserved_2'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); | ||
$offset += 2; | ||
|
@@ -565,7 +571,8 @@ public function Analyze() { | |
$offset += 2; | ||
$thisfile_asf_markerobject['name'] = substr($ASFHeaderData, $offset, $thisfile_asf_markerobject['name_length']); | ||
$offset += $thisfile_asf_markerobject['name_length']; | ||
for ($MarkersCounter = 0; $MarkersCounter < $thisfile_asf_markerobject['markers_count']; $MarkersCounter++) { | ||
for ($MarkersCounter = 0; $MarkersCounter < $totalMakersCount; $MarkersCounter++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. False positive
|
||
$thisfile_asf_markerobject['markers'][$MarkersCounter] = array(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
$thisfile_asf_markerobject['markers'][$MarkersCounter]['offset'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8)); | ||
$offset += 8; | ||
$thisfile_asf_markerobject['markers'][$MarkersCounter]['presentation_time'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8)); | ||
|
@@ -615,7 +622,7 @@ public function Analyze() { | |
} | ||
$thisfile_asf_bitratemutualexclusionobject['stream_numbers_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); | ||
$offset += 2; | ||
for ($StreamNumberCounter = 0; $StreamNumberCounter < $thisfile_asf_bitratemutualexclusionobject['stream_numbers_count']; $StreamNumberCounter++) { | ||
for ($StreamNumberCounter = 0; $StreamNumberCounter < (int) $thisfile_asf_bitratemutualexclusionobject['stream_numbers_count']; $StreamNumberCounter++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. False positive
|
||
$thisfile_asf_bitratemutualexclusionobject['stream_numbers'][$StreamNumberCounter] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); | ||
$offset += 2; | ||
} | ||
|
@@ -759,7 +766,7 @@ public function Analyze() { | |
$thisfile_asf_extendedcontentdescriptionobject['objectsize'] = $NextObjectSize; | ||
$thisfile_asf_extendedcontentdescriptionobject['content_descriptors_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); | ||
$offset += 2; | ||
for ($ExtendedContentDescriptorsCounter = 0; $ExtendedContentDescriptorsCounter < $thisfile_asf_extendedcontentdescriptionobject['content_descriptors_count']; $ExtendedContentDescriptorsCounter++) { | ||
for ($ExtendedContentDescriptorsCounter = 0; $ExtendedContentDescriptorsCounter < (int) $thisfile_asf_extendedcontentdescriptionobject['content_descriptors_count']; $ExtendedContentDescriptorsCounter++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. False positive
|
||
// shortcut | ||
$thisfile_asf_extendedcontentdescriptionobject['content_descriptors'][$ExtendedContentDescriptorsCounter] = array(); | ||
$thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current = &$thisfile_asf_extendedcontentdescriptionobject['content_descriptors'][$ExtendedContentDescriptorsCounter]; | ||
|
@@ -957,7 +964,8 @@ public function Analyze() { | |
$thisfile_asf_streambitratepropertiesobject['objectsize'] = $NextObjectSize; | ||
$thisfile_asf_streambitratepropertiesobject['bitrate_records_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); | ||
$offset += 2; | ||
for ($BitrateRecordsCounter = 0; $BitrateRecordsCounter < $thisfile_asf_streambitratepropertiesobject['bitrate_records_count']; $BitrateRecordsCounter++) { | ||
for ($BitrateRecordsCounter = 0; $BitrateRecordsCounter < (int) $thisfile_asf_streambitratepropertiesobject['bitrate_records_count']; $BitrateRecordsCounter++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. False positive
|
||
$thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter] = array(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
$thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter]['flags_raw'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); | ||
$offset += 2; | ||
$thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter]['flags']['stream_number'] = $thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter]['flags_raw'] & 0x007F; | ||
|
@@ -1006,7 +1014,7 @@ public function Analyze() { | |
if (isset($thisfile_asf_streambitratepropertiesobject['bitrate_records_count'])) { | ||
$ASFbitrateAudio = 0; | ||
$ASFbitrateVideo = 0; | ||
for ($BitrateRecordsCounter = 0; $BitrateRecordsCounter < $thisfile_asf_streambitratepropertiesobject['bitrate_records_count']; $BitrateRecordsCounter++) { | ||
for ($BitrateRecordsCounter = 0; $BitrateRecordsCounter < (int) $thisfile_asf_streambitratepropertiesobject['bitrate_records_count']; $BitrateRecordsCounter++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. False positive
|
||
if (isset($thisfile_asf_codeclistobject['codec_entries'][$BitrateRecordsCounter])) { | ||
switch ($thisfile_asf_codeclistobject['codec_entries'][$BitrateRecordsCounter]['type_raw']) { | ||
case 1: | ||
|
@@ -1030,7 +1038,7 @@ public function Analyze() { | |
$thisfile_video['bitrate'] = $ASFbitrateVideo; | ||
} | ||
} | ||
if (isset($thisfile_asf['stream_properties_object']) && is_array($thisfile_asf['stream_properties_object'])) { | ||
if (isset($thisfile_asf['stream_properties_object'])) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
$thisfile_audio['bitrate'] = 0; | ||
$thisfile_video['bitrate'] = 0; | ||
|
@@ -1067,7 +1075,7 @@ public function Analyze() { | |
} | ||
|
||
if (!empty($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'])) { // @phpstan-ignore-line | ||
foreach ($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'] as $dummy => $dataarray) { | ||
foreach ($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'] as $dummy => $dataarray) { // @phpstan-ignore-line | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. False positive
|
||
if (isset($dataarray['flags']['stream_number']) && ($dataarray['flags']['stream_number'] == $streamnumber)) { | ||
$thisfile_asf_audiomedia_currentstream['bitrate'] = $dataarray['bitrate']; | ||
$thisfile_audio['bitrate'] += $dataarray['bitrate']; | ||
|
@@ -1153,7 +1161,7 @@ public function Analyze() { | |
$thisfile_asf_videomedia_currentstream['format_data']['codec_data'] = substr($streamdata['type_specific_data'], $videomediaoffset); | ||
|
||
if (!empty($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'])) { // @phpstan-ignore-line | ||
foreach ($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'] as $dummy => $dataarray) { | ||
foreach ($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'] as $dummy => $dataarray) { // @phpstan-ignore-line | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. False positive
|
||
if (isset($dataarray['flags']['stream_number']) && ($dataarray['flags']['stream_number'] == $streamnumber)) { | ||
$thisfile_asf_videomedia_currentstream['bitrate'] = $dataarray['bitrate']; | ||
$thisfile_video['streams'][$streamnumber]['bitrate'] = $dataarray['bitrate']; | ||
|
@@ -1266,10 +1274,13 @@ public function Analyze() { | |
$thisfile_asf_simpleindexobject['maximum_packet_count'] = getid3_lib::LittleEndian2Int(substr($SimpleIndexObjectData, $offset, 4)); | ||
$offset += 4; | ||
$thisfile_asf_simpleindexobject['index_entries_count'] = getid3_lib::LittleEndian2Int(substr($SimpleIndexObjectData, $offset, 4)); | ||
/** @var int|float|false $totalIndexEntriesCount */ | ||
$totalIndexEntriesCount = $thisfile_asf_simpleindexobject['index_entries_count']; | ||
$offset += 4; | ||
|
||
$IndexEntriesData = $SimpleIndexObjectData.$this->fread(6 * $thisfile_asf_simpleindexobject['index_entries_count']); | ||
for ($IndexEntriesCounter = 0; $IndexEntriesCounter < $thisfile_asf_simpleindexobject['index_entries_count']; $IndexEntriesCounter++) { | ||
$IndexEntriesData = $SimpleIndexObjectData.$this->fread(6 * $totalIndexEntriesCount); | ||
for ($IndexEntriesCounter = 0; $IndexEntriesCounter < $totalIndexEntriesCount; $IndexEntriesCounter++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. False positive
|
||
$thisfile_asf_simpleindexobject['index_entries'][$IndexEntriesCounter] = array(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
$thisfile_asf_simpleindexobject['index_entries'][$IndexEntriesCounter]['packet_number'] = getid3_lib::LittleEndian2Int(substr($IndexEntriesData, $offset, 4)); | ||
$offset += 4; | ||
$thisfile_asf_simpleindexobject['index_entries'][$IndexEntriesCounter]['packet_count'] = getid3_lib::LittleEndian2Int(substr($IndexEntriesData, $offset, 4)); | ||
|
@@ -1320,9 +1331,10 @@ public function Analyze() { | |
$offset += 4; | ||
|
||
$ASFIndexObjectData .= $this->fread(4 * $thisfile_asf_asfindexobject['index_specifiers_count']); | ||
for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) { | ||
for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < (int) $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. False positive
|
||
$IndexSpecifierStreamNumber = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 2)); | ||
$offset += 2; | ||
$thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter] = array(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
$thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['stream_number'] = $IndexSpecifierStreamNumber; | ||
$thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['index_type'] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 2)); | ||
$offset += 2; | ||
|
@@ -1331,17 +1343,19 @@ public function Analyze() { | |
|
||
$ASFIndexObjectData .= $this->fread(4); | ||
$thisfile_asf_asfindexobject['index_entry_count'] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4)); | ||
/** @var int|float|false $totalIndexEntryCount */ | ||
$totalIndexEntryCount = $thisfile_asf_asfindexobject['index_entry_count']; | ||
$offset += 4; | ||
|
||
$ASFIndexObjectData .= $this->fread(8 * $thisfile_asf_asfindexobject['index_specifiers_count']); | ||
for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) { | ||
for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < (int) $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. False positive
|
||
$thisfile_asf_asfindexobject['block_positions'][$IndexSpecifiersCounter] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 8)); | ||
$offset += 8; | ||
} | ||
|
||
$ASFIndexObjectData .= $this->fread(4 * $thisfile_asf_asfindexobject['index_specifiers_count'] * $thisfile_asf_asfindexobject['index_entry_count']); | ||
for ($IndexEntryCounter = 0; $IndexEntryCounter < $thisfile_asf_asfindexobject['index_entry_count']; $IndexEntryCounter++) { | ||
for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) { | ||
for ($IndexEntryCounter = 0; $IndexEntryCounter < $totalIndexEntryCount; $IndexEntryCounter++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. False positive
|
||
for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < (int) $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. False positive
|
||
$thisfile_asf_asfindexobject['offsets'][$IndexSpecifiersCounter][$IndexEntryCounter] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4)); | ||
$offset += 4; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.