1.3.2 (2026-12-01)
- On Windows
generatewrote an alias stub with no aliases, from 0.11.1, so every legacy class name was undefined in every add-on analysed against that forum. The rule that skips a path naming no class accepted only/between segments, and PHP joins them with\there. Reported as issue #3- On Windows a shortcut did not return the analysing add-on's own class extension: the file was matched against the add-on's directory with
/only. Found by reading while fixing the above, and not run on Windows
1.3.1 (2026-12-01)
generate --checkno longer reports a set as out of date because it was generated through another path to the same forum, as one mounted in a container is when checked from its host. 1.3.0 compared the path recorded in each file's header; nothing reads it.generateleaves such a set as it is for the same reason, where it rewrote it before
1.3.0 (2026-12-01)
generate --checknotices a class extension added, removed or switched off since the set was generated, and a class renamed, and names each one. It applied only the test PHPStan applies, which is the XenForo version, so a set that was missing a new extension read as current. It now builds the set in memory as well and compares it with the files, writing nothing; the set needs nothing new in it, so one written by any release can be checked, and nothing has to be regenerated. A set that another release of this package wrote may differ for that reason alone, and is reported the same way
1.2.1 (2026-11-30)
- A BB code renderer's
render()andrenderAst()return a stringXF::getRootDirectory(),getSourceDirectory()andgetAddOnDirectory()return a string, as doUtil\File::canonicalizePath(),getCodeCachePath()andstripRootPathPrefix()Anis_string()check written to narrow one of these now reports as already narrowed- Changelog: the 1.2.0 entry said an add-on's own ignore for a
findByIds()report becomes unmatched; it stays silently redundant, and the entry now says so
1.2.0 (2026-11-30)
$em->findByIds('XF:Thread', $ids)is typed as a collection of the entity named, and its identifier is no longer reported against theclass-stringannotation at level 5 or as an unresolved template type at level 6. It was missing from the shortcuts the package covers. An add-on's own ignore for either report is now redundant and is not reported as unmatched: it matches the same error the package's pattern does, so PHPStan counts it as used, and removing it is the only way to see that. Reported by an adopter- The conditions XenForo's own finders add,
isValidUser(),inForum(),skipIgnored()and 59 more, return the finder they were called on, so a chain keeps its entity at level 7 and above- A core controller's
*SaveProcess()returns aFormAction, through$this->andparent::, so$form = parent::userSaveProcess($user)in a controller extension is typed. The three that are handed the form and return nothing are left alone- README: an entity's class given to a finder shortcut is XenForo 2.3's behaviour; an add-on with a 2.2 floor keeps the identifier form
1.1.0 (2026-11-30)
- An entity structure's
$shortNameis a string, its$contentTypea string or null, and its$primaryKeyone column or the list of a compound key- The finder's
columnUtf8()andcaseInsensitive()return aFinderExpression, andexpression()is corrected to the same: XenForo documents it as returning the finder, so a method called on the result was accepted where the body returns an expression that has none
1.0.0 (2026-11-30)
composer require --dev hampel/xenforo-phpstan:^1.0. Nothing in the package's behaviour
changed from 0.12.0, so a forum whose set was generated by 0.12.0 needs nothing more.
- The first stable release. A
^1.0constraint takes every later 1.x release withcomposer update, where a^0.xconstraint stopped at its own minor and each one had to be named- README: the members the stubs type, and the documented types they correct, are tables grouped by class in place of two long paragraphs
- Tutorial: one sentence still said
generatewrites three files
0.12.0 (2026-11-30)
composer require --dev hampel/xenforo-phpstan:^0.12, thenvendor/bin/xenforo-phpstan generate
once per forum. Until it has run, PHPStan stops with `Scanned file
.../internal_data/phpstan/xf-options.php does not exist, andgenerate --check` says so first.
- PHPStan runs against a XenForo 2.3.0 forum. The fragment named the forum's
src/XF/Options.phpto PHPStan, which 2.3.0 does not have, and a scan file that does not exist stops the run before anything is analysed.generatenow writes a fourth file,xf-options.php: the forum's own class, byte for byte, or a file that declares nothing where the forum has none, and the fragment names that- The generated set keeps its format, so add-ons on an earlier release that share the forum go on reading it after one on 0.12 has regenerated
0.11.16 (2026-11-30)
- A
FormAction's steps return the action, so a chain such as$form->basicEntitySave($entity, $input)->run()is typed:setup(),setupEntityInput(),validate(),validateEntity(),apply(),saveEntity(),complete(),basicEntitySave(),basicValidateServiceSave(),applyInTransaction()andlogError()are$this,run()andisUsingTransaction()a bool- The controller's
reroute(),rerouteController()andreroutePath()return aReroute, andRouter::prepareStringForUrl()a string. Reported by an adopter at level max
0.11.15 (2026-11-30)
filter('name', [...]), an array of filters given for one name, is an array shape asfilter([...])has been since 0.7.0, on the controller and the requestController::filter()'s$typeis corrected to take that array: XenForo documents a string, and the request the call is passed to hands an array tofilterArray()- Typed where XenForo leaves them undeclared:
XF::$DS,config()with no key onXFandXF\App(one key's value staysmixed),Entity::toArray(),AddOn::getInstalledAddOn(),escapeLike()on the adapter and the finder, the controller's$requestandbuildLinkHash(),Language::phrase()anddateTime(), andRequest::getRequestMethod()Request::getFile()is corrected from XenForo's upload-or-list: one upload asked for is the upload, null or false, and$multiplegives the list. Typing the controller's$requestbrought XenForo's docblock into force, which reported a single upload passed on as a list
0.11.14 (2026-11-30)
$entity->getExistingValue('column')andgetPreviousValue('column')are typed asgetValue()has been since 0.11.12: each reads the same column, from the stored or the previous values, with the same fallback to the column's default and then null
0.11.13 (2026-11-30)
extendClass()given a string is no longer reported against XenForo'sclass-stringannotation, as the container shortcuts have not been since 0.1.0. An entity's array read typed as a string in 0.11.12 made\XF::extendClass($entry['cron_class'])a report wheremixedhad been accepted- The stub declares
Stringable, whichController::error()andnoPermission()name as XenForo does. Under aphpVersionfloor below 8.0 PHPStan does not know the interface and reported the stub itself; an add-on never saw that only because the stub sits under its excludedvendor/
0.11.12 (2026-11-30)
- An array read of an entity,
$entity['column'], is typed asget()has been since 0.11.11:offsetGet()is the same call$entity->getValue('column')is typed from the entity's@propertyline: the underscored one XenForo writes for the stored value of a column that has a getter, the plain one otherwise
0.11.11 (2026-11-29)
$entity->get('column')is typed from the entity's@propertyline for that name, as a relation by name has been since 0.8.1, a column or relation a class extension adds included. It is what__get()calls, so it is the property read by another spelling; a name the entity does not declare, or one held in a variable, staysmixed
0.11.10 (2026-11-29)
- The finder's
columnSqlName()andquote()return a string andStructure::$tableis one, so a condition written as SQL by hand is no longermixedat level 10Util\Ip::parseIpRangeString()is corrected from the documentedarray|boolto false or the one array it builds, with its six keys typed, so a check for false leaves a shape whoseprintable,startRangeand the rest can be read- README: the configuration template sets
tmpDir: .phpstan.cache. Without it every add-on on a machine shares PHPStan's one default result cache, so each run after switching add-ons is cold and two runs at once write the same file. An adopter adds the line itself, with the.gitignoreentry and thebuild.jsonremoval the README shows; the tutorial's template carries the same line
0.11.9 (2026-11-29)
- A finder shortcut given an entity's class name, which XenForo 2.3 accepts, returns that entity's finder: its finder class where it has one, the generic
Finderof that entity where it has none. It was a bareFinderyielding plain entities, and within the add-on that extends the entity it was typed as the entity extension, so every finder method on it was reported as undefined; that part was a defect of the own-extension rule since 0.2.2
0.11.8 (2026-11-29)
- An undeclared
action*method of one of XenForo's own controller plugins returns a reply, as a controller's has since 0.8.0, so an extension of the warning or delete plugin returningparent::actionWarn()is no longermixed. Only a method declared underXF\ControllerPluginis typed: nothing enforces a reply from a plugin, and another add-on's may return anything- The templater's 34 form helpers that declare no return,
formRow(),formTextBoxRow(),formSelectRow()and the rest, return a string, so an option renderer returning one is no longer reported at level 10- README: with no
phpVersionset the floor comes fromcomposer.json'sphprequirement, where it said the running PHP; asedthat makes an add-on's own options non-null in the generated options stub; an extension of an add-on that is not installed is excluded; an option renderer'sinputNameis not a string; a floor config inheritsignoreErrorsas well, and which inherited ignores are then reported as unmatched; a view's parameters as a residual above level 8
0.11.7 (2026-11-27)
Structure's$getters,$defaultWith,$options,$behaviors,$columnAliasesand$withAliasesare arrays, as$columnsand$relationshave been since 0.7.1, so an entity extension adding a getter to the structure it was handed is no longer an offset onmixedat level 10Controller::formAction()returns aFormAction, and so do the account controller'saccountDetailsSaveProcess()andpreferencesSaveProcess(), which an extension calls throughparent::to add to the formRequest::getIp(),Templater::callMacro()andcallAdsMacro()return a string, and a spam provider's$appis the application; XenForo declares none of them- corrected:
Util\Ip::convertIpStringToBinary()andconvertIpBinaryToString()returnstring|false, where XenForo documentsbool|stringand no path returns true- README: a docblock between an attribute and its method is not read, Mockery's higher-order expectations need the mocked class in the mock's type, and the chained
generateis safe on a shared forum
Each was reported by an adopter at level max.
0.11.6 (2026-11-24)
- the API controller's
apiResult(),apiSuccess()andapiBoolResult()return anApiResultandapiError()anError, andApiResult::getApiResult()returns the result it was built from; XenForo declares none of them, so at level 9 every API action with a declared return type was reported as returningmixed. Reported by an adopter at level max
0.11.5 (2026-11-24)
SimpleCache::getSet()returns aSimpleCacheSet,AddOn::getAddOnDirectory()andView::getTemplateName()a string, andApp::getGlobalTemplateData()an array keyed by name; XenForo declares none of them.Templater::$defaultParams, which a templater extension reads directly, is an array keyed by name. Reported by an adopter at level max- corrected:
XF::$versionis a string andXF::$versionIdan int. XenForo documents the pair with one block carrying both@varlines, which read as neither
0.11.4 (2026-11-23)
getMasterPhrase()returns the phrase entity on the nineteen core entities that left it undeclared, from a cron entry and an option to a trophy and a reaction: each body returns the relation or a new phrase when it is empty, so never null. A prefix group and a widget had it from 0.10.8getMasterTitlePhrase()andgetMasterDescriptionPhrase()return the phrase entity on a widget definition, a widget position, an advertising position and an activity summary definition, for the same reason
0.11.3 (2026-11-23)
TagRepository::normalizeTag()returns a string, andStr\Formatter::getProxiedUrlIfActive()andgetProxiedUrlIfActiveExtended()a string or null; XenForo declares neither. Asked for by an adopter at level 10UserRepository::getUsersByNames()returns a collection of users, and the names it did not find are strings; XenForo documents a bareArrayCollectionand a bare array- corrected:
Mailer::getTransportFromOption()returns anAbstractTransport, as every branch of it does and as the mailer's constructor,setDefaultTransport()andsend()require; XenForo documents the interface, which none of them accepts
0.11.2 (2026-11-22)
- a declared container key is typed through
$app->get('key')and$subContainer->get('key')as well, which read the same entry as the array form and were leftmixedin 0.11.0. Reported by an adopter- README: a declared container type that contains a comma is quoted, and a
@phpstan-typealias is not known in one- README: with no
phpVersionset PHPStan analyses for the PHP it runs on, and PHP 8.5 reports anint|nullarray key
0.11.1 (2026-11-22)
generatewrote alegacy-aliases.stub.phpPHP cannot parse when an add-on held PHP under a dot directory or any directory whose name is not an identifier, such as a git worktree checked out inside it: the alias took its namespace from the path. PHPStan drops a scan file it cannot parse without reporting it, so every legacy class name went undefined in every add-on analysed against that forum. Dot directories are now skipped, as is any path with a segment that is not an identifier, and dot directories under an add-on are left out of the scan as well, where a worktree declared every class of its add-on twice. Rungenerateagain on a forum that was affected (#2)
0.11.0 (2026-11-22)
- an add-on's own container keys are typed where it declares them:
xenforo.containermaps a key of the application's container to a PHPDoc type, andxenforo.subContainersdoes the same per sub-container class.$app->container('key'),$app['key'],$container['key'],$this->container['key']inside a sub-container and$subContainer['key']are all answered; an undeclared key staysmixed. On one add-on at level 9 this cleared 37 of 120 reports and added none. Nothing changes for an add-on that declares no keys. Suggested by an adopter- below 1.0 a caret holds the minor:
composer require --dev hampel/xenforo-phpstan:^0.11
0.10.9 (2026-11-22)
XF\Http\Reader::get(),request(),getUntrusted()andrequestUntrusted()corrected:$saveToisstring|resource|null, the path or stream the body is written to, and$errorcomes back asstring|XF\Phrase|null. XenForo documents both as null, so an add-on downloading to a file was reported from level 5, and a check of the error after the call read as always false. Reported by an adopter
0.10.8 (2026-11-10)
getMasterPhrase()onAbstractPrefixGroupandWidgettyped as theXF\Entity\Phraseit returns, never null; XenForo declares neither, so above level 8 the phrase wasmixedgetMasterPhrase()onStylePropertyandStylePropertyGroupcorrected to theXF\Entity\Phraseentity it returns; XenForo's docblock resolves to the renderableXF\Phrasethrough an import, so the phrase's text andsave()were reported as undefined from level 2
Thanks to @DragonByte Tech for the suggestion and bug report!
0.10.7 (2026-11-09)
generatecompared a set from an earlier minute as changed and rewrote it, because the date was stripped from the header before comparing but not from the exported'generated'entry inclasses.php; 0.10.6's "writes nothing when current" held only within the minute it was written. Reported by a reader the same day
0.10.6 (2026-11-09)
generatewrites nothing when the set already there differs from what it would write only by its date, and says so, so it can run in front of every analysis without invalidating PHPStan's result cache, which records the hash of every stub file- README: run
generatebefore every analysis rather than remembering to; it costs a fraction of a second
We use essential cookies to make this site work, and optional cookies to enhance your experience.