0

I've started a new project recently and decided to have some functions under their own namespace (e.g general functional programming functions).

I've created a test and included the annotation but now I'm getting the following warning when testing for coverage:

"@covers ::pipe" is invalid

If I use \Example\FP\pipe the warning goes away but surely that's incorrect as there's nothing indicating it's a function (there's no class either in this case).

I've searched online, even considered raising an issue because as far as I can tell you either have a global function and use @covers ::functionName -or- you're forced to make it a static method.

A few questions:

  1. Is there a known solution when having namespaced functions that I'm just simply missing?
  2. Is the norm to just use static methods? If yes, why is it better than standard functions?
  3. Not needed: Is there a (significant) performance penalty of using static methods over normal functions?

Later edit: 3 - found Performance of static methods vs. functions

JTAnon
  • 1
  • 1
  • Based on the [official documentation](https://phpunit.readthedocs.io/en/9.5/annotations.html#covers), you should only use `@covers ::function` when you want to cover a global function, not a class method... Share you code please (test and function) – matiaslauriti Oct 16 '22 at 15:02
  • Thanks! I know you're trying to help but I read the documentation. The issue is how do you mark as covered a namespaced function (ie Q1). I can add an example but it's quite explicit what I'm asking/describing. – JTAnon Oct 16 '22 at 18:16
  • Well, the documentation is saying you have to do `::function`, are you sure it is global? – matiaslauriti Oct 16 '22 at 18:25

0 Answers0