Skip to content

Commit

Permalink
Remove __autoload and spl_autoloader_*
Browse files Browse the repository at this point in the history
Summary:
- You can only use these to autoload classes so it makes no sense to use them
- Makes the code nicer cleaning up stuff.

Reviewed By: jano

Differential Revision: D20807780

fbshipit-source-id: adeae2d13d49dffc8d64d77c130e45dcd5179511
  • Loading branch information
WizKid authored and facebook-github-bot committed Apr 8, 2020
1 parent f1d5ecc commit 6f24761
Show file tree
Hide file tree
Showing 360 changed files with 728 additions and 2,863 deletions.
12 changes: 0 additions & 12 deletions hphp/hack/hhi/stdlib/builtins_spl.hhi
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,6 @@ function iterator_apply($obj, $func, $params = null);
function iterator_count($obj);
<<__PHPStdLib>>
function iterator_to_array($obj, bool $use_keys = true);
<<__PHPStdLib>>
function spl_autoload_call(string $class_name);
<<__PHPStdLib>>
function spl_autoload_extensions(string $file_extensions = "");
<<__PHPStdLib>>
function spl_autoload_functions();
<<__PHPStdLib>>
function spl_autoload_register($autoload_function = null, bool $throws = true, bool $prepend = false);
<<__PHPStdLib>>
function spl_autoload_unregister($autoload_function);
<<__PHPStdLib>>
function spl_autoload(string $class_name, $file_extensions = null);

class SplDoublyLinkedList<T> implements Iterator<T>, ArrayAccess<int, T>, Countable {
public function bottom(): T;
Expand Down
4 changes: 1 addition & 3 deletions hphp/hack/src/naming/naming_special_names.ml
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,11 @@ module SpecialFunctions = struct

let assert_ = "assert"

let autoload = "__autoload"

let hhas_adata = "__hhas_adata"

let is_special_function =
let all_special_functions =
HashSet.of_list [tuple; echo; assert_; autoload; hhas_adata]
HashSet.of_list [tuple; echo; assert_; hhas_adata]
in
(fun x -> HashSet.mem all_special_functions x)
end
Expand Down
4 changes: 1 addition & 3 deletions hphp/hack/src/naming/naming_special_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,14 +405,12 @@ pub mod special_functions {

pub const ASSERT_: &str = "assert";

pub const AUTOLOAD: &str = "__autoload";

pub const HHAS_ADATA: &str = "__hhas_adata";

pub fn is_special_function(x: &str) -> bool {
lazy_static! {
static ref ALL_SPECIAL_FUNCTIONS: Vec<&'static str> =
vec![TUPLE, ECHO, ASSERT_, AUTOLOAD, HHAS_ADATA,]
vec![TUPLE, ECHO, ASSERT_, HHAS_ADATA,]
.into_iter()
.collect();
}
Expand Down
10 changes: 0 additions & 10 deletions hphp/hack/src/parser/lowerer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3532,19 +3532,9 @@ where
let function_type_parameter_list = &c.function_type_parameter_list;
let function_parameter_list = &c.function_parameter_list;
let function_type = &c.function_type;
let is_autoload = Self::text_str(function_name, env)
.eq_ignore_ascii_case(special_functions::AUTOLOAD);
if function_name.value.is_missing() {
Self::raise_parsing_error(function_name, env, &syntax_error::empty_method_name);
}
let num_params = Self::syntax_to_list(false, function_parameter_list).len();
if is_autoload && num_params > 1 {
Self::raise_parsing_error(
node,
env,
&syntax_error::autoload_takes_one_argument,
);
}
let kinds = Self::p_kinds(function_modifiers, env)?;
let has_async = kinds.has(modifier::ASYNC);
let has_coroutine = kinds.has(modifier::COROUTINE);
Expand Down
2 changes: 0 additions & 2 deletions hphp/hack/src/parser/syntax_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -836,8 +836,6 @@ pub fn invalid_is_as_expression_hint(n: &str, hint: &str) -> Error {
))
}
pub const elvis_operator_space: Error = Cow::Borrowed("An Elvis operator ('?:') is expected here.");
pub const autoload_takes_one_argument: Error =
Cow::Borrowed("__autoload() must take exactly 1 argument");
pub fn clone_takes_no_arguments(class_name: &str, method_name: &str) -> Error {
Cow::Owned(format!(
"Method {}::{} cannot accept any arguments",
Expand Down
Loading

0 comments on commit 6f24761

Please sign in to comment.