php-gtk4 / stubs
IDE and PHPStan stubs for the php-gtk4 extension (the Gtk4\ namespace). Declarations only - the extension defines the classes, so this package is never autoloaded.
Requires
- php: >=8.4
Requires (Dev)
None
Suggests
- phpstan/extension-installer: Registers extension.neon with PHPStan, so Gtk4\ symbols resolve without configuration
Provides
None
Conflicts
None
Replaces
None
README
Generated — do not edit here.
gtk4.phpcomes out ofgen/ide-stub.phpin apss-pohl/php-gtk4, which is also where this package is published from, and where issues and pull requests belong. Anything changed by hand is gone at the next release.
IDE and static-analysis stubs for the php-gtk4 extension:
every class, method, enum, constant and @property of the Gtk4\ namespace, with the same
signatures and docblocks the extension registers, and dummy bodies so PhpStorm, Intelephense and
PHPStan can read them.
composer require --dev php-gtk4/stubs
The package version equals the extension version it describes: php-gtk4/stubs 0.3.0 is the
API of php-gtk4 0.3.0.
Never load this file. The extension defines the classes at runtime and the stub would
redeclare every one of them, so the package deliberately has no autoload section. It is read
by tools, not by PHP.
Licence
MIT, like the extension (LICENSE). One thing in this package is not: the docblocks are GTK's, GLib's,
Pango's and WebKitGTK's own documentation, copied out of their GObject-Introspection data by the generator
and reflowed — their authors' text under their licences (LGPL, MIT for graphene). THIRD-PARTY-NOTICES.md
next to this file is the accounting.
PHPStan
With phpstan/extension-installer nothing
else is needed: extension.neon registers gtk4.php under scanFiles, so Gtk4\GtkButton resolves
whether or not the extension is loaded in the PHP that runs PHPStan. Without the installer:
includes: - vendor/php-gtk4/stubs/extension.neon
IDEs
PhpStorm and Intelephense index vendor/ on their own, so composer require is all it takes.
For a project that does not use Composer, point the IDE at the directory instead:
- VS Code (Intelephense):
"intelephense.environment.includePaths": ["/path/to/stubs"]insettings.json. - PhpStorm: Settings → PHP → Include Path → add the directory.
For php-gtk4 developers
gtk4.php is generated from the hand-written src/gtk4.stub.php and every generated
src/<Ns>/<Ns>.stub.php by gen/ide-stub.php (same declarations with dummy bodies, plus
__get/__set/__isset on GObject so @property tags are honoured). Do not edit;
./ci.sh --only=stubs --fix regenerates it together with src/gtk4_arginfo.h, and
tests/StubsTest.php fails if it is stale or disagrees with ReflectionExtension('gtk4').
This directory is the package: release.yml copies it into the
php-gtk4-stubs repository and tags it with the
extension's version on every real release (docs/RELEASING.md "The stubs package"). Nothing in
that repository is edited by hand.