| 1 |
<?php |
| 2 |
declare( strict_types=1 ); |
| 3 |
|
| 4 |
/** |
| 5 |
* This program is free software; you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License as published by |
| 7 |
* the Free Software Foundation; either version 2 of the License, or |
| 8 |
* (at your option) any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License along |
| 16 |
* with this program; if not, write to the Free Software Foundation, Inc., |
| 17 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 18 |
* http://www.gnu.org/copyleft/gpl.html |
| 19 |
* |
| 20 |
* @file |
| 21 |
*/ |
| 22 |
|
| 23 |
namespace Wikimedia\JsonCodec; |
| 24 |
|
| 25 |
use Psr\Container\ContainerInterface; |
| 26 |
|
| 27 |
/** |
| 28 |
* Classes implementing this interface support round-trip JSON |
| 29 |
* serialization/deserialization via a JsonClassCodec object |
| 30 |
* (which may maintain state and/or consult service objects). |
| 31 |
* It requires a single static method to be defined which |
| 32 |
* allows the creation of an appropriate JsonClassCodec |
| 33 |
* for this class. |
| 34 |
*/ |
| 35 |
interface JsonCodecable { |
| 36 |
|
| 37 |
/** |
| 38 |
* Create a JsonClassCodec which can serialize/deserialize instances of |
| 39 |
* this class. |
| 40 |
* @param JsonCodecInterface $codec A codec which can be used to handle |
| 41 |
* certain cases of implicit typing in the generated JSON; see |
| 42 |
* `JsonCodecInterface` for details. It should not be necessary for |
| 43 |
* most class codecs to use this, as recursive |
| 44 |
* serialization/deserialization is handled by default. |
| 45 |
* @param ContainerInterface $serviceContainer A service container |
| 46 |
* @return JsonClassCodec A JsonClassCodec appropriate for objects of |
| 47 |
* this type. |
| 48 |
*/ |
| 49 |
public static function jsonClassCodec( |
| 50 |
JsonCodecInterface $codec, |
| 51 |
ContainerInterface $serviceContainer |
| 52 |
): JsonClassCodec; |
| 53 |
} |