Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pquery
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Taddeüs Kroes
pquery
Commits
e4ec329a
Commit
e4ec329a
authored
13 years ago
by
Taddeus Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Switched position of static/non-static functions.
parent
607f0caf
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pquery.php
+71
-71
71 additions, 71 deletions
pquery.php
with
71 additions
and
71 deletions
pquery.php
+
71
−
71
View file @
e4ec329a
...
...
@@ -80,6 +80,77 @@ class pQuery {
*/
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.
*
...
...
@@ -202,77 +273,6 @@ class pQuery {
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
;
}
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment