Problem/Motivation
PHP warnings during static code analysis using phan with messages:
"Expected an object instance when accessing an instance property, but saw an expression $config with type false in metatag.admin.inc and metatag.module
"Expected an object instance when accessing an instance property, but saw an expression $product with type array{metatags:mixed[]} " in metatag.module
"Argument 3 ($metatags) is $metatags of type null but \metatag_metatags_form() takes array defined at jjbos-platform/docroot/profiles/jjbos/modules/contrib/metatag/metatag.module" and "Argument 4 ($options) is $options of type null but \metatag_metatags_form() takes array defined at jjbos-platform/docroot/profiles/jjbos/modules/contrib/metatag/metatag.module" in metatag.module
"Expected an object instance when accessing an instance property, but saw an expression $metatag_config_node with type false", "Expected an object instance when accessing an instance property, but saw an expression $metatag_config_global with type false", "Expected an object instance when accessing an instance property, but saw an expression $metatag_config_taxonomy_term with type false" and "Expected an object instance when accessing an instance property, but saw an expression $metatag_config_user with type false" in metatag_importer/metatag_importer.page_title.inc
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | metatag-n3274588-12.patch | 6.75 KB | damienmckenna |
| #10 | patch-applied.png | 30.34 KB | anoopsingh92 |
| #8 | metatag-3274588-php-warnings-during-8.patch | 5.7 KB | loon |
Issue fork metatag-3274588
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
Dmitrii_Zadorozhnyi commentedI would suggest to apply a patch
Comment #3
Dmitrii_Zadorozhnyi commentedSome fixes for patch
Comment #4
damienmckennaThank you for working on this.
I think it needs a little work.
This should display an error message of $config is not a valid object.
How about just adding the "object" declaration in the function definition, i.e. metatag_config_save(object $config)?
Ditto.
This needs an error message.
This should just not pass the third and fourth arguments, seeing as they don't exist.
Comment #5
Dmitrii_Zadorozhnyi commentedAdd some fixes for patch
Comment #6
hitchshock+1 RTBC, but someone else to review this one too.
Comment #7
damienmckennaIt needs some more work to display error messages, or throwing an exception, when the expected objects aren't loaded, e.g. metatag_config_delete_form_submit().
Comment #8
loon commentedAdded error messages
Comment #9
anoopsingh92Comment #10
anoopsingh92Hi @loon, Your patch applied cleanly for me. Someone also can review it before moving it to RTBC.

Thanks
Comment #11
damienmckenna@anoopsingh92: FYI posting a screenshot that shows a patch applies is not a useful use of your time, please don't post more of them.
Comment #12
damienmckennaHow does this work?
Comment #13
damienmckennaComment #14
damienmckennaCommitted. Thanks everyone.