1

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

3
  • Based on the official documentation, 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) Commented Oct 16, 2022 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. Commented Oct 16, 2022 at 18:16
  • Well, the documentation is saying you have to do ::function, are you sure it is global? Commented Oct 16, 2022 at 18:25

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.