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

PHAN checks #4533

Closed
mdeweerd opened this issue Aug 29, 2023 · 10 comments
Closed

PHAN checks #4533

mdeweerd opened this issue Aug 29, 2023 · 10 comments

Comments

@mdeweerd
Copy link
Contributor

Hi

I have set up phan - a static code checker -, skipping quite a few messages already - https://github.com/mdeweerd/yii/tree/phan .

You may want to check out the remaining ones. If deemed ok, I'll update the "baseline" to ignore them.

Note: currently this CI is a bit annoying as the phan docker image does not contain git and "apk add git" fails quite often.

base/CSecurityManager.php:225 PhanUndeclaredConstant Reference to undeclared constant \MCRYPT_RAND. This will cause a thrown Error in php 8.0+.
base/CSecurityManager.php:268 PhanUndeclaredConstant Reference to undeclared constant \MCRYPT_MODE_CBC. This will cause a thrown Error in php 8.0+.
base/CSecurityManager.php:402 PhanUndeclaredConstant Reference to undeclared constant \MCRYPT_DEV_URANDOM. This will cause a thrown Error in php 8.0+.
base/CSecurityManager.php:479 PhanTypeMismatchArgumentInternal Argument 2 ($value) is 20 of type 20 but \ini_set() takes string
base/CSecurityManager.php:486 PhanPluginUseReturnValueInternalKnown Expected to use the return value of the internal function/method \session_regenerate_id
base/CSecurityManager.php:581 PhanUndeclaredConstant Reference to undeclared constant \MCRYPT_MODE_CBC. This will cause a thrown Error in php 8.0+.
caching/CCache.php:376 PhanParamSignatureMismatchInternal Declaration of function offsetUnset(string $id) : bool should be compatible with internal function offsetUnset(mixed $offset) : void
caching/CDummyCache.php:164 PhanParamSignatureMismatchInternal Declaration of function offsetUnset(string $id) : bool should be compatible with internal function offsetUnset(mixed $offset) : void
console/CConsoleCommand.php:135 PhanDeprecatedFunctionInternal Call to deprecated function \ReflectionParameter::isArray()
db/ar/CActiveRecord.php:1406 PhanTypeMismatchArgumentInternalReal Argument 1 ($callback) is [$this,$scope] of type array{0:static,1:?int|?string} but \call_user_func_array() takes callable
i18n/CDateFormatter.php:208 PhanTypeMismatchArgumentInternal Argument 1 ($string) is ($year % 100) of type int but \str_pad() takes string
i18n/CDateFormatter.php:402 PhanTypeMismatchArgumentInternal Argument 1 ($string) is $hour of type 12|int but \str_pad() takes string
i18n/CDateFormatter.php:440 PhanTypeMismatchArgumentInternal Argument 1 ($string) is $hour of type int but \str_pad() takes string
i18n/CDateFormatter.php:509 PhanTypeMismatchArgumentInternal Argument 4 ($month) is $date['mon'] of type string but \mktime() takes int
i18n/CDateFormatter.php:509 PhanTypeMismatchArgumentInternal Argument 6 ($year) is $date['year'] of type string but \mktime() takes int
utils/CFormatter.php:325 PhanTypeMismatchArgumentInternal Argument 3 ($subject) is $value of type float but \str_replace() takes array|string
validators/CEmailValidator.php:[107](https://github.com/mdeweerd/yii/actions/runs/6016815619/job/16322871860#step:5:108) PhanTypeMismatchArgumentNullableInternal Argument 1 ($hostname) is $domain of type ?string but \checkdnsrr() takes string (expected type to be non-nullable)
validators/CEmailValidator.php:207 PhanTypeMismatchArgumentNullableInternal Argument 2 ($flags) is IDNA_NONTRANSITIONAL_TO_ASCII of type ?array|?bool|?float|?int|?resource|?string but \idn_to_ascii() takes int (expected type to be non-nullable)
validators/CEmailValidator.php:207 PhanTypeMismatchArgumentNullableInternal Argument 3 ($variant) is INTL_IDNA_VARIANT_UTS46 of type ?array|?bool|?float|?int|?resource|?string but \idn_to_ascii() takes int (expected type to be non-nullable)
validators/CFileValidator.php:242 PhanUndeclaredConstant Reference to undeclared constant \FILEINFO_MIME. This will cause a thrown Error in php 8.0+.
validators/CUrlValidator.php:176 PhanTypeMismatchArgumentNullableInternal Argument 2 ($flags) is IDNA_NONTRANSITIONAL_TO_ASCII of type ?array|?bool|?float|?int|?resource|?string but \idn_to_ascii() takes int (expected type to be non-nullable)
validators/CUrlValidator.php:176 PhanTypeMismatchArgumentNullableInternal Argument 3 ($variant) is INTL_IDNA_VARIANT_UTS46 of type ?array|?bool|?float|?int|?resource|?string but \idn_to_ascii() takes int (expected type to be non-nullable)
validators/CUrlValidator.php:209 PhanTypeMismatchArgumentNullableInternal Argument 2 ($flags) is IDNA_NONTRANSITIONAL_TO_ASCII of type ?array|?bool|?float|?int|?resource|?string but \idn_to_utf8() takes int (expected type to be non-nullable)
validators/CUrlValidator.php:209 PhanTypeMismatchArgumentNullableInternal Argument 3 ($variant) is INTL_IDNA_VARIANT_UTS46 of type ?array|?bool|?float|?int|?resource|?string but \idn_to_utf8() takes int (expected type to be non-nullable)
web/CHttpSession.php:161 PhanUndeclaredConstant Reference to undeclared constant \PHP_SESSION_ACTIVE. This will cause a thrown Error in php 8.0+.
web/CHttpSession.php:256 PhanTypeMismatchArgumentInternal Argument 1 ($lifetime_or_options) is ['lifetime'=>$lifetime,'path'=>$path,'domain'=>$domain,'secure'=>$secure,'httponly'=>$httponly,'samesite'=>$samesite] of type array{lifetime:null,path:null,domain:null,secure:null,httponly:mixed,samesite:mixed} but \session_set_cookie_params() takes array{lifetime?:int,path?:string,domain?:?string,secure?:bool,httponly?:bool}
web/CHttpSession.php:262 PhanTypeMismatchArgumentInternalProbablyReal Argument 1 ($lifetime_or_options) is $lifetime of type null but \session_set_cookie_params() takes array{lifetime?:int,path?:string,domain?:?string,secure?:bool,httponly?:bool}
web/CHttpSession.php:262 PhanTypeMismatchArgumentInternalProbablyReal Argument 4 ($secure) is $secure of type null but \session_set_cookie_params() takes bool
web/CHttpSession.php:266 PhanTypeMismatchArgumentInternalProbablyReal Argument 1 ($lifetime_or_options) is $lifetime of type null but \session_set_cookie_params() takes array{lifetime?:int,path?:string,domain?:?string,secure?:bool,httponly?:bool}
web/CHttpSession.php:266 PhanTypeMismatchArgumentInternalProbablyReal Argument 2 ($path) is $path of type null but \session_set_cookie_params() takes string
web/CHttpSession.php:266 PhanTypeMismatchArgumentInternalProbablyReal Argument 4 ($secure) is $secure of type null but \session_set_cookie_params() takes bool
web/CHttpSession.php:268 PhanTypeMismatchArgumentInternalProbablyReal Argument 1 ($lifetime_or_options) is $lifetime of type null but \session_set_cookie_params() takes array{lifetime?:int,path?:string,domain?:?string,secure?:bool,httponly?:bool}
web/CHttpSession.php:268 PhanTypeMismatchArgumentInternalProbablyReal Argument 2 ($path) is $path of type null but \session_set_cookie_params() takes string
web/CHttpSession.php:268 PhanTypeMismatchArgumentInternalProbablyReal Argument 4 ($secure) is $secure of type null but \session_set_cookie_params() takes bool
web/CHttpSession.php:334 PhanTypeMismatchArgumentInternal Argument 2 ($value) is floor(($value * 21474836.47)) of type float but \ini_set() takes string
web/CHttpSession.php:335 PhanTypeMismatchArgumentInternal Argument 2 ($value) is 2147483647 of type 2147483647 but \ini_set() takes string
web/CHttpSession.php:375 PhanTypeMismatchArgumentInternal Argument 2 ($value) is $value of type int but \ini_set() takes string
web/CUrlManager.php:816 PhanTypeMismatchArgumentInternal Argument 2 ($haystack) is $this->verb of type string but \in_array() takes array
web/actions/CAction.php:100 PhanDeprecatedFunctionInternal Call to deprecated function \ReflectionParameter::isArray()
web/helpers/CJSON.php:[109](https://github.com/mdeweerd/yii/actions/runs/6016815619/job/16322871860#step:5:110) PhanTypeMismatchArgumentInternal Argument 3 ($subject) is (float)($var) of type float but \str_replace() takes array|string
web/helpers/CJSON.php:553 PhanCompatibleNegativeStringOffset Using negative string offsets is not supported before PHP 7.1 (emits an 'Uninitialized string offset' notice)
web/helpers/CJSON.php:554 PhanCompatibleNegativeStringOffset Using negative string offsets is not supported before PHP 7.1 (emits an 'Uninitialized string offset' notice)
web/helpers/CJavaScript.php:85 PhanTypeMismatchArgumentInternal Argument 3 ($subject) is (float)($value) of type float but \str_replace() takes array|string
web/services/CWebService.php:165 PhanTypeMismatchArgumentInternal Argument 2 ($value) is 0 of type 0 but \ini_set() takes string
web/services/CWebService.php:262 PhanUndeclaredConstant Reference to undeclared constant \SOAP_1_1. This will cause a thrown Error in php 8.0+.
web/services/CWebService.php:264 PhanUndeclaredConstant Reference to undeclared constant \SOAP_1_2. This will cause a thrown Error in php 8.0+.
web/widgets/CTextHighlighter.php:91 PhanUndeclaredConstant Reference to undeclared constant \HL_NUMBERS_LI. This will cause a thrown Error in php 8.0+.
web/widgets/CTextHighlighter.php:91 PhanUndeclaredConstant Reference to undeclared constant \HL_NUMBERS_TABLE. This will cause a thrown Error in php 8.0+.
@mdeweerd
Copy link
Contributor Author

I further update the flow which limits to the following messages.

These seem most relevant, the others are typing errors that need better hinting and are current automatically "resolved":

gii/components/Pear/Text/Diff/Engine/shell.php:41 PhanStaticCallToNonStatic Static call to non-static method \Text_Diff::_getTempDir() defined at gii/components/Pear/Text/Diff.php:226. This is an Error in PHP 8.0+.
messages/ca/yii.php:88 PhanPluginDuplicateArrayKey Duplicate/Equivalent array key value('Alias "{alias}" is invalid. Make sure it points to an existing directory or file.') detected in array - the earlier entry 'Alias "{alias}" is invalid. Make sure it points to an existing directory or file.' at line 87 will be ignored.

Extended list:

base/CComponent.php:148 PhanTypeMagicVoidWithReturn Found a return statement with a value in the implementation of the magic method \CComponent::__set, expected void return type
base/CComponent.php:215 PhanTypeMagicVoidWithReturn Found a return statement with a value in the implementation of the magic method \CComponent::__unset, expected void return type
base/CSecurityManager.php:479 PhanTypeMismatchArgumentInternal Argument 2 ($value) is 20 of type 20 but \ini_set() takes string
base/CSecurityManager.php:528 PhanTypeMissingReturn Method \CSecurityManager::validateEncryptionKey is declared to return bool in phpdoc but has no return value
caching/CCache.php:376 PhanParamSignatureMismatchInternal Declaration of function offsetUnset(string $id) : bool should be compatible with internal function offsetUnset(mixed $offset) : void
caching/CCache.php:376 PhanTypeMissingReturn Method \CCache::offsetUnset is declared to return bool in phpdoc but has no return value
caching/CDummyCache.php:164 PhanParamSignatureMismatchInternal Declaration of function offsetUnset(string $id) : bool should be compatible with internal function offsetUnset(mixed $offset) : void
caching/CDummyCache.php:164 PhanTypeMissingReturn Method \CDummyCache::offsetUnset is declared to return bool in phpdoc but has no return value
cli/commands/MessageCommand.php:75 PhanTypeMissingReturn Method \MessageCommand::run is declared to return int in phpdoc but has no return value
cli/commands/MessageCommand.php:88 PhanTypeMismatchArgumentInternal Argument 1 ($filename) is $sourcePath of type null but \is_dir() takes string
cli/commands/MessageCommand.php:89 PhanTypeSuspiciousStringExpression Suspicious type null of a variable or expression $sourcePath used to build a string. (Expected type to be able to cast to a string)
cli/commands/MessageCommand.php:90 PhanTypeMismatchArgumentInternal Argument 1 ($filename) is $messagePath of type null but \is_dir() takes string
cli/commands/MessageCommand.php:91 PhanTypeSuspiciousStringExpression Suspicious type null of a variable or expression $messagePath used to build a string. (Expected type to be able to cast to a string)
cli/commands/MessageCommand.php:112 PhanTypeMismatchArgumentInternal Argument 1 ($path) is $sourcePath of type null but \realpath() takes string
cli/commands/MessageCommand.php:120 PhanTypeSuspiciousStringExpression Suspicious type null of a variable or expression $messagePath used to build a string. (Expected type to be able to cast to a string)
cli/commands/MessageCommand.php:181 PhanTypeMismatchArgumentInternal Argument 1 ($key) is $message of type false but \array_key_exists() takes int|string
cli/commands/ShellCommand.php:53 PhanTypeMissingReturn Method \ShellCommand::run is declared to return int in phpdoc but has no return value
cli/commands/ShellCommand.php:138 PhanTypeSuspiciousEcho Suspicious argument $evalResult of type false for an echo/print statement
cli/commands/WebAppCommand.php:47 PhanTypeMissingReturn Method \WebAppCommand::run is declared to return int in phpdoc but has no return value
cli/commands/shell/ModelCommand.php:127 PhanTypeMissingReturn Method \ModelCommand::generateRelations is declared to return array in phpdoc but has no return value
collections/CAttributeCollection.php:62 PhanTypeMissingReturn Method \CAttributeCollection::__set is declared to return mixed in phpdoc but has no return value
collections/CAttributeCollection.php:88 PhanTypeMissingReturn Method \CAttributeCollection::__unset is declared to return mixed in phpdoc but has no return value
db/CDbMigration.php:105 PhanTypeMissingReturn Method \CDbMigration::safeUp is declared to return bool in phpdoc but has no return value
db/CDbMigration.php:119 PhanTypeMissingReturn Method \CDbMigration::safeDown is declared to return bool in phpdoc but has no return value
db/ar/CActiveRecord.php:155 PhanTypeMissingReturn Method \CActiveRecord::__set is declared to return mixed in phpdoc but has no return value
db/ar/CActiveRecord.php:194 PhanTypeMissingReturn Method \CActiveRecord::__unset is declared to return mixed in phpdoc but has no return value
db/ar/CActiveRecord.php:457 PhanTypeMissingReturn Method \CActiveRecord::primaryKey is declared to return mixed in phpdoc but has no return value
db/schema/mssql/CMssqlPdoAdapter.php:23 PhanUnextractableAnnotationElementName Saw possibly unextractable annotation for a fragment of comment '* @param string|null sequence name. Defaults to null': after string|null, did not see an element name (will guess based on comment order) 
db/schema/mssql/CMssqlSqlsrvPdoAdapter.php:34 PhanParamSignatureMismatchInternal Declaration of function lastInsertId(null|string $sequence = null) : int should be compatible with internal function lastInsertId(?string $name = null) : string
gii/components/Pear/Text/Diff/Engine/native.php:67 PhanUndeclaredVariableDim Variable $xhash was undeclared, but array fields are being added to it.
gii/components/Pear/Text/Diff/Engine/native.php:74 PhanUndeclaredVariableDim Variable $yhash was undeclared, but array fields are being added to it.
gii/components/Pear/Text/Diff/Engine/native.php:165 PhanUndeclaredVariableDim Variable $ymatches was undeclared, but array fields are being added to it.
gii/components/Pear/Text/Diff/Engine/native.php:169 PhanUndeclaredVariableDim Variable $ymatches was undeclared, but array fields are being added to it.
gii/components/Pear/Text/Diff/Engine/native.php:176 PhanUndeclaredVariableDim Variable $ymids was undeclared, but array fields are being added to it.
gii/components/Pear/Text/Diff/Engine/native.php:219 PhanUndeclaredVariableDim Variable $seps was undeclared, but array fields are being added to it.
gii/components/Pear/Text/Diff/Engine/native.php:384 PhanPluginLoopVariableReuse Variable $start used in loop was also used in an outer loop on line 381
gii/components/Pear/Text/Diff/Engine/shell.php:41 PhanStaticCallToNonStatic Static call to non-static method \Text_Diff::_getTempDir() defined at gii/components/Pear/Text/Diff.php:226. This is an Error in PHP 8.0+.
gii/components/Pear/Text/Diff/Engine/shell.php:88 PhanTypeInvalidLeftOperandOfNumericOp Invalid operator: left operand of - is string (expected number)
gii/components/Pear/Text/Diff/Engine/shell.php:91 PhanTypeInvalidLeftOperandOfNumericOp Invalid operator: left operand of - is string (expected number)
gii/components/Pear/Text/Diff/Engine/shell.php:92 PhanTypeInvalidLeftOperandOfNumericOp Invalid operator: left operand of - is string (expected number)
gii/components/Pear/Text/Diff/Mapped.php:37 PhanUndeclaredStaticMethod Static call to undeclared method \Text_Diff::Text_Diff
gii/components/Pear/Text/Diff/Renderer.php:106 PhanTypeInvalidRightOperandOfNumericOp Invalid operator: right operand of - is null (expected number)
gii/components/Pear/Text/Diff/Renderer.php:107 PhanTypeInvalidRightOperandOfNumericOp Invalid operator: right operand of - is null (expected number)
gii/components/Pear/Text/Diff/Renderer.php:186 PhanTypeInvalidLeftOperandOfAdd Invalid operator: left operand of + is null (expected array or number)
gii/components/Pear/Text/Diff/Renderer.php:189 PhanTypeInvalidLeftOperandOfAdd Invalid operator: left operand of + is null (expected array or number)
gii/components/Pear/Text/Diff/Renderer.php:194 PhanTypeInvalidUnaryOperandIncOrDec Invalid operator: unary operand of (expr)-- is ?int|?string= (expected int or string or float)
gii/components/Pear/Text/Diff/Renderer.php:194 PhanTypeInvalidUnaryOperandIncOrDec Invalid operator: unary operand of (expr)-- is ?string (expected int or string or float)
gii/components/Pear/Text/Diff/Renderer.php:196 PhanTypeInvalidUnaryOperandIncOrDec Invalid operator: unary operand of (expr)-- is ?int|?string= (expected int or string or float)
gii/components/Pear/Text/Diff/Renderer.php:196 PhanTypeInvalidUnaryOperandIncOrDec Invalid operator: unary operand of (expr)-- is ?string (expected int or string or float)
gii/generators/model/ModelCode.php:365 PhanUnextractableAnnotationElementName Saw possibly unextractable annotation for a fragment of comment '* @param CDbTableSchema table to inspect': after CDbTableSchema, did not see an element name (will guess based on comment order)
gii/generators/model/ModelCode.php:397 PhanUnextractableAnnotationElementName Saw possibly unextractable annotation for a fragment of comment '* @param string the name of the table to hold the relation': after string, did not see an element name (will guess based on comment order) 
gii/generators/model/ModelCode.php:398 PhanUnextractableAnnotationElementName Saw possibly unextractable annotation for a fragment of comment '* @param string the foreign key name': after string, did not see an element name (will guess based on comment order)
gii/generators/model/ModelCode.php:399 PhanUnextractableAnnotationElementName Saw possibly unextractable annotation for a fragment of comment '* @param boolean whether the relation would contain multiple objects': after boolean, did not see an element name (will guess based on comment order)
gii/generators/model/ModelGenerator.php:12 PhanTypeMissingReturn Method \ModelGenerator::actionGetTableNames is declared to return string in phpdoc but has no return value
messages/ca/yii.php:88 PhanPluginDuplicateArrayKey Duplicate/Equivalent array key value('Alias "{alias}" is invalid. Make sure it points to an existing directory or file.') detected in array - the earlier entry 'Alias "{alias}" is invalid. Make sure it points to an existing directory or file.' at line 87 will be ignored.
test/CDbFixtureManager.php:360 PhanUndeclaredVariableDim Variable $pk was undeclared, but array fields are being added to it.
test/CWebTestCase.php:46 PhanTypeComparisonFromArray array to false comparison
test/CWebTestCase.php:61 PhanTypeComparisonFromArray array to false comparison
utils/CFormatter.php:325 PhanTypeMismatchArgumentInternal Argument 3 ($subject) is $value of type float but \str_replace() takes array|string
validators/CEmailValidator.php:107 PhanTypeMismatchArgumentNullableInternal Argument 1 ($hostname) is $domain of type ?string but \checkdnsrr() takes string (expected type to be non-nullable)
validators/CValidator.php:219 PhanTypeMissingReturn Method \CValidator::clientValidateAttribute is declared to return string in phpdoc but has no return value
web/CHttpRequest.php:1165 PhanTypeInvalidRightOperandOfNumericOp Invalid operator: right operand of - is string (expected number)
web/CHttpSession.php:190 PhanPluginUseReturnValueInternalKnown Expected to use the return value of the internal function/method \session_regenerate_id
web/CHttpSession.php:256 PhanTypeMismatchArgumentInternal Argument 1 ($lifetime_or_options) is ['lifetime'=>$lifetime,'path'=>$path,'domain'=>$domain,'secure'=>$secure,'httponly'=>$httponly,'samesite'=>$samesite] of type array{lifetime:null,path:null,domain:null,secure:null,httponly:mixed,samesite:mixed} but \session_set_cookie_params() takes array{lifetime?:int,path?:string,domain?:?string,secure?:bool,httponly?:bool}
web/CHttpSession.php:261 PhanUndeclaredVariableAssignOp Variable $path was undeclared, but it is being used as the left-hand side of an assignment operation
web/CHttpSession.php:262 PhanTypeMismatchArgumentInternalProbablyReal Argument 1 ($lifetime_or_options) is $lifetime of type null but \session_set_cookie_params() takes array{lifetime?:int,path?:string,domain?:?string,secure?:bool,httponly?:bool}
web/CHttpSession.php:262 PhanTypeMismatchArgumentInternalProbablyReal Argument 4 ($secure) is $secure of type null but \session_set_cookie_params() takes bool
web/CHttpSession.php:266 PhanTypeMismatchArgumentInternalProbablyReal Argument 1 ($lifetime_or_options) is $lifetime of type null but \session_set_cookie_params() takes array{lifetime?:int,path?:string,domain?:?string,secure?:bool,httponly?:bool}
web/CHttpSession.php:266 PhanTypeMismatchArgumentInternalProbablyReal Argument 2 ($path) is $path of type null but \session_set_cookie_params() takes string
web/CHttpSession.php:266 PhanTypeMismatchArgumentInternalProbablyReal Argument 4 ($secure) is $secure of type null but \session_set_cookie_params() takes bool
web/CHttpSession.php:268 PhanTypeMismatchArgumentInternalProbablyReal Argument 1 ($lifetime_or_options) is $lifetime of type null but \session_set_cookie_params() takes array{lifetime?:int,path?:string,domain?:?string,secure?:bool,httponly?:bool}
web/CHttpSession.php:268 PhanTypeMismatchArgumentInternalProbablyReal Argument 2 ($path) is $path of type null but \session_set_cookie_params() takes string
web/CHttpSession.php:268 PhanTypeMismatchArgumentInternalProbablyReal Argument 4 ($secure) is $secure of type null but \session_set_cookie_params() takes bool
web/CHttpSession.php:321 PhanTypeInvalidLeftOperandOfNumericOp Invalid operator: left operand of / is false|string (expected number)
web/CHttpSession.php:321 PhanTypeInvalidRightOperandOfNumericOp Invalid operator: right operand of / is false|string (expected number)
web/CHttpSession.php:334 PhanTypeMismatchArgumentInternal Argument 2 ($value) is floor(($value * 21474836.47)) of type float but \ini_set() takes string
web/CHttpSession.php:335 PhanTypeMismatchArgumentInternal Argument 2 ($value) is 2147483647 of type 2147483647 but \ini_set() takes string
web/CHttpSession.php:375 PhanTypeMismatchArgumentInternal Argument 2 ($value) is $value of type int but \ini_set() takes string
web/CHttpSessionIterator.php:33 PhanUnextractableAnnotationElementName Saw possibly unextractable annotation for a fragment of comment '* @param array the data to be iterated through': after array, did not see an element name (will guess based on comment order)
web/CUrlManager.php:672 PhanUndeclaredVariableDim Variable $tr was undeclared, but array fields are being added to it.
web/CUrlManager.php:672 PhanUndeclaredVariableDim Variable $tr2 was undeclared, but array fields are being added to it.
web/actions/CViewAction.php:98 PhanTypeMissingReturn Method \CViewAction::resolveView is declared to return string in phpdoc but has no return value
web/auth/CWebUser.php:156 PhanTypeMissingReturn Method \CWebUser::__set is declared to return mixed in phpdoc but has no return value
web/auth/CWebUser.php:184 PhanTypeMissingReturn Method \CWebUser::__unset is declared to return mixed in phpdoc but has no return value
web/form/CFormElement.php:122 PhanTypeMissingReturn Method \CFormElement::__set is declared to return mixed in phpdoc but has no return value
web/form/CFormElementCollection.php:107 PhanTypeMissingReturn Method \CFormElementCollection::remove is declared to return mixed in phpdoc but has no return value
web/helpers/CJSON.php:109 PhanTypeMismatchArgumentInternal Argument 3 ($subject) is (float)($var) of type float but \str_replace() takes array|string
web/helpers/CJavaScript.php:85 PhanTypeMismatchArgumentInternal Argument 3 ($subject) is (float)($value) of type float but \str_replace() takes array|string
web/services/CWebService.php:165 PhanTypeMismatchArgumentInternal Argument 2 ($value) is 0 of type 0 but \ini_set() takes string
web/services/CWsdlGenerator.php:52 PhanInvalidCommentForDeclarationType The phpdoc comment for @param cannot occur on a class
web/services/CWsdlGenerator.php:53 PhanInvalidCommentForDeclarationType The phpdoc comment for @param cannot occur on a class
web/services/CWsdlGenerator.php:54 PhanInvalidCommentForDeclarationType The phpdoc comment for @return cannot occur on a class
web/services/CWsdlGenerator.php:64 PhanInvalidCommentForDeclarationType The phpdoc comment for @var cannot occur on a class
web/services/CWsdlGenerator.php:69 PhanInvalidCommentForDeclarationType The phpdoc comment for @var cannot occur on a class
web/services/CWsdlGenerator.php:127 PhanInvalidCommentForDeclarationType The phpdoc comment for @var cannot occur on a class
web/services/CWsdlGenerator.php:132 PhanInvalidCommentForDeclarationType The phpdoc comment for @var cannot occur on a class
web/services/CWsdlGenerator.php:138 PhanInvalidCommentForDeclarationType The phpdoc comment for @var cannot occur on a class
web/widgets/COutputCache.php:162 PhanTypeMissingReturn Method \COutputCache::filter is declared to return bool in phpdoc but has no return value
web/widgets/CTextHighlighter.php:88 PhanUndeclaredVariableDim Variable $options was undeclared, but array fields are being added to it.
web/widgets/captcha/CCaptchaAction.php:275 PhanTypeMismatchArgumentInternal Argument 5 ($y) is $y of type float but \imagettftext() takes int

@marcovtwout
Copy link
Member

Thanks. Most likely a lot of them are false positives, but valuable for a manual check nonetheless.

@mdeweerd
Copy link
Contributor Author

I reduced the number of message quite a bit - you can select which ones you fix and which ones you do not - then the baseline.txt can be updated .

I forgot to indicate that you can surely reuse the runPhan.sh script in my modified version of Yii to run the checks locally. runPhan.sh 1 will update the baseline.txt file
(the baseline.txt file decides which notifications are ignored file by file).

@marcovtwout
Copy link
Member

Manually checked your list and applied in #4537

Here's a log including the non-fixed and false positives: phan-yii.csv

@mdeweerd
Copy link
Contributor Author

@marcovtwout Thank you for going through this and making these adjustments.

My feedback:

  • The analysis of the next message shows that when the regeneration of the session fails (false return), this is not detected and no Exception is thrown.
    web/CHttpSession.php:190 PhanPluginUseReturnValueInternalKnown Expected to use the return value of the internal function/method \session_regenerate_id
  • I opened an issue with phan regarding the 'ini_set' false positives;
  • Regarding initialising arrays from undefined variables see https://www.php.net/manual/en/language.types.string.php#language.types.string.substr - also note changes in recent PHP versions. The recommendation can explain why phan notifies about it.

@marcovtwout
Copy link
Member

@mdeweerd Thanks for checking the details :)

  • About CHttpSession: its true the code doesn't check the return value of the internal function, but appearantly that doesn't lead to issues. The Yii2 implementation and the PHP docs examples are not checking the return value either. I think it can be safely ignored.
  • The initializing array from undefined is slightly different from your link, that refers to accessing existing strings using array keys. The current behavior is not recommended but allowed, see https://stackoverflow.com/a/8246214/729324

@mdeweerd
Copy link
Contributor Author

IHMO not checking does not lead to issues if all goes well. It's not critical to me to modify this behavior which has been like this since "day 0".

After reading when this call can return false, I decided to throw an exception in "fork"
https://github.com/php/php-src/blob/PHP-8.3/ext/session/session.c#L2235 .

As far as the "allowed but not recommended" way of initialising an array goes: I generally go with the recommended method, but it's not crucial.

For me you can close this.

@marcovtwout
Copy link
Member

Will close this when #4537 is reviewed and merged.

@mdeweerd
Copy link
Contributor Author

FYI:
Prior to PHP8.1, typing wise, the argument for the value in ini_set is a string: https://www.php.net/manual/en/function.ini-set.php#refsect1-function.ini-set-changelog .

@marcovtwout
Copy link
Member

Fixed with #4537

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

No branches or pull requests

2 participants