nexus-psalm
Psalm plugin that enforces actor-model safety rules and improves generic type inference for Nexus APIs.
What's in this package
Safety rules (catch violations at analysis time, before runtime)
NonReadonlyMessage—tell()arguments must bereadonlyclassesMutableActorState—ActorHandler/StatefulActorHandlerproperties must bereadonlyNonSerializableRemoteMessage—WorkerActorRef::tell()messages must carry#[MessageType]BlockingCallInHandler— flagssleep,file_get_contents,curl_exec, and similar blocking calls inside handlersMutableClosureCapture—Props::fromFactory()/fromStatefulFactory()closures must not capture by reference (use (&$var))
Type providers
PropsReturnTypeProvider— infersProps<T>fromfromContainer,fromFactory, andfromStatefulFactoryso downstreamspawn()returns the correctActorRef<T>
Narrowing hook
BehaviorSubclassNarrowingHook— suppresses false-positiveDocblockTypeContradiction/TypeDoesNotContainTypeerrors wheninstanceof-narrowingBehavior<T>to a concrete subclass
Install
composer require --dev nexus-actors/psalm
Quick example
psalm.xml
<?xml version="1.0"?>
<psalm errorLevel="1" resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
</projectFiles>
<plugins>
<pluginClass class="Monadial\Nexus\Psalm\Plugin" />
</plugins>
</psalm>
All five safety rules fire at Psalm level 1. Suppress per-line with @psalm-suppress NonReadonlyMessage (and equivalent names), or globally in psalm.xml via <issueHandlers>.
See also
- nexus-core — the actor APIs this plugin analyses
- Core concepts / actors