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 Compile error since last update #2655

Closed
davey013 opened this issue Mar 7, 2014 · 27 comments
Closed

PHP Compile error since last update #2655

davey013 opened this issue Mar 7, 2014 · 27 comments

Comments

@davey013
Copy link

davey013 commented Mar 7, 2014

Since last update i get this error (PHP Compile Error):

Declaration of yii\base\ArrayableTrait::toArray(array $fields = Array, array $expand = Array, $recursive = true) must be compatible with yii\base\Arrayable::toArray()
@samdark
Copy link
Member

samdark commented Mar 7, 2014

Can you post full error stack?

@davey013
Copy link
Author

davey013 commented Mar 7, 2014

image

I get this on every page (even gii)

@cebe cebe added this to the 2.0 Beta milestone Mar 7, 2014
@samdark
Copy link
Member

samdark commented Mar 7, 2014

Aha. That is yii\base\Model that both implements Arrayable and uses ArrayableTrait which has different signatures for toArray.

@qiangxue seems to be your change for API. Can you take a look?

@o-rey
Copy link
Contributor

o-rey commented Mar 7, 2014

I wonder why I'm not getting this error (updated 5 min ago to see it for myself).

UPD: php 5.5.3

@samdark
Copy link
Member

samdark commented Mar 7, 2014

@davey-w which PHP version do you have?

@arashkarimian
Copy link

@samdark same here, 5.4.12

@samdark
Copy link
Member

samdark commented Mar 7, 2014

@o-rey are you using any models? error_reporting(-1)?

@o-rey
Copy link
Contributor

o-rey commented Mar 7, 2014

@samdark yes, I use a lot of models :) And no, it just works. No errors/notices at all. Php 5.5.3 / ubuntu. Any special code I should run to get into this?

I remember some strange things happened some time ago, but they were caused by buggy opcache in my installation.

@samdark
Copy link
Member

samdark commented Mar 7, 2014

Hmm, actually tried advanced application with lots of models and no error appeared. I have 5.5.4.

@davey013
Copy link
Author

davey013 commented Mar 7, 2014

I'm running on PHP 5.4.12

@samdark
Copy link
Member

samdark commented Mar 7, 2014

Tried 5.4.20 as well. No error.

@subdee
Copy link
Contributor

subdee commented Mar 7, 2014

I think it was an issue in PHP 5.4.12 which was fixed in 5.4.14.

Not sure if it's related though.

@davey013
Copy link
Author

davey013 commented Mar 7, 2014

Hmm i see, is there a way to avoid this? Since i'm running WAMP (64-bit) and 5.4.12 is only available for that.

@qiangxue
Copy link
Member

qiangxue commented Mar 7, 2014

We may need to confirm if this is indeed an issue introduced in 5.4.12, and what about 5.4.11 and 5.4.13.

@subdee Could you please try the following three pieces of code (separately) and see if they work fine?

class Test11
{
    public function test()
    {
    }
}

class Test12 extends Test11
{
    public function test($a = 1)
    {
    }
}
interface Test21
{
    public function test();
}

class Test22 implements Test21
{
    public function test($a = 1)
    {
    }
}
interface Test31
{
    public function test();
}

trait Test31Trait
{
    public function test($a = 1)
    {
    }
}

class Test32 implements Test31
{
    use Test31Trait;
}

Reopened for as further investigation is needed.

@qiangxue qiangxue reopened this Mar 7, 2014
@subdee
Copy link
Contributor

subdee commented Mar 7, 2014

@qiangxue Only the last one with the trait fails on php 5.4.12 and 5.4.13

@o-rey
Copy link
Contributor

o-rey commented Mar 7, 2014

PHP Version 5.4.4-14+deb7u7 - all is well.

@qiangxue
Copy link
Member

qiangxue commented Mar 7, 2014

@o-rey Do you mean 5.4.4 to 5.4.14 all worked fine? I'm curious how did you manage to test so many versions easily?

@subdee
Copy link
Contributor

subdee commented Mar 7, 2014

haha I think he meant a specific revision of 5.4.4 for Debian

@o-rey
Copy link
Contributor

o-rey commented Mar 7, 2014

@qiangxue oops sorry :) it's only one installation that I have by chance on remote.

@cebe
Copy link
Member

cebe commented Mar 7, 2014

looks like travis can do this for us: 315cfbc https://travis-ci.org/yiisoft/yii2/builds/20288396

@samdark
Copy link
Member

samdark commented Mar 7, 2014

Nice :)

@cebe
Copy link
Member

cebe commented Mar 7, 2014

oh, looks like not all the versions are possible. lets wait for the result.

@subdee
Copy link
Contributor

subdee commented Mar 7, 2014

nice try @cebe 👍

This tool could help for trying out snippets on different versions though

@qiangxue
Copy link
Member

qiangxue commented Mar 7, 2014

Good try. @subdee Thanks for the info. It seems 5.4.11, 5.4.12, 5.4.13 all have problem. 5.4.10 and 5.4.21 are fine.

@qiangxue
Copy link
Member

qiangxue commented Mar 7, 2014

Options to deal with this issue:

  1. Add documentation about unsupported versions;
  2. Modify Arrayable interface;
  3. Introduce a different interface and trait for converting an object to an array with customizable fields.

Which one do you like?

@subdee
Copy link
Contributor

subdee commented Mar 7, 2014

My thoughts.

  1. Although I expect that most people won't have trouble with their webhosts (I assume webhosts update their PHPs), I'd rather not have such specific revisions preventing developers from using the framework.
  2. Not sure, renaming the function destroys consistency. Maybe by defining the same parameters/values as in the trait?
  3. I think this could be overkill.

@abrahamgreyson
Copy link
Contributor

I'm not sure but I think maybe people don't like unsupported thing.

cebe added a commit that referenced this issue Mar 8, 2014
* 'master' of github.com:yiisoft/yii2:
  Make code coverage work
  Note about  embedded documents added to mongodb extension readme
  yii\mongodb\file\Collection::ensureMongoId() fixed to suppress exception on invalid _id format.
  yii\mongodb\file\ActiveRecord::update() fixed to save the attributes while updating file.
  Fixes #2661: Added boolean column type support for SQLite
  Refactored controller creation process.
  Added back some toArray() implementations.
  Fixed test break.
  Update console-migrate.md
  Fixes #2655: Arrayable and ArrayableTrait are incompatible for some PHP versions.
  Fixes #2659
  Minor code style fixes for apidoc
  Changed assertions
  fix tests
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

8 participants