laminas / laminas-stdlib

SPL extensions, array utilities, error handlers, and more
https://docs.laminas.dev/laminas-stdlib/
BSD 3-Clause "New" or "Revised" License
190 stars 40 forks source link

Mocking ParametersInterface leads to Deprecation messages #85

Closed mimmi20 closed 1 year ago

mimmi20 commented 1 year ago

Bug Report

Q A
Version(s) 3.17.0

Summary

When Mocking the ParametersInterface, the following Deprecation message is created:

Mock_ParametersInterface_a1ece25f implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary)

Current behavior

The deprecation message is created.

How to reproduce

run the following test

<?php

use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\MockObject\Exception;

class RequestTest extends TestCase
{
    /** @throws Exception */
    public function testGetQuery(): void
    {
        $query = $this->createMock(\Laminas\Stdlib\ParametersInterface::class);
        $query->expects(static::never())
            ->method('get');

        $request = new \Laminas\Http\Request();
        $request->setQuery($query);

        self::assertSame($query, $request->getQuery());
    }
}

Expected behavior

no Deprecation message.

Ocramius commented 1 year ago

We can't just drop an interface without massive BC implications anyway: has to stay for the foreseeable future.

A deprecation warning here is better than a hard downstream system crash.

mimmi20 commented 1 year ago

Could this be implemented in version 4?

Ocramius commented 1 year ago

Most likely, but for just a deprecation issue, it isn't worth pursuing a new major release.