Skip to content
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

PHP syntax incompatibility in resolveClassName function #82

Closed
1 task done
omoustaouda opened this issue Oct 15, 2019 · 3 comments
Closed
1 task done

PHP syntax incompatibility in resolveClassName function #82

omoustaouda opened this issue Oct 15, 2019 · 3 comments

Comments

@omoustaouda
Copy link

omoustaouda commented Oct 15, 2019

Package: silverstripe/restfulserver
Version: 2.2.0

Hello,

in this function
\SilverStripe\RestfulServer\RestfulServer::resolveClassName

    protected function resolveClassName(HTTPRequest $request): string
    {
        $className = $request->param('ClassName');
        $aliases = self::config()->get('endpoint_aliases');

        return $aliases[$className] ?? $this->unsanitiseClassName($className);
    }

the return type is specified. : string

This is raising a syntax parsing error in PHP 5.6
but the package is not preventing the usage of PHP 5.6.

I see that this is the only function having the return type specified,
would be safe to remove the return type here?
If yes I can open a 2-lines PR.

This would restore compatibility again with PHP 5.6.

P.S.
In the return statement the null coalescence operator is used too,
again, is present only in this function.

Pulls request

@omoustaouda omoustaouda changed the title PHP syntax incompatibility in \SilverStripe\RestfulServer\RestfulServer::resolveClassName PHP syntax incompatibility in resolveClassName function Oct 15, 2019
@robbieaverill
Copy link
Contributor

Yep, if that's the only occurrence of PHP 7 only syntax then we'd welcome a PR to remove it. While SilverStripe 4.5 onwards will require PHP 7, these satellite modules are currently designed to cater to multiple versions of SilverStripe framework. When the time comes that we will depend on a new feature in core which requires a version bump, we can then start adding new APIs that use PHP 7 syntax.

@maxime-rainville
Copy link

#83 will tweak what was done in #80 so it's PHP5 compatible, but I only did it because it was trivial to fix.

@omoustaouda
Copy link
Author

Oh great!
I understand : )

Thank you all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants