Comments (8)
Just to note, this is the case for many other contrib modules. Usually because they somewhat do not follow conventions in the api.php file, but even still. It's a documentation piece of a file, so it's kind of annoying.
Here is just a couple I experienced this morning:
Fatal error: Cannot redeclare elasticsearch_helper_aws_elasticsearch_helper_client_builder_alter() (previously declared in /__w/nymedia_commerce_profile/nymedia_commerce_profile/web/modules/contrib/elasticsearch_helper/elasticsearch_helper_aws/elasticsearch_helper_aws.module:17) in /__w/nymedia_commerce_profile/nymedia_commerce_profile/web/modules/contrib/elasticsearch_helper/elasticsearch_helper.api.php on line 19
Fatal error: Cannot redeclare ckeditor_media_embed_ckeditor_media_embed_object_alter() (previously declared in /__w/store/store/drupal/modules/contrib/ckeditor_media_embed/ckeditor_media_embed.module:136) in /__w/store/store/drupal/modules/contrib/ckeditor_media_embed/ckeditor_media_embed.api.php on line 21
from phpstan-drupal.
Added a PR to be able to opt out of loading api.php
files here: #641
from phpstan-drupal.
Sorry about this. I didn't think folks had that broken of .api.php
files. I like the idea of opting out.
I'm going to rework your PR @eiriksm. I want to establish a bleeding-edge concept like in PHPStan. New rules are added as off by default, but including that file will enable them.
from phpstan-drupal.
Wow you are the most kind, knowledgeful maintainer ever ❤️ I have a feeling you more or less posted this just after waking up, so taking the time here to appreciate your work and a new release breaking stuff just highlights the impact of your work. Thank you, Matt!
from phpstan-drupal.
Huh. The file should be loaded with a catch for even fatal errors.
That module needs to be fixed.
But also see if we can harden the error catching here.
from phpstan-drupal.
Fatal errors cannot be caught as far as I know so I don't think you can work around that easily. While we can 'fix' the contrib module by adding a patch to have that hook commented, it might not make sense to the contrib maintainers.
From my understanding, api.php file is more of a documentation piece for custom hooks or related hook usage that's related to the module. They are just code examples and it's not meant to be included by others so logically it's not an issue from their end. What do you think?
from phpstan-drupal.
To add to this: eiriksm#2 is a PR I created against my own fork, which demonstrates the bug. A redeclaration in an api.php file does not cause any issues in running a drupal site, but it totally crashes phpstan here ✌️
from phpstan-drupal.
Tried a couple of hacks to catch such a fatal error, but came up short. Seems like we should either
- Revert the commit
- or make it either opt-in or possible to opt out
from phpstan-drupal.
Related Issues (20)
- Detect deprecated Drupal\Core\Routing\RouteSubscriberBase::getSubscribedEvents(): array HOT 4
- Detect storage handlers injection and storage instantiation in constructors
- «Undefined array key» when using autowiring with decorator
- Make ^10.0 the default constraint for Drupal core, update from ^9.0
- Move data samples out of phpstan_fixtures and into test data files
- Add PHP 8.3 tests
- Form should not have private properties HOT 2
- Simplify defining test namespaces HOT 1
- Have AccessResult forbiddenIf and allowedIf perform truthy checks HOT 5
- LockBackendInterface::acquire() is impure HOT 2
- ModuleHandler->loadInclude() call is not being processed HOT 2
- Update `bleedingEdge.neon` to include new rules
- Support turning off @internal check HOT 2
- New accessibility requirement requires title attributes for most form elements.
- Validate FormBuilderInterface::getForm() arguments by inspecting form class HOT 1
- New rule for checking "static create()" method in controller
- Register dynamic services from DrupalKernel::attachSynthetic
- Determine return value from `\Drupal\Core\Config\Config::get` HOT 1
- Warn about max-age less then 10
- Fatal error: Uncaught TypeError: is_link(): Argument #1 ($filename) must be of type string, Drush\Config\Environment given in /tmp/site/vendor/webflo/drupal-finder/src/DrupalFinder.php:153 HOT 18
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phpstan-drupal.