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

Custom method on extended classes are flagged as undefined. #151

Open
1 of 4 tasks
Beakerboy opened this issue Apr 3, 2020 · 2 comments
Open
1 of 4 tasks

Custom method on extended classes are flagged as undefined. #151

Beakerboy opened this issue Apr 3, 2020 · 2 comments

Comments

@Beakerboy
Copy link

Beakerboy commented Apr 3, 2020

How is drupal-check installed?

  • drupal-check is installed using the phar
  • drupal-check is installed globally via Composer
  • drupal-check is installed globally using consolidation/cgr
  • drupal-check is installed as a dependency to my project

Environment:

  • OS: Linux
  • PHP Version: 7.3
  • Drupal core: 8.8.x

Describe the bug
Drupal-check flags every call to a custom method as undefined.

Console output
Paste the output of the console when running the command with -vvv
https://travis-ci.org/github/Beakerboy/sqlsrv/builds/671039483

@Beakerboy
Copy link
Author

Beakerboy commented Apr 5, 2020

Some of the “method not found” errors originate from prophecy objects. I installed jangregor/phpstan-prophecy and phpstan/extension-installer, but then get the error:

- /home/travis/build/Beakerboy/drupal-project/vendor/phpstan/phpstan-deprecation-rules/rules.neon
- /home/travis/build/Beakerboy/drupal-project/vendor/mglaman/phpstan-drupal/extension.neon

It can lead to unexpected results. If you're using phpstan/extension-installer, make sure you have removed corresponding neon files from your project config file.

I have no neon file, and I do not see one in your project repository either.

@Beakerboy
Copy link
Author

Beakerboy commented Apr 6, 2020

It looks like many of the errors are due to limitations in the way the core doc blocks are used. The function Connection::schema() will always return a child of \Drupal\Core\Database\Schema, not this particular “abstract for all intents and purposes” class.

If I break the following statement

$result = $this->connection->schema()->customFunction();

Into

/** @var \Drupal\Driver\Database\module\Schema $schema */
$schema = $this->connection->schema();
$result = $schema->customFunction();

Then the error goes away. If you think this is the expected behavior, feel free to close it. Prophecy is still an issue though.

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

1 participant