Skip to content

Commit

Permalink
remove variables in types (are well defined only with type) and added…
Browse files Browse the repository at this point in the history
… resource as PID
  • Loading branch information
manuel-rubio committed May 22, 2015
1 parent 934049f commit c4c0cc7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/ephp_func_vars.erl
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ print_r(Context, Value) ->
print_r(Context, Value, {false,false}).


-spec var_dump(Context :: context(), Value :: var_value()) -> null.
-spec var_dump(context(), var_value()) -> null.

var_dump(Context, {_,Value}) ->
Result = case var_dump_fmt(Context, Value, <<?SPACES_VD>>) of
Expand Down Expand Up @@ -115,7 +115,7 @@ var_dump(Context, {_,Value}) ->
ephp_context:set_output(Context, Result),
null.

-spec print_r(Context :: context(), Value :: var_value(), Output :: boolean()) -> true | binary().
-spec print_r(context(), var_value(), Output :: boolean()) -> true | binary().

print_r(_Context, {_,#reg_instance{class=Class, context=Ctx}}, {_,true}) ->
Data = lists:foldl(fun(#class_attr{name=Name}, Output) ->
Expand Down Expand Up @@ -157,15 +157,15 @@ print_r(Context, {_,Value}, {_,false}) ->
ephp_context:set_output(Context, <<"Array\n(\n", Data/binary, ")\n">>),
true.

-spec isset(Context :: context(), Value :: var_value()) -> boolean().
-spec isset(context(), var_value()) -> boolean().

isset(_Context, {_,Value}) ->
case Value of
undefined -> false;
_ -> true
end.

-spec empty(Context :: context(), Value :: var_value()) -> boolean().
-spec empty(context(), var_value()) -> boolean().

empty(_Context, {_,Value}) ->
case Value of
Expand All @@ -176,19 +176,19 @@ empty(_Context, {_,Value}) ->
_ -> false
end.

-spec gettype(Context :: context(), Value :: var_value()) -> binary().
-spec gettype(context(), var_value()) -> binary().

gettype(_Context, {_,Value}) when is_boolean(Value) -> <<"boolean">>;
gettype(_Context, {_,Value}) when is_integer(Value) -> <<"integer">>;
gettype(_Context, {_,Value}) when is_float(Value) -> <<"double">>;
gettype(_Context, {_,Value}) when is_binary(Value) -> <<"string">>;
gettype(_Context, {_,Value}) when ?IS_DICT(Value) -> <<"array">>;
gettype(_Context, {_,Value}) when is_record(Value, reg_instance) -> <<"object">>;
%% TODO: resource type
gettype(_Context, {_,Value}) when is_pid(Value) -> <<"resource">>;
gettype(_Context, {_,null}) -> <<"NULL">>;
gettype(_Context, {_,_}) -> <<"unknown type">>.

-spec unset(Context :: context(), Var :: var_value()) -> null.
-spec unset(context(), var_value()) -> null.

unset(Context, {Var,_}) ->
%% TODO: find objects in remove data to run __destruct if it's defined.
Expand Down

0 comments on commit c4c0cc7

Please sign in to comment.