Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pquery
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
pquery
Commits
e4ec329a
Commit
e4ec329a
authored
Dec 05, 2011
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switched position of static/non-static functions.
parent
607f0caf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
71 deletions
+71
-71
pquery.php
pquery.php
+71
-71
No files found.
pquery.php
View file @
e4ec329a
...
@@ -80,6 +80,77 @@ class pQuery {
...
@@ -80,6 +80,77 @@ class pQuery {
*/
*/
var
$arguments
=
array
();
var
$arguments
=
array
();
/**
* Parse the type of the given variable, and convert it if needed.
*
* @param mixed $variable The variable to parse.
* @param bool $force Whether not to check the variables type against the accepted types.
*/
function
set_variable
(
$variable
,
$force
=
false
)
{
$this
->
variable
=
$variable
;
if
(
$force
)
return
;
$type
=
gettype
(
$variable
);
$class_name
=
get_class
(
$this
);
$accepts
=
$class_name
::
$accepts
;
if
(
isset
(
$accepts
[
$type
])
)
{
$convert_method
=
$accepts
[
$type
];
if
(
!
method_exists
(
$this
,
$convert_method
)
)
{
return
self
::
error
(
'Plugin "%s" has no conversion method "%s".'
,
$class_name
,
$convert_method
);
}
$result
=
$this
->
$convert_method
(
$variable
);
$result
===
null
||
$this
->
variable
=
$result
;
}
else
if
(
!
in_array
(
$type
,
$accepts
)
)
{
return
self
::
error
(
'Variable type "%s" is not accepted by class "%s".'
,
$type
,
$class_name
);
}
}
/**
* Getter for {@link variable}.
*
* @see variable_alias
*/
function
__get
(
$name
)
{
$class_name
=
get_class
(
$this
);
if
(
in_array
(
$name
,
(
array
)
$class_name
::
$variable_alias
)
)
return
$this
->
variable
;
}
/**
* Setter for {@link variable}.
*
* @see variable_alias
*/
function
__set
(
$name
,
$value
)
{
$class_name
=
get_class
(
$this
);
if
(
in_array
(
$name
,
(
array
)
$class_name
::
$variable_alias
)
)
$this
->
variable
=
$value
;
}
/**
* Handler for pQuery exceptions.
*
* If the execption is a (@link pQueryException}, exit the script with
* its message. Otherwise, throw the exception further.
*
* @param Exception $e The exception to handle.
*/
function
exception_handler
(
$e
)
{
if
(
$e
instanceof
pQueryException
)
die
(
nl2br
(
$e
->
getMessage
()));
throw
$e
;
}
/**
/**
* Extend pQuery with a plugin.
* Extend pQuery with a plugin.
*
*
...
@@ -202,77 +273,6 @@ class pQuery {
...
@@ -202,77 +273,6 @@ class pQuery {
include_once
$path
;
include_once
$path
;
}
}
}
}
/**
* Parse the type of the given variable, and convert it if needed.
*
* @param mixed $variable The variable to parse.
* @param bool $force Whether not to check the variables type against the accepted types.
*/
function
set_variable
(
$variable
,
$force
=
false
)
{
$this
->
variable
=
$variable
;
if
(
$force
)
return
;
$type
=
gettype
(
$variable
);
$class_name
=
get_class
(
$this
);
$accepts
=
$class_name
::
$accepts
;
if
(
isset
(
$accepts
[
$type
])
)
{
$convert_method
=
$accepts
[
$type
];
if
(
!
method_exists
(
$this
,
$convert_method
)
)
{
return
self
::
error
(
'Plugin "%s" has no conversion method "%s".'
,
$class_name
,
$convert_method
);
}
$result
=
$this
->
$convert_method
(
$variable
);
$result
===
null
||
$this
->
variable
=
$result
;
}
else
if
(
!
in_array
(
$type
,
$accepts
)
)
{
return
self
::
error
(
'Variable type "%s" is not accepted by class "%s".'
,
$type
,
$class_name
);
}
}
/**
* Getter for {@link variable}.
*
* @see variable_alias
*/
function
__get
(
$name
)
{
$class_name
=
get_class
(
$this
);
if
(
in_array
(
$name
,
(
array
)
$class_name
::
$variable_alias
)
)
return
$this
->
variable
;
}
/**
* Setter for {@link variable}.
*
* @see variable_alias
*/
function
__set
(
$name
,
$value
)
{
$class_name
=
get_class
(
$this
);
if
(
in_array
(
$name
,
(
array
)
$class_name
::
$variable_alias
)
)
$this
->
variable
=
$value
;
}
/**
* Handler for pQuery exceptions.
*
* If the execption is a (@link pQueryException}, exit the script with
* its message. Otherwise, throw the exception further.
*
* @param Exception $e The exception to handle.
*/
function
exception_handler
(
$e
)
{
if
(
$e
instanceof
pQueryException
)
die
(
nl2br
(
$e
->
getMessage
()));
throw
$e
;
}
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment