Skip to content
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

Draft
wants to merge 1 commit into
base: production
Choose a base branch
from
Draft

Adding PHPStan #68

wants to merge 1 commit into from

Conversation

srtfisher
Copy link
Member

  • 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

@srtfisher srtfisher changed the base branch from production to feature/autoloader December 30, 2024 21:42
@srtfisher srtfisher changed the title Addinh PHPStan Adding PHPStan Dec 30, 2024
Base automatically changed from feature/autoloader to production January 14, 2025 18:17
Comment on lines +64 to +67
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
Copy link

@szepeviktor szepeviktor Jan 15, 2025

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.

Suggested change
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

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.

Suggested change
add_action( $hook, [ $this, $function ], $priority ); // @phpstan-ignore-line expects callable
assert( method_exists( $function, $this ) );
add_action( $hook, [ $this, $function ], $priority );

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@szepeviktor
Copy link

szepeviktor commented Jan 15, 2025

@srtfisher Please reach 0 errors on level 4. It is very close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants