def METHOD_NAME(recwarn):
    class Foo:
        @staticmethod
        def add(x, y):
            """Add x and y."""
            return x + y
        do_plus = legacy_alias(add, "do_plus", since="v1.2")
    assert Foo.add.__doc__ == "Add x and y."
    assert Foo.do_plus.__doc__ == (
        "\n"
        ".. deprecated:: v1.2\n"
        "   Usage of this legacy static method is deprecated. Use\n"
        "   :py:meth:`.add` instead.\n"
    )
    assert Foo().add(2, 3) == 5
    assert len(recwarn) == 0
    expected_warning = re.escape(
        "Call to deprecated function (or staticmethod) add."
        " (Usage of this legacy static method is deprecated. Use `.add` instead.)"
        " -- Deprecated since version v1.2."
    )
    with pytest.warns(UserDeprecationWarning, match=expected_warning):
        res = Foo().do_plus(2, 3)
    assert res == 5
    with pytest.warns(UserDeprecationWarning, match=expected_warning):
        res = Foo.do_plus(2, 3)
    assert res == 5