kalessil / phpinspectionsea

A Static Code Analyzer for PHP (a PhpStorm/Idea Plugin)
https://plugins.jetbrains.com/plugin/7622?pr=phpStorm
Other
1.44k stars 118 forks source link

Long Inheritance Chain (add special case for PhalconPHP) #280

Closed strayobject closed 7 years ago

strayobject commented 7 years ago

In Long Inheritance Chain there is a note stating that some framework specific assumptions are made, please add Phalconphp to those assumptions.

kalessil commented 7 years ago

@strayobject : gladly, but I need input on which inherited classes got reported - I'm not involved into the community or related development.

strayobject commented 7 years ago

I'm not sure if I understood correctly what you need. Below is the list of files (from Phalcon stubs) which contain framework classes that already extend another framework class. (Classes are named exactly the same as the files, namespaces are capitalized paths) Please let me know if you need something else.

./Phalcon/db/adapter/pdo/Mysql.php
./Phalcon/db/adapter/pdo/Postgresql.php
./Phalcon/db/adapter/pdo/Sqlite.php
./Phalcon/db/adapter/Pdo.php
./Phalcon/db/dialect/Mysql.php
./Phalcon/db/dialect/Postgresql.php
./Phalcon/db/dialect/Sqlite.php
./Phalcon/db/Exception.php
./Phalcon/acl/adapter/Memory.php
./Phalcon/acl/Exception.php
./Phalcon/annotations/adapter/Files.php
./Phalcon/annotations/adapter/Apc.php
./Phalcon/annotations/adapter/Memory.php
./Phalcon/annotations/adapter/Xcache.php
./Phalcon/annotations/Exception.php
./Phalcon/Validation.php
./Phalcon/queue/beanstalk/Exception.php
./Phalcon/tag/Exception.php
./Phalcon/http/response/Exception.php
./Phalcon/http/cookie/Exception.php
./Phalcon/http/request/File.php
./Phalcon/http/request/Exception.php
./Phalcon/paginator/adapter/NativeArray.php
./Phalcon/paginator/adapter/QueryBuilder.php
./Phalcon/paginator/adapter/Model.php
./Phalcon/paginator/Exception.php
./Phalcon/forms/element/Submit.php
./Phalcon/forms/element/Check.php
./Phalcon/forms/element/Text.php
./Phalcon/forms/element/Password.php
./Phalcon/forms/element/Select.php
./Phalcon/forms/element/Numeric.php
./Phalcon/forms/element/File.php
./Phalcon/forms/element/Radio.php
./Phalcon/forms/element/Email.php
./Phalcon/forms/element/Hidden.php
./Phalcon/forms/element/TextArea.php
./Phalcon/forms/element/Date.php
./Phalcon/forms/Form.php
./Phalcon/forms/Exception.php
./Phalcon/flash/Session.php
./Phalcon/flash/Direct.php
./Phalcon/flash/Exception.php
./Phalcon/mvc/Controller.php
./Phalcon/mvc/Micro.php
./Phalcon/mvc/application/Exception.php
./Phalcon/mvc/user/Module.php
./Phalcon/mvc/user/Component.php
./Phalcon/mvc/user/Plugin.php
./Phalcon/mvc/collection/behavior/SoftDelete.php
./Phalcon/mvc/collection/behavior/Timestampable.php
./Phalcon/mvc/collection/Exception.php
./Phalcon/mvc/micro/Exception.php
./Phalcon/mvc/Dispatcher.php
./Phalcon/mvc/Collection.php
./Phalcon/mvc/DispatcherInterface.php
./Phalcon/mvc/View.php
./Phalcon/mvc/model/transaction/Exception.php
./Phalcon/mvc/model/transaction/Failed.php
./Phalcon/mvc/model/behavior/SoftDelete.php
./Phalcon/mvc/model/behavior/Timestampable.php
./Phalcon/mvc/model/metadata/Files.php
./Phalcon/mvc/model/metadata/Session.php
./Phalcon/mvc/model/metadata/Apc.php
./Phalcon/mvc/model/metadata/Memcache.php
./Phalcon/mvc/model/metadata/Redis.php
./Phalcon/mvc/model/metadata/Memory.php
./Phalcon/mvc/model/metadata/Libmemcached.php
./Phalcon/mvc/model/metadata/Xcache.php
./Phalcon/mvc/model/resultset/Simple.php
./Phalcon/mvc/model/resultset/Complex.php
./Phalcon/mvc/model/validator/StringLength.php
./Phalcon/mvc/model/validator/Inclusionin.php
./Phalcon/mvc/model/validator/Numericality.php
./Phalcon/mvc/model/validator/PresenceOf.php
./Phalcon/mvc/model/validator/Exclusionin.php
./Phalcon/mvc/model/validator/Ip.php
./Phalcon/mvc/model/validator/Email.php
./Phalcon/mvc/model/validator/Url.php
./Phalcon/mvc/model/validator/Regex.php
./Phalcon/mvc/model/validator/Uniqueness.php
./Phalcon/mvc/model/ValidationFailed.php
./Phalcon/mvc/model/Message.php
./Phalcon/mvc/model/Exception.php
./Phalcon/mvc/dispatcher/Exception.php
./Phalcon/mvc/router/Annotations.php
./Phalcon/mvc/router/Exception.php
./Phalcon/mvc/ViewInterface.php
./Phalcon/mvc/Application.php
./Phalcon/mvc/view/Simple.php
./Phalcon/mvc/view/Engine.php
./Phalcon/mvc/view/engine/Php.php
./Phalcon/mvc/view/engine/volt/Exception.php
./Phalcon/mvc/view/engine/volt/Compiler.php
./Phalcon/mvc/view/engine/Volt.php
./Phalcon/mvc/view/Exception.php
./Phalcon/mvc/Model.php
./Phalcon/mvc/url/Exception.php
./Phalcon/assets/resource/Js.php
./Phalcon/assets/resource/Css.php
./Phalcon/assets/Exception.php
./Phalcon/assets/inline/Js.php
./Phalcon/assets/inline/Css.php
./Phalcon/application/Exception.php
./Phalcon/config/adapter/Php.php
./Phalcon/config/adapter/Yaml.php
./Phalcon/config/adapter/Json.php
./Phalcon/config/adapter/Ini.php
./Phalcon/config/Exception.php
./Phalcon/logger/adapter/File.php
./Phalcon/logger/adapter/Stream.php
./Phalcon/logger/adapter/Firephp.php
./Phalcon/logger/adapter/Syslog.php
./Phalcon/logger/formatter/Line.php
./Phalcon/logger/formatter/Json.php
./Phalcon/logger/formatter/Firephp.php
./Phalcon/logger/formatter/Syslog.php
./Phalcon/logger/Exception.php
./Phalcon/security/Exception.php
./Phalcon/translate/adapter/Gettext.php
./Phalcon/translate/adapter/Csv.php
./Phalcon/translate/adapter/NativeArray.php
./Phalcon/translate/Exception.php
./Phalcon/session/adapter/Files.php
./Phalcon/session/adapter/Memcache.php
./Phalcon/session/adapter/Redis.php
./Phalcon/session/adapter/Libmemcached.php
./Phalcon/session/Exception.php
./Phalcon/validation/CombinedFieldsValidator.php
./Phalcon/validation/validator/StringLength.php
./Phalcon/validation/validator/InclusionIn.php
./Phalcon/validation/validator/Numericality.php
./Phalcon/validation/validator/Between.php
./Phalcon/validation/validator/ExclusionIn.php
./Phalcon/validation/validator/PresenceOf.php
./Phalcon/validation/validator/Alpha.php
./Phalcon/validation/validator/CreditCard.php
./Phalcon/validation/validator/File.php
./Phalcon/validation/validator/Confirmation.php
./Phalcon/validation/validator/Email.php
./Phalcon/validation/validator/Url.php
./Phalcon/validation/validator/Regex.php
./Phalcon/validation/validator/Alnum.php
./Phalcon/validation/validator/Uniqueness.php
./Phalcon/validation/validator/Digit.php
./Phalcon/validation/validator/Identical.php
./Phalcon/validation/validator/Date.php
./Phalcon/validation/Exception.php
./Phalcon/escaper/Exception.php
./Phalcon/cli/Task.php
./Phalcon/cli/Console.php
./Phalcon/cli/Dispatcher.php
./Phalcon/cli/DispatcherInterface.php
./Phalcon/cli/dispatcher/Exception.php
./Phalcon/cli/router/Exception.php
./Phalcon/cli/console/Exception.php
./Phalcon/loader/Exception.php
./Phalcon/image/adapter/Gd.php
./Phalcon/image/adapter/Imagick.php
./Phalcon/image/Exception.php
./Phalcon/debug/Exception.php
./Phalcon/DiInterface.php
./Phalcon/Application.php
./Phalcon/Exception.php
./Phalcon/cache/frontend/Msgpack.php
./Phalcon/cache/frontend/Igbinary.php
./Phalcon/cache/Exception.php
./Phalcon/cache/backend/Apc.php
./Phalcon/cache/backend/Memcache.php
./Phalcon/cache/backend/File.php
./Phalcon/cache/backend/Redis.php
./Phalcon/cache/backend/Mongo.php
./Phalcon/cache/backend/Memory.php
./Phalcon/cache/backend/Libmemcached.php
./Phalcon/cache/backend/Xcache.php
./Phalcon/crypt/Exception.php
./Phalcon/filter/Exception.php
./Phalcon/di/factorydefault/Cli.php
./Phalcon/di/FactoryDefault.php
./Phalcon/di/Exception.php
./Phalcon/events/Exception.php
kalessil commented 7 years ago

