-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding PHPStan #68
base: production
Are you sure you want to change the base?
Adding PHPStan #68
Conversation
srtfisher
commented
Dec 30, 2024
- Moving code into inc and more modern structure
- Wiring up the legacy aliases and upgrading phpcs to alley cs 2.0
- Migrating tests into new namespace
- CHANGELOG and built release workflow
- Adding PHP 8.3, removing 8.0
- Adding editor config and test CS
- Migrating test suite to PSR-4
- Adjusting workflow
- Testing CI
- Testing CI
- Add types for array arguments
- Fix branch
- CHANGELOG
- Fixing types
- Test MS
- Contd work on phpstan
add_action( 'after_setup_theme', [ \Alley\WP\Asset_Manager\Preload::class, 'instance' ] ); // @phpstan-ignore-line should not return anything | ||
add_action( 'after_setup_theme', [ \Alley\WP\Asset_Manager\Scripts::class, 'instance' ] ); // @phpstan-ignore-line should not return anything | ||
add_action( 'after_setup_theme', [ \Alley\WP\Asset_Manager\Styles::class, 'instance' ] ); // @phpstan-ignore-line should not return anything | ||
add_action( 'after_setup_theme', [ \Alley\WP\Asset_Manager\SVG_Sprite::class, 'instance' ] ); // @phpstan-ignore-line should not return anything |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can specify the error ID.
add_action( 'after_setup_theme', [ \Alley\WP\Asset_Manager\Preload::class, 'instance' ] ); // @phpstan-ignore-line should not return anything | |
add_action( 'after_setup_theme', [ \Alley\WP\Asset_Manager\Scripts::class, 'instance' ] ); // @phpstan-ignore-line should not return anything | |
add_action( 'after_setup_theme', [ \Alley\WP\Asset_Manager\Styles::class, 'instance' ] ); // @phpstan-ignore-line should not return anything | |
add_action( 'after_setup_theme', [ \Alley\WP\Asset_Manager\SVG_Sprite::class, 'instance' ] ); // @phpstan-ignore-line should not return anything | |
add_action( 'after_setup_theme', [ \Alley\WP\Asset_Manager\Preload::class, 'instance' ] ); // @phpstan-ignore return.void | |
add_action( 'after_setup_theme', [ \Alley\WP\Asset_Manager\Scripts::class, 'instance' ] ); // @phpstan-ignore return.void | |
add_action( 'after_setup_theme', [ \Alley\WP\Asset_Manager\Styles::class, 'instance' ] ); // @phpstan-ignore return.void | |
add_action( 'after_setup_theme', [ \Alley\WP\Asset_Manager\SVG_Sprite::class, 'instance' ] ); // @phpstan-ignore return.void |
@@ -245,7 +229,7 @@ public function set_asset_type_defaults() {} | |||
public function add_hooks() { | |||
foreach ( $this->load_hooks as $hook => $functions ) { | |||
foreach ( $functions as $function => $priority ) { | |||
add_action( $hook, [ $this, $function ], $priority ); | |||
add_action( $hook, [ $this, $function ], $priority ); // @phpstan-ignore-line expects callable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert
is a noop in production.
add_action( $hook, [ $this, $function ], $priority ); // @phpstan-ignore-line expects callable | |
assert( method_exists( $function, $this ) ); | |
add_action( $hook, [ $this, $function ], $priority ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Annotations are much better for automatic hooking.
https://github.com/szepeviktor/SentencePress/blob/master/src/HookAnnotation.php
... or modern PHP attributes
https://github.com/boxuk/wp-hook-attributes?tab=readme-ov-file#usage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I usually do it with https://mantle.alley.com/docs/features/support/hookable#usage-with-attributes but this is an older plugin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📡 What a space laser you have there!
@srtfisher Please reach 0 errors on level 4. It is very close. |