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

add ", but" for InvalidArgument error message where a type is provided #8364

Merged

Conversation

kkmuffme
Copy link
Contributor

@kkmuffme kkmuffme commented Aug 3, 2022

Added a "but" after the "," in InvalidArgument errors, so one can easily find where the provided type starts. If the function has a param with array{} with many parameters and nested array{}, it is often very hard to find where the expected type ends and the provided type starts.

This is a very simple example, in reality I often had cases with 25+ keys.
https://psalm.dev/r/2e6a506272

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/2e6a506272
<?php

/**
 * @param array{ hello: string, world?: int, lorem: float, ipsum: array|int|float, bar: mixed, xyz: 'dada', abc?: string } $arg
 * @return void
 */
function foo( $arg ) {
 	print_r( $arg );   
}

$data = array(
  'hello' => 'world',
    'foo' => 'bar',
    'ipsum' => array(),
  'balsdk' => 564,
    
);

foo( $data );
Psalm output (using commit 24f7920):

ERROR: InvalidArgument - 19:6 - Argument 1 of foo expects array{abc?: string, bar: mixed, hello: string, ipsum: array<array-key, mixed>|float|int, lorem: float, world?: int, xyz: 'dada'}, array{balsdk: 564, foo: 'bar', hello: 'world', ipsum: array<never, never>} provided

@kkmuffme kkmuffme force-pushed the add-but-to-differentiate-errors-invalidargument branch from 652aa03 to 8076372 Compare August 3, 2022 17:57
@orklah orklah added the release:typo The PR will be included in 'Typos' section of the release notes label Aug 3, 2022
@orklah
Copy link
Collaborator

orklah commented Aug 3, 2022

Seems good! Can you fix remaining CI failures and it'll be good to go

@kkmuffme kkmuffme force-pushed the add-but-to-differentiate-errors-invalidargument branch from 8076372 to d2be169 Compare August 3, 2022 18:12
@orklah orklah merged commit 1ef3851 into vimeo:4.x Aug 3, 2022
@orklah
Copy link
Collaborator

orklah commented Aug 3, 2022

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:typo The PR will be included in 'Typos' section of the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants