Skip to content
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

Merged
merged 1 commit into from
Feb 2, 2024

Conversation

StudioMaX
Copy link
Collaborator

No description provided.

$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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  119    Negated boolean expression is always false.                                                                
  119    Result of && is always false.                                                                              

@@ -243,7 +243,7 @@ public function analyze($filename, $filesize=null, $original_filename='', $fp=nu
$result = parent::analyze($filename, $filesize, $original_filename, $fp);

// Save result
if (isset($key) && file_exists($filename)) {
if ($key !== null) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  246    Right side of && is always true.

@@ -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) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1520   Offset 0 on array{0: int, 1: int, 2: int, 3: string, mime: string, channels?: int, bits?: int} in isset()
         always exists and is not nullable.
  1520   Offset 1 on array{0: int, 1: int, 2: int, 3: string, mime: string, channels?: int, bits?: int} in isset()
         always exists and is not nullable.

@@ -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) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1548   Offset 0 on array{0: int, 1: int, 2: int, 3: string, mime: string, channels?: int, bits?: int} in isset()
         always exists and is not nullable.
  1548   Offset 1 on array{0: int, 1: int, 2: int, 3: string, mime: string, channels?: int, bits?: int} in isset()
         always exists and is not nullable.

@@ -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;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  412    Binary operation "*" between string and 1048576 results in an error.

} 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;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  415    Binary operation "*" between string and 1073741824 results in an error.

$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++) {
Copy link
Collaborator Author

@StudioMaX StudioMaX Feb 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive

  502    Comparison operation "<" between int<0, max> and ((non-empty-array<literal-string&non-falsy-string,
         mixed>)|float|int|string|false) results in an error.

$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);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  505    Cannot assign offset 'name' to string.

}
for ($CommandsCounter = 0; $CommandsCounter < $thisfile_asf_scriptcommandobject['commands_count']; $CommandsCounter++) {
for ($CommandsCounter = 0; $CommandsCounter < (int) $thisfile_asf_scriptcommandobject['commands_count']; $CommandsCounter++) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive

  508    Comparison operation "<" between int<0, max> and ((non-empty-array<int<0,
         max>|(literal-string&non-falsy-string), mixed>)|float|int|string|false) results in an error.

@@ -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++) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive

  568    Comparison operation "<" between int<0, max> and ((non-empty-array<literal-string&non-falsy-string,
         mixed>)|float|int|string|false) results in an error.

@@ -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++) {
$thisfile_asf_markerobject['markers'][$MarkersCounter] = array();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  569    Cannot assign offset 'offset' to string.

@@ -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++) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive

  618    Comparison operation "<" between int<0, max> and ((non-empty-array<literal-string&non-falsy-string,
         array{encrypted: bool}|float|int|string|false>)|float|int|string|false) results in an error.

@@ -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++) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive

  762    Comparison operation "<" between int<0, max> and ((non-empty-array<literal-string&non-falsy-string,
         array{encrypted?: bool}|float|int|string|false>)|float|int|string|false) results in an error.

@@ -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++) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive

  960    Comparison operation "<" between int<0, max> and ((non-empty-array<literal-string&non-falsy-string,
         mixed>)|float|int|string|false) results in an error.

@@ -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++) {
$thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter] = array();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  961    Cannot assign offset 'flags_raw' to string.

@@ -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++) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive

  1009   Comparison operation "<" between int<0, max> and ((non-empty-array<int<0,
         max>|(literal-string&non-falsy-string), mixed>)|float|int|string|false) results in an error.

@@ -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'])) {
Copy link
Collaborator Author

@StudioMaX StudioMaX Feb 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1033   Right side of && is always true.

@@ -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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive

  1070   Offset 'bitrate_records' does not exist on array<int<0, 127>, array<literal-string&non-falsy-string,
         array{encrypted: bool}|float|int|string|false>>.

@@ -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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive

  1156   Offset 'bitrate_records' does not exist on array<int<0, 127>, array<literal-string&non-falsy-string,
         array{encrypted: bool}|float|int|string|false>>.

$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++) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive

  1272   Comparison operation "<" between int<0, max> and ((array<literal-string&non-falsy-string,
         mixed>)|float|int|string|false) results in an error.

for ($IndexEntriesCounter = 0; $IndexEntriesCounter < $thisfile_asf_simpleindexobject['index_entries_count']; $IndexEntriesCounter++) {
$IndexEntriesData = $SimpleIndexObjectData.$this->fread(6 * $totalIndexEntriesCount);
for ($IndexEntriesCounter = 0; $IndexEntriesCounter < $totalIndexEntriesCount; $IndexEntriesCounter++) {
$thisfile_asf_simpleindexobject['index_entries'][$IndexEntriesCounter] = array();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1273   Cannot assign offset 'packet_number' to string.

@@ -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++) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive

  1323   Comparison operation "<" between int<0, max> and ((array<literal-string&non-falsy-string,
         mixed>)|float|int|string|false) results in an error.

$IndexSpecifierStreamNumber = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 2));
$offset += 2;
$thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter] = array();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1326   Cannot assign offset 'stream_number' to string.

$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++) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive

  1337   Comparison operation "<" between int<0, max> and ((array<int<0, max>|(literal-string&non-falsy-string),
         mixed>)|float|int|string|false) results in an error.

$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++) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive

  1343   Comparison operation "<" between int<0, max> and ((array<int<0, max>|(literal-string&non-falsy-string),
         mixed>)|float|int|string|false) results in an error.

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++) {
for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < (int) $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive

  1344   Comparison operation "<" between int<0, max> and ((array<int<0, max>|(literal-string&non-falsy-string),
         mixed>)|float|int|string|false) results in an error.

} elseif (strlen($lat_deg) == 4) { // [+-]DDMM.M
$ISO6709parsed['latitude'] = (($lat_sign == '-') ? -1 : 1) * floatval(ltrim(substr($lat_deg, 0, 2), '0')) + floatval(ltrim(substr($lat_deg, 2, 2), '0').$lat_deg_dec / 60);
$ISO6709parsed['latitude'] = (($lat_sign == '-') ? -1 : 1) * (int) ltrim(substr($lat_deg, 0, 2), '0') + ((float) (ltrim(substr($lat_deg, 2, 2), '0').$lat_deg_dec) / 60);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  161    Binary operation "/" between string and 60 results in an error.

} elseif (strlen($lat_deg) == 6) { // [+-]DDMMSS.S
$ISO6709parsed['latitude'] = (($lat_sign == '-') ? -1 : 1) * floatval(ltrim(substr($lat_deg, 0, 2), '0')) + floatval((int) ltrim(substr($lat_deg, 2, 2), '0') / 60) + floatval(ltrim(substr($lat_deg, 4, 2), '0').$lat_deg_dec / 3600);
$ISO6709parsed['latitude'] = (($lat_sign == '-') ? -1 : 1) * (int) ltrim(substr($lat_deg, 0, 2), '0') + ((int) ltrim(substr($lat_deg, 2, 2), '0') / 60) + ((float) (ltrim(substr($lat_deg, 4, 2), '0').$lat_deg_dec) / 3600);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  163    Binary operation "/" between string and 3600 results in an error.

} elseif (strlen($lon_deg) == 5) { // [+-]DDDMM.M
$ISO6709parsed['longitude'] = (($lon_sign == '-') ? -1 : 1) * floatval(ltrim(substr($lon_deg, 0, 2), '0')) + floatval(ltrim(substr($lon_deg, 2, 2), '0').$lon_deg_dec / 60);
$ISO6709parsed['longitude'] = (($lon_sign == '-') ? -1 : 1) * (int) ltrim(substr($lon_deg, 0, 2), '0') + ((float) (ltrim(substr($lon_deg, 2, 2), '0').$lon_deg_dec) / 60);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  169    Binary operation "/" between string and 60 results in an error.

} elseif (strlen($lon_deg) == 7) { // [+-]DDDMMSS.S
$ISO6709parsed['longitude'] = (($lon_sign == '-') ? -1 : 1) * floatval(ltrim(substr($lon_deg, 0, 2), '0')) + floatval((int) ltrim(substr($lon_deg, 2, 2), '0') / 60) + floatval(ltrim(substr($lon_deg, 4, 2), '0').$lon_deg_dec / 3600);
$ISO6709parsed['longitude'] = (($lon_sign == '-') ? -1 : 1) * (int) ltrim(substr($lon_deg, 0, 2), '0') + ((int) ltrim(substr($lon_deg, 2, 2), '0') / 60) + ((float) (ltrim(substr($lon_deg, 4, 2), '0').$lon_deg_dec) / 3600);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  171    Binary operation "/" between string and 3600 results in an error.

} elseif (strlen($alt_deg) == 5) { // [+-]DDDMM.M
$ISO6709parsed['altitude'] = (($alt_sign == '-') ? -1 : 1) * floatval(ltrim(substr($alt_deg, 0, 2), '0')) + floatval(ltrim(substr($alt_deg, 2, 2), '0').$alt_deg_dec / 60);
$ISO6709parsed['altitude'] = (($alt_sign == '-') ? -1 : 1) * (int) ltrim(substr($alt_deg, 0, 2), '0') + ((float) (ltrim(substr($alt_deg, 2, 2), '0').$alt_deg_dec) / 60);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  177    Binary operation "/" between string and 60 results in an error.

} elseif (strlen($alt_deg) == 7) { // [+-]DDDMMSS.S
$ISO6709parsed['altitude'] = (($alt_sign == '-') ? -1 : 1) * floatval(ltrim(substr($alt_deg, 0, 2), '0')) + floatval((int) ltrim(substr($alt_deg, 2, 2), '0') / 60) + floatval(ltrim(substr($alt_deg, 4, 2), '0').$alt_deg_dec / 3600);
$ISO6709parsed['altitude'] = (($alt_sign == '-') ? -1 : 1) * (int) ltrim(substr($alt_deg, 0, 2), '0') + ((int) ltrim(substr($alt_deg, 2, 2), '0') / 60) + ((float) (ltrim(substr($alt_deg, 4, 2), '0').$alt_deg_dec) / 3600);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  179    Binary operation "/" between string and 3600 results in an error.

@@ -1979,16 +1979,16 @@ public function QuicktimeParseAtom($atomname, $atomsize, $atom_data, $baseoffset
foreach (array('latitude','longitude') as $latlon) {
preg_match('#^([0-9]{1,3})([0-9]{2}\\.[0-9]+)$#', $GPS_this_GPRMC['raw'][$latlon], $matches);
list($dummy, $deg, $min) = $matches;
$GPS_this_GPRMC[$latlon] = $deg + ($min / 60);
$GPS_this_GPRMC[$latlon] = (int) $deg + ((float) $min / 60);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1982   Binary operation "/" between string and 60 results in an error.


if (!isset($info['bitrate'])) {
$info['bitrate'] = ((($info['avdataend'] - $info['avdataoffset']) / $info['playtime_seconds']) * 8);
}

} elseif (isset($thisfile_riff_audio) && !isset($thisfile_riff_video)) {
} elseif ($thisfile_riff_audio !== null && $thisfile_riff_video === null) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1375   Variable $thisfile_riff_video in isset() always exists and is always null.

@@ -1695,7 +1695,7 @@ public function ParseRIFF($startoffset, $maxoffset) {
break;
}
$thisindex = 0;
if (isset($RIFFchunk[$chunkname]) && is_array($RIFFchunk[$chunkname])) {
if (isset($RIFFchunk[$chunkname])) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1698   Right side of && is always true.

@@ -111,7 +111,7 @@ public function Analyze() {
$TicksAtCurrentBPM = 0;
while ($eventsoffset < strlen($trackdata)) {
$eventid = 0;
if (isset($MIDIevents[$tracknumber]) && is_array($MIDIevents[$tracknumber])) {
if (isset($MIDIevents[$tracknumber])) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  114    Right side of && is always true.

@@ -137,7 +137,7 @@ public function Analyze() {

case 'tRNS': // Transparency
$thisfile_png_chunk_type_text['header'] = $chunk;
switch ($thisfile_png['IHDR']['raw']['color_type']) {
switch ($thisfile_png['IHDR']['raw']['color_type']) { // @phpstan-ignore-line
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive

  140    Offset 'color_type' does not exist on non-empty-array<int,
         non-empty-array<'blend_op'|'crc'|'data'|'data_length'|'delay'|'delay_den'|'delay_num'|'dispose_op'|'flags'|'height'|'sequence_number'|'type_raw'|'type_text'|'width'|'x_offset'|'y_offset'|int,
         non-empty-array<'ancilliary'|'blend_op'|'crc'|'data'|'data_length'|'delay'|'delay_den'|'delay_num'|'dispose_op'|'flags'|'height'|'private'|'reserved'|'safe_to_copy'|'sequence_number'|'type_raw'|'type_text'|'width'|'x_offset'|'y_offset'|int,
         array{ancilliary: bool, private: bool, reserved: bool, safe_to_copy: bool}|array{sequence_number:
         float|int|false, width: float|int|false, height: float|int|false, x_offset: float|int|false, y_offset:
         float|int|false, delay_num: float|int|false, delay_den: float|int|false, dispose_op: float|int|false,
         ...}|bool|float|int|string>|bool|float|int|string>|bool|float|int|string>|float|int.

@@ -160,7 +160,7 @@ public function Analyze() {
break;

default:
$this->warning('Unhandled color_type in tRNS chunk: '.$thisfile_png['IHDR']['raw']['color_type']);
$this->warning('Unhandled color_type in tRNS chunk: '.$thisfile_png['IHDR']['raw']['color_type']); // @phpstan-ignore-line
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive

  163    Offset 'color_type' does not exist on non-empty-array<int,
         non-empty-array<'blend_op'|'crc'|'data'|'data_length'|'delay'|'delay_den'|'delay_num'|'dispose_op'|'flags'|'height'|'sequence_number'|'type_raw'|'type_text'|'width'|'x_offset'|'y_offset'|int,
         non-empty-array<'ancilliary'|'blend_op'|'crc'|'data'|'data_length'|'delay'|'delay_den'|'delay_num'|'dispose_op'|'flags'|'height'|'private'|'reserved'|'safe_to_copy'|'sequence_number'|'type_raw'|'type_text'|'width'|'x_offset'|'y_offset'|int,
         array{ancilliary: bool, private: bool, reserved: bool, safe_to_copy: bool}|array{sequence_number:
         float|int|false, width: float|int|false, height: float|int|false, x_offset: float|int|false, y_offset:
         float|int|false, delay_num: float|int|false, delay_den: float|int|false, dispose_op: float|int|false,
         ...}|bool|float|int|string>|bool|float|int|string>|bool|float|int|string>|float|int.

@@ -273,7 +273,7 @@ public function Analyze() {

case 'bKGD': // Background Color
$thisfile_png_chunk_type_text['header'] = $chunk;
switch ($thisfile_png['IHDR']['raw']['color_type']) {
switch ($thisfile_png['IHDR']['raw']['color_type']) { // @phpstan-ignore-line
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive

  276    Offset 'color_type' does not exist on non-empty-array<int,
         non-empty-array<'blend_op'|'crc'|'data'|'data_length'|'delay'|'delay_den'|'delay_num'|'dispose_op'|'flags'|'height'|'sequence_number'|'type_raw'|'type_text'|'width'|'x_offset'|'y_offset'|int,
         non-empty-array<'ancilliary'|'blend_op'|'crc'|'data'|'data_length'|'delay'|'delay_den'|'delay_num'|'dispose_op'|'flags'|'height'|'private'|'reserved'|'safe_to_copy'|'sequence_number'|'type_raw'|'type_text'|'width'|'x_offset'|'y_offset'|int,
         array{ancilliary: bool, private: bool, reserved: bool, safe_to_copy: bool}|array{sequence_number:
         float|int|false, width: float|int|false, height: float|int|false, x_offset: float|int|false, y_offset:
         float|int|false, delay_num: float|int|false, delay_den: float|int|false, dispose_op: float|int|false,
         ...}|bool|float|int|string>|bool|float|int|string>|bool|float|int|string>|float|int.

@@ -307,7 +307,7 @@ public function Analyze() {

case 'sBIT': // Significant Bits
$thisfile_png_chunk_type_text['header'] = $chunk;
switch ($thisfile_png['IHDR']['raw']['color_type']) {
switch ($thisfile_png['IHDR']['raw']['color_type']) { // @phpstan-ignore-line
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive

  310    Offset 'color_type' does not exist on non-empty-array<int,
         non-empty-array<'blend_op'|'crc'|'data'|'data_length'|'delay'|'delay_den'|'delay_num'|'dispose_op'|'flags'|'height'|'sequence_number'|'type_raw'|'type_text'|'width'|'x_offset'|'y_offset'|int,
         non-empty-array<'ancilliary'|'blend_op'|'crc'|'data'|'data_length'|'delay'|'delay_den'|'delay_num'|'dispose_op'|'flags'|'height'|'private'|'reserved'|'safe_to_copy'|'sequence_number'|'type_raw'|'type_text'|'width'|'x_offset'|'y_offset'|int,
         array{ancilliary: bool, private: bool, reserved: bool, safe_to_copy: bool}|array{sequence_number:
         float|int|false, width: float|int|false, height: float|int|false, x_offset: float|int|false, y_offset:
         float|int|false, delay_num: float|int|false, delay_den: float|int|false, dispose_op: float|int|false,
         ...}|bool|float|int|string>|bool|float|int|string>|bool|float|int|string>|float|int.

if (isset($thisfile_png_chunk_type_text) && is_array($thisfile_png_chunk_type_text)) {
$gIFgCounter = count($thisfile_png_chunk_type_text);
}
$gIFgCounter = count($thisfile_png_chunk_type_text);
Copy link
Collaborator Author

@StudioMaX StudioMaX Feb 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  426    Result of && is always true.
  426    Variable $thisfile_png_chunk_type_text in isset() always exists and is not nullable.

if (isset($thisfile_png_chunk_type_text) && is_array($thisfile_png_chunk_type_text)) {
$gIFxCounter = count($thisfile_png_chunk_type_text);
}
$gIFxCounter = count($thisfile_png_chunk_type_text);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  438    Result of && is always true.
  438    Variable $thisfile_png_chunk_type_text in isset() always exists and is not nullable.

if (isset($thisfile_png['IDAT']) && is_array($thisfile_png['IDAT'])) {
$idatinformationfieldindex = count($thisfile_png['IDAT']);
}
$idatinformationfieldindex = count($thisfile_png['IDAT']);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  450    Right side of && is always true.

@@ -272,7 +272,7 @@ public function getLyrics3Data($endoffset, $version, $length) {
*/
public function Lyrics3Timestamp2Seconds($rawtimestamp) {
if (preg_match('#^\\[([0-9]{2}):([0-9]{2})\\]$#', $rawtimestamp, $regs)) {
return (int) (($regs[1] * 60) + $regs[2]);
return (int) (((int) $regs[1] * 60) + (int) $regs[2]);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  275    Binary operation "*" between string and 60 results in an error.

@@ -250,7 +250,7 @@ public function RemoveID3v2() {
fwrite($fp_temp, $buffer, strlen($buffer));
}
fclose($fp_source);
if (getID3::is_writable($this->filename) && ($fp_source = fopen($this->filename, 'wb'))) {
if ($fp_source = fopen($this->filename, 'wb')) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  253    Left side of && is always true.

@@ -802,7 +802,7 @@ public function QuicktimeParseAtom($atomname, $atomsize, $atom_data, $baseoffset
}

$stsdEntriesDataOffset = 8;
for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
for ($i = 0; $i < (int) $atom_structure['number_entries']; $i++) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive

  805    Comparison operation "<" between int<0, max> and (non-empty-array<int, array{data: string, data_format:
         string, encoder_revision?: (float|int|false), encoder_vendor?: string, encoder_version?: (float|int|false),
         reference_index: (float|int|false), reserved: (float|int|false), size: (float|int|false),
         ...}>|float|int|string|false) results in an error.

@@ -1304,7 +1304,7 @@ public function ParseID3v2Frame(&$parsedFrame) {
// Adjustment $xx (xx ...)

$frame_offset = 0;
$parsedFrame['adjustmentbits'] = substr($parsedFrame['data'], $frame_offset++, 1);
$parsedFrame['adjustmentbits'] = ord(substr($parsedFrame['data'], $frame_offset++, 1));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1308   Binary operation "/" between string and 8 results in an error.

@StudioMaX StudioMaX marked this pull request as ready for review February 2, 2024 12:49
@JamesHeinrich JamesHeinrich merged commit fff2dc3 into JamesHeinrich:master Feb 2, 2024
15 checks passed
@StudioMaX StudioMaX deleted the update-phpstan branch February 4, 2024 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants