Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3942628
WithLegacyMethods.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
WithLegacyMethods.php
View Options
<?php
namespace
Keruald\Database
;
use
BadMethodCallException
;
trait
WithLegacyMethods
{
private
static
function
getNewMethodName
(
string
$legacyName
)
:
string
{
return
match
(
$legacyName
)
{
'sql_nextid'
=>
'nextId'
,
'sql_query_express'
=>
'queryScalar'
,
'sql_fetchrow'
=>
'fetchRow'
,
'sql_numrows'
=>
'numRows'
,
default
=>
substr
(
$legacyName
,
4
),
};
}
protected
function
callByLegacyMethodName
(
string
$name
,
array
$arguments
)
{
$newMethodName
=
self
::
getNewMethodName
(
$name
);
if
(!
method_exists
(
$this
,
$newMethodName
))
{
$className
=
get_class
(
$this
);
throw
new
BadMethodCallException
(
"Legacy method doesn't exist: $className::$name"
);
}
trigger_error
(
<<<EOF
\$db->$name calls shall be replaced by \$db->$newMethodName calls.
EOF
,
E_USER_DEPRECATED
);
return
call_user_func_array
(
[
$this
,
$newMethodName
],
$arguments
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Thu, Dec 26, 17:08 (1 d, 9 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2314253
Default Alt Text
WithLegacyMethods.php (1 KB)
Attached To
Mode
rKERUALD Keruald libraries development repository
Attached
Detach File
Event Timeline
Log In to Comment