Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Raise notice when controller is defined with a starting back slash #30045

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ protected function instantiateController($class)
try {
return parent::instantiateController($class);
} catch (\Error $e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's a notice IMO we should not trigger only on Excpetion

if (0 === strpos($class, '\\')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of deprecating this possibility, what about trimming the starting backslash in the instantiateController method?

@trigger_error(sprintf('The controller definition "%s" must not begin with "\"', $class), E_USER_DEPRECATED);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe: must not start with a slash

Instead of

“\” ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH it's backslash actually ;)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with @OskarStark and you. What about

Suggested change
@trigger_error(sprintf('The controller definition "%s" must not begin with "\"', $class), E_USER_DEPRECATED);
@trigger_error(sprintf('The controller definition "%s" must not start with a backslash.', $class), E_USER_DEPRECATED);

It looks like start with smth is the correct wording: https://www.thefreedictionary.com/words-that-start-with-x .
We should also add a dot, because it's a sentence.

}
}

$this->throwExceptionIfControllerWasRemoved($class, $e);
Expand Down