src/AbstractMessage.php
final public static function schema()
    {
        $type = get_called_class();
        if (!isset(self::$schemas[$type])) {
            $schema = static::defineSchema();

            if (!$schema instanceof Schema) {
                throw new SchemaNotDefined(
                    sprintf('Message [%s] must return a Schema from the defineSchema method.', $type)
                );
            }

            if ($schema->getClassName() !== $type) {
                throw new SchemaNotDefined(
                    sprintf(
                        'Schema [%s] returned from defineSchema must be for class [%s], not [%s]',
                        $schema->getId()->toString(),
                        $type,
                        $schema->getClassName()
                    )
                );
            }
            self::$schemas[$type] = $schema;
        }
        return self::$schemas[$type];
    }
final public static function schema()
    {
        $type = get_called_class();
        if (!isset(self::$schemas[$type])) {
            $schema = static::defineSchema();

            if (!$schema instanceof Schema) {
                throw new SchemaNotDefined(
                    sprintf('Message [%s] must return a Schema from the defineSchema method.', $type)
                );
            }

            if ($schema->getClassName() !== $type) {
                throw new SchemaNotDefined(
                    sprintf(
                        'Schema [%s] returned from defineSchema must be for class [%s], not [%s]',
                        $schema->getId()->toString(),
                        $type,
                        $schema->getClassName()
                    )
                );
            }
            self::$schemas[$type] = $schema;
        }
        return self::$schemas[$type];
    }
{@inheritdoc}
@return Schema