Almost, I need just a few classes (2-3, except controllers) like here: https://github.com/kalessil/phpinspectionsea/blob/master/src/main/java/com/kalessil/phpStorm/phpInspectionsEA/inspectors/semanticalAnalysis/classes/LongInheritanceChainInspector.java#L25

strayobject commented 7 years ago

I see. In this case would it not be better to count only userland inheritance by allowing people to set partial namespaces that are not to be counted or counted as 1 (example would be adding '\Phalcon\' to adjust the count if "extends" matches)?

As for the classes, I would consider the following (although other people might think otherwise):

\\Phalcon\\Forms\\Form
\\Phalcon\\Db\\Adapter\\Pdo
\\Phalcon\\Db\\Adapter\\Pdo\\Mysql
\\Phalcon\\Db\\Adapter\\Pdo\\Postgresql
\\Phalcon\\Db\\Adapter\\Pdo\\Sqlite
\\Phalcon\\Mvc\\View\\Engine\\Volt
\\Phalcon\\Mvc\\View\\Engine\\Php
kalessil commented 7 years ago

Great, the list looks good.

Some frameworks are using older PSRs, so namespace fragments there will not work.

kalessil commented 7 years ago

I did check the stubs and ended up with adding \Phalcon\Di\Injectable.

Feedback would be appreciated: you can download PhpInspectionsEA.jar from master, in IDE: File - Settings - Plugins and under the plugins list click "Install from disk", point to the file and apply changes.

Let me know if the fix helps please.

strayobject commented 7 years ago

Yes this works :) Thank you.

kalessil commented 7 years ago

Super, and thank you for reporting!