phpstan-webmozart-assert icon indicating copy to clipboard operation
phpstan-webmozart-assert copied to clipboard

Support the new methods in 1.4

Open Nyholm opened this issue 6 years ago • 3 comments

I released 1.4.0 with some new assertions that should be added here.

  • Assert::ip()
  • Assert::ipv4()
  • Assert::ipv6()
  • Assert::notRegex()
  • Assert::interfaceExists()
  • Assert::isList()
  • Assert::isMap()

Nyholm avatar Jan 10 '19 14:01 Nyholm

@Nyholm I'm planning to work on it the next week cc/ @ondrejmirtes

mavimo avatar Jan 11 '19 07:01 mavimo

Maybe good to change the title to Support the new methods between 1.4 and 1.7 https://github.com/webmozart/assert/blob/1.7.0/CHANGELOG.md#170-2020-02-14

ruudk avatar Feb 18 '20 08:02 ruudk

fyi @ondrejmirtes I went through methods in webmozart/assert and what we support here and saw that only the following don't further specify types:

type:

  • Assert::uniqueValues() (in https://github.com/phpstan/phpstan-webmozart-assert/pull/178 we learned that we can't narrow array further unfortunately..)

string:

  • Assert::notContains()
  • Assert::notStartsWith()
  • Assert::notEndsWith()
  • Assert::regex()
  • Assert::notRegex()

file:

  • Assert::fileExists()
  • Assert::file()
  • Assert::directory()
  • Assert::readable()
  • Assert::writable()

object:

  • Assert::propertyNotExists()
  • Assert::methodNotExists()

function:

  • Assert::throws()

I'm not sure if more is possible. Related to this issue the only one left is notRegex(), which checks that a string does not match a given regex. Not sure, but I don't think we can specify further types here, except doing something with constant strings maybe, but not sure if it's possible/worth.

IMO this issue can be closed, what do you think?

herndlm avatar Mar 29 '24 13:03 herndlm