Adding a separate syntax to refer to constants in docblocks looks like a cleaner solution to me
You are right, I agree.
The problem with
E_ERROR | E_USER_ERROR
is that it's not clear whether it refers to constants or classes.
Sure, but that could be "worked around" by only supporting that when use const E_ERROR
etc. is used. That way Psalm should know that in the context of the current scope E_ERROR
is a constant and not a class.
hello @sebastianbergmann , we are currently using v10.0.19 and phpunit is still not stopping using the flag
--stop-on-defect
when a warning is raised.we also tried with dev-main 3a680a9 but still no luck. any ideas?
Please open a new ticket and provide a minimal, self-contained, reproducing test case that shows the problem you are reporting. Without such a minimal, self-contained, reproducing test case I will not be able to investigate this issue.
According to this test, --stop-on-defect
correctly aborts test execution after the first test that triggered a warning.
Sorry to comment on a closed issue, but I see that this bug is supposed to be fixed in version 10.0.4, but I still get it:
bin/phpunit --stop-on-failure PHPUnit 10.0.4 by Sebastian Bergmann and contributors. Runtime: PHP 8.1.1 Configuration: /user/myapp/phpunit.xml.dist .....E....................................................... 61 / 61 (100%) Time: 00:05.680, Memory: 72.50 MB There was 1 error
An error is not a failure, these are treated separately.
Hey @sebastianbergmann, can you reproduce the issue on https://psalm.dev ?
Yes, my dear bot, I can.
https://github.com/vimeo/psalm/issues/9582#issue-1645866657 contains the reproducing example as well as the output generated by https://psalm.dev/ for it.
Initial work on filtering deprecations, notices, and warnings
I would like to narrow the type for $errorLevel
from int
to a specified list of possible integer values using global constants:
<?php declare(strict_types=1);
/** @psalm-param E_ERROR|E_USER_ERROR $errorLevel */
function f(int $errorLevel): void
{
}
This is currently not possible:
ERROR: [UndefinedDocblockClass](https://psalm.dev/200) - 2:18 - Docblock-defined class, interface or enum named E_ERROR does not exist
ERROR: [UndefinedDocblockClass](https://psalm.dev/200) - 2:18 - Docblock-defined class, interface or enum named E_USER_ERROR does not exist
ERROR: [MismatchingDocblockParamType](https://psalm.dev/141) - 2:18 - Parameter $errorLevel has wrong type 'E_ERROR|E_USER_ERROR', should be 'int'
The Psalm output shown above was was generated using commit e2abc3e.
Furthermore, and similarly to how class constants that share a common prefix are supported, I would like to be able to use the following:
<?php declare(strict_types=1);
/** @psalm-param E_* $errorLevel */
function f(int $errorLevel): void
{
}
I need to define a PHP binary path in PhpUnit which will be used by PhpUnit, instead of the default from the OS.
I think such a use case is outside the scope of both this project as well as outside of PHPUnit.
That being said, I think PHP_BINARY !== ''
is a leftover from a time where PHP_BINARY
was not always available.
Closes #5285
Merge branch '10.0'
Prepare release
Merge branch '10.0'
Add test for #5287
Merge branch '10.0'
Change test fixture for #5287 to more closely resemble a real world use case
Update test expectation
Merge branch '10.0'
Closes #5287
Merge branch '10.0'
Add test for #5288
Merge branch '8.5' into 9.6
Merge branch '9.6' into 10.0
Closes #5288
Merge branch '10.0'
Use rtrim() instead of str_replace()
Merge branch '10.0'
Prepare release
Merge branch '10.0'
Fix CS/WS issue
Make Psalm happy
Merge branch '9.5'
Update tools
Merge branch '8.5' into 9.5
Merge branch '9.5'
Update tools
Merge branch '8.5' into 9.5
Merge branch '9.5'
Store test data in serialize()d form, if possible
Revert "Store test data in serialize()d form, if possible"
This reverts commit 9c6d7ad0cbe51bded7a987cee757594a276a6d19.
Reorganize
Store test data in serialize()d form, if possible
Revert "Store test data in serialize()d form, if possible"
This reverts commit 7aff2713c05843ae720a186b55e76fb55f911668.
Reorganize
Improve test names in fixture
Implement TestMethod::prettifiedClassName() and TestMethod::prettifiedMethodName()
Remove id
Improve type safety
Only consider method-level TestDox metadata
Fix PHP attribute syntax error
Merge branch '10.0'
Fix PHP attribute syntax error
I am not sure what to make of this ticket.
Thanks!
readme: added note about Git diffs
https://www.artima.com/weblogs/viewpost.jsp?thread=164293
https://www.artima.com/weblogs/viewpost.jsp?thread=164293
Reorganize
Merge branch '10.0'
Follow RFC 4180 and use field instead of column
Follow RFC 4180 and use record instead of row
Implement Parser::setEnclosure()
Eliminate code duplication
Implement Parser::setEscape()
Refactor
Implement Parser::setSeparator()
Closes #5270
Fix section title
Prepare release
Merge branch '9.6' into 10.0
Prepare release
Merge branch '10.0'
Closes #5270
Prepare release
Merge branch '9.6' into 10.0
Prepare release