codemod 2010-2016 to 2010-present
[hiphop-php.git] / hphp / runtime / base / dummy-resource.h
blob18419cc7650645e96df0f8f05dcb179f8686a518
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 | Copyright (c) 1997-2010 The PHP Group |
7 +----------------------------------------------------------------------+
8 | This source file is subject to version 3.01 of the PHP license, |
9 | that is bundled with this package in the file LICENSE, and is |
10 | available through the world-wide-web at the following url: |
11 | http://www.php.net/license/3_01.txt |
12 | If you did not receive a copy of the PHP license and are unable to |
13 | obtain it through the world-wide-web, please send a note to |
14 | license@php.net so we can mail you a copy immediately. |
15 +----------------------------------------------------------------------+
18 #ifndef incl_HPHP_DUMMY_RESOURCE_H_
19 #define incl_HPHP_DUMMY_RESOURCE_H_
21 #include "hphp/runtime/base/resource-data.h"
22 #include "hphp/runtime/base/type-string.h"
24 namespace HPHP {
25 ///////////////////////////////////////////////////////////////////////////////
27 /**
28 * DummyResource is used in a number of places where the runtime wants
29 * to cast a value to the resource type. Ideally, casting a non-resource
30 * value to a resource would throw or produce null, but there are a few
31 * places in the runtime and the extensions that would need to be updated
32 * first to make that work.
34 struct DummyResource : ResourceData {
35 DECLARE_RESOURCE_ALLOCATION_NO_SWEEP(DummyResource);
36 CLASSNAME_IS("Unknown");
37 DummyResource();
38 String m_class_name;
39 const String& o_getClassNameHook() const override;
40 bool isInvalid() const override { return m_class_name.empty(); }
41 void o_setResourceId(int64_t id) { hdr()->setRawId(id); }
44 ///////////////////////////////////////////////////////////////////////////////
47 #endif