Problem
be-framework/psalm-plugin currently focuses on Be Framework runtime mistakes that can be found statically.
For applications that intentionally use Ray.MediaQuery, a small optional check could help catch simple MediaQuery wiring mistakes before runtime, without creating a standalone architecture checker or turning project-specific architecture policy into default Psalm errors.
Proposed scope
Add an opt-in Ray.MediaQuery conformance check profile, initially limited to the smallest useful rules:
BeMissingDbQueryAttribute
When the opt-in profile is enabled, interfaces in configured MediaQuery directories such as:
src/Reason/Media/Query
src/Reason/Media/Command
be/src/Reason/Media/Query
be/src/Reason/Media/Command
should declare #[DbQuery] on query/command methods.
BeMissingSqlFile
When a method has #[DbQuery('foo')], the plugin should optionally verify that a matching SQL file exists, e.g.:
The SQL directory should be configurable.
Non-goals
This issue should not introduce broad architecture enforcement.
Out of scope:
- banning PDO globally
- banning
Sql* classes by naming convention
- enforcing BEAR Resource usage patterns
- inferring whether
MediaQueryModule is installed correctly
- dependency-direction checks; those belong in Deptrac or a project-specific policy
- creating a standalone CLI checker
Configuration sketch
The checks should be disabled by default and enabled explicitly in psalm.xml, for example:
<pluginClass class="Be\PsalmPlugin\Plugin">
<mediaQueryConformance enabled="true">
<mediaDirectories>
<directory name="src/Reason/Media" />
<directory name="be/src/Reason/Media" />
</mediaDirectories>
<sqlDirectory name="var/sql" />
</mediaQueryConformance>
</pluginClass>
Exact XML shape can be decided during implementation.
Implementation notes
Follow the existing plugin pattern:
- add
src/Issue/*
- add
src/Handler/*
- register handlers in
src/Plugin.php
- add invalid/valid fixtures under
tests/Fixture
- extend
tests/PluginIntegrationTest.php
- document issue types and suppression examples in README
Acceptance criteria
- Checks are opt-in and disabled by default.
- Psalm reports
BeMissingDbQueryAttribute for configured MediaQuery interfaces missing #[DbQuery].
- Psalm reports
BeMissingSqlFile when a configured #[DbQuery('foo')] has no matching SQL file.
- Valid fixtures remain clean.
- Standard Psalm suppression/baseline/output mechanisms work unchanged.
composer tests passes on PHP 8.3 and 8.4.
Problem
be-framework/psalm-plugincurrently focuses on Be Framework runtime mistakes that can be found statically.For applications that intentionally use Ray.MediaQuery, a small optional check could help catch simple MediaQuery wiring mistakes before runtime, without creating a standalone architecture checker or turning project-specific architecture policy into default Psalm errors.
Proposed scope
Add an opt-in Ray.MediaQuery conformance check profile, initially limited to the smallest useful rules:
BeMissingDbQueryAttributeWhen the opt-in profile is enabled, interfaces in configured MediaQuery directories such as:
src/Reason/Media/Querysrc/Reason/Media/Commandbe/src/Reason/Media/Querybe/src/Reason/Media/Commandshould declare
#[DbQuery]on query/command methods.BeMissingSqlFileWhen a method has
#[DbQuery('foo')], the plugin should optionally verify that a matching SQL file exists, e.g.:var/sql/foo.sqlThe SQL directory should be configurable.
Non-goals
This issue should not introduce broad architecture enforcement.
Out of scope:
Sql*classes by naming conventionMediaQueryModuleis installed correctlyConfiguration sketch
The checks should be disabled by default and enabled explicitly in
psalm.xml, for example:Exact XML shape can be decided during implementation.
Implementation notes
Follow the existing plugin pattern:
src/Issue/*src/Handler/*src/Plugin.phptests/Fixturetests/PluginIntegrationTest.phpAcceptance criteria
BeMissingDbQueryAttributefor configured MediaQuery interfaces missing#[DbQuery].BeMissingSqlFilewhen a configured#[DbQuery('foo')]has no matching SQL file.composer testspasses on PHP 8.3 and 8.4.