Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8552609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:27:39+00:00 2026-06-11T14:27:39+00:00

The PSR-0/1/2-syntax checker on phphint.org gives this message The first parameter of a multi-line

  • 0

The PSR-0/1/2-syntax checker on phphint.org gives this message

The first parameter of a multi-line function declaration must be on
the line after the opening bracket 

on this code:

// class autoloader for PHP 5.3+
spl_autoload_register( function ($class) {
    include('classes/' . $class . '.class.php');
});

I tried a lot, but never got this little piece of code PSR-0/1/2-save.
How would a solution look like (or is the analyzer on phphint too strict ?) ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:27:40+00:00Added an answer on June 11, 2026 at 2:27 pm

    I fixed this by myself, but the solution is extremely ugly.

    spl_autoload_register( function (
        $class
    ) {
        include('classes/' . $class . '.class.php');
    }
    );
    

    Maybe the PSR-guys should think about their weird syntax.
    The correct solution looks like this, even if it is a step backwards.

    // autoload function (it's NOT "__autoload", __autoload is
    // DEPRECATED since PHP 5.4!)
    function autoload($class) {
        include('classes/' . $class . '.class.php');
    }
    
    // class autoloader for PHP 5.3+, registers the function that's used if a class/file
    // is not found (=autoloader)
    spl_autoload_register('autoload');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get this example from http://www.php.net/manual/ru/function.spl-autoload.php#92767 But this causes an error *Fatal error: spl_autoload()
is anyone aware of lightweight restful lib that is namespaced following psr-0 guide lines.
I have a table given below PSR exon 3311421 E11 3311422 E11 3311423 E11
I am trying to use PhpUnit with Composer. In this purpose I did: 1
I have a large piece of code, part of whose body contains this piece
For my application I am using PSR-0 namespaces. Everything works beautiful! Until I wanted
Firstly, I'm not using rails. This is vanilla ruby application. I've read about packaging
I am trying to change svn:externals property of a remote repository via this command:
I'm dabbling w/ a 'lightweight' PSR-0 AutoLoader for a WordPress Plugin, it runs fine
What's the PSR-2 Standard coding convention for initialization of arrays and method chaining? $foo

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.