PHP Classes

File: vendor/gabordemooij/redbean/RedBeanPHP/TypedModel.php

Recommend this page to a friend!
  Classes of Adrian M   upMVC   vendor/gabordemooij/redbean/RedBeanPHP/TypedModel.php   Download  
File: vendor/gabordemooij/redbean/RedBeanPHP/TypedModel.php
Role: Class source
Content type: text/plain
Description: Class source
Class: upMVC
Pure PHP web development without other frameworks
Author: By
Last change:
Date: 1 month ago
Size: 880 bytes
 

Contents

Class file image Download
<?php

namespace RedBeanPHP;

use
RedBeanPHP\SimpleModel as SimpleModel;

/**
 * TypedModel
 * Just like the standard SimpleModel but allows for
 * better type hinting in PHP 8 and higher.
 *
 * Usage:
 *
 * define( 'REDBEAN_MODEL_PREFIX', '\\' );
 * R::setup();
 * class Book extends \RedBeanPHP\TypedModel { }
 * $book = R::dispense('book');
 * $book = Book::cast($book);
 * var_dump( $book ); -- and you'll see Book...
 *
 * @file RedBeanPHP/TypeModel.php
 * @author Gabor de Mooij and the RedBeanPHP Team
 * @license BSD/GPLv2
 *
 * @copyright
 * copyright (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community
 * This source file is subject to the BSD/GPLv2 License that is bundled
 * with this source code in the file license.txt.
 */
class TypedModel extends SimpleModel
{
    public static function
cast($instance): static
    {
        return
$instance->box();
    }
}