16 "postModify" => array(
17 "newName" =>
"postStore",
21 "specRefresh" => array(
22 "newName" =>
"preRefresh",
27 "newName" =>
"postDuplicate",
28 "declare" =>
'&$copyfrom',
32 "newName" =>
"preDuplicate",
33 "call" =>
'$copyfrom',
34 "declare" =>
'&$copyfrom'
36 "postRevive" => array(
37 "newName" =>
"postUndelete",
42 "newName" =>
"preUndelete",
46 "getSpecTitle" => array(
47 "newName" =>
"getCustomTitle",
51 "postInsertDoc" => array(
52 "newName" =>
"postInsertDocument",
53 "call" =>
'$docid, $multiple',
54 "declare" =>
'$docid, $multiple = false'
56 "preInsertDoc" => array(
57 "newName" =>
"preInsertDocument",
58 "call" =>
'$docid, $multiple',
59 "declare" =>
'$docid, $multiple = false'
61 "postUnlinkDoc" => array(
62 "newName" =>
"postRemoveDocument",
63 "call" =>
'$docid, $multiple',
64 "declare" =>
'$docid, $multiple = false'
66 "preUnlinkDoc" => array(
67 "newName" =>
"preRemoveDocument",
68 "call" =>
'$docid, $multiple',
69 "declare" =>
'$docid, $multiple = false'
71 "postMInsertDoc" => array(
72 "newName" =>
"postInsertMultipleDocuments",
74 "declare" =>
'$tdocid'
77 private $content =
'';
78 private $methods = array();
82 $this->methods = array();
83 $this->content = $phpContent;
86 private function extractMethods()
88 if (count($this->methods) > 0)
return;
89 $tokens = token_get_all($this->content);
91 foreach ($tokens as $token) {
92 if (is_array($token)) {
93 if ($token[0] === T_FUNCTION) {
97 if ($funcHunt && $token[0] === T_STRING) {
98 $this->methods[] = strtolower($token[1]);
102 if ($token ===
';' || $token ===
'{') {
108 $this->testDoubleDeclaration();
111 private function testDoubleDeclaration()
113 foreach ($this->deprecatedHooks as $dName =>
$info) {
114 $nTestingName = strtolower(
$info[
"newName"]);
115 $dTestingName = strtolower($dName);
116 if (in_array($nTestingName, $this->methods) && in_array($dTestingName, $this->methods)) {
117 throw new \Dcp\Exception(
"MTHD0003", $dName,
$info[
"newName"]);
123 $dh = array_keys($this->deprecatedHooks);
124 foreach ($dh as $k => $v) {
125 $dh[$k] = strtolower($v);
132 $dh = array_values($this->deprecatedHooks);
133 foreach ($dh as $k => $v) {
134 $dh[$k] = strtolower($v[
"newName"]);
141 $this->extractMethods();
147 $this->extractMethods();
153 foreach ($this->deprecatedHooks as $dName => $nName) {
154 if (strtolower($dName) == strtolower($deprecatedName))
return $nName[
"newName"];
161 foreach ($this->deprecatedHooks as $dName => $nName) {
162 if (strtolower($dName) == strtolower($deprecatedName))
return $nName[
"call"];
169 foreach ($this->deprecatedHooks as $dName => $nName) {
170 if (strtolower($dName) == strtolower($deprecatedName))
return $nName[
"declare"];
176 foreach ($this->deprecatedHooks as $dName => $nName) {
177 if (strtolower($nName[
"newName"]) == strtolower($newName))
return $dName;
184 foreach ($this->deprecatedHooks as $dName => $nName) {
185 if (strtolower($nName[
"newName"]) == strtolower($name))
return $nName[
"newName"];
186 if (strtolower($dName) == strtolower($name))
return $dName;
194 foreach ($dh as $dHook) {
196 $alias.=
"\n/**\n*generated alias : new method name\n";
197 $alias.= sprintf(
"*@deprecated declare %s instead\n", $nHook);
198 $alias.= sprintf(
"*/\n");
204 foreach ($nh as $nHook) {
206 $alias.=
"\n/**\n*generated alias : old compatibility\n";
207 $alias.= sprintf(
"*@deprecated alias for %s\n", $nHook);
208 $alias.= sprintf(
"*/\n");
getNewHookName($deprecatedName)
getDeprecatedHookName($newName)
generateCompatibleMethods()
getArgDeclareHook($deprecatedName)
getArgCallHook($deprecatedName)
inspectContent($phpContent)