Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 23 18:30
    jakubmisek commented #496
  • Aug 23 18:27
    jakubmisek labeled #497
  • Aug 23 18:27
    jakubmisek assigned #497
  • Aug 23 18:25
    jakubmisek commented #496
  • Aug 23 18:25
    jakubmisek commented #496
  • Aug 23 18:15
    jakubmisek labeled #496
  • Aug 23 18:15
    jakubmisek assigned #496
  • Aug 23 15:44
    aschwin closed #499
  • Aug 23 15:44
    aschwin commented #499
  • Aug 23 15:16
    calvinbaart commented #499
  • Aug 23 15:03
    aschwin opened #499
  • Aug 23 12:20
    calvinbaart opened #498
  • Aug 23 12:11
    calvinbaart opened #497
  • Aug 23 11:31
    calvinbaart edited #496
  • Aug 23 11:30
    calvinbaart opened #496
  • Aug 23 09:55
  • Aug 23 07:55
    aschwin commented #155
  • Aug 22 23:09

    jakubmisek on master

    conversion to callable (compare)

  • Aug 22 21:52
    jakubmisek commented #489
  • Aug 22 21:52
    jakubmisek commented #494
Calvin Baart
@calvinbaart
Anyone tried compiling Mockery in with PHPUnit? I'm getting some compile errors related to class_alias that I can't seem to reproduce in a minimal sample :/
Benjamin Fistein
@bfistein
@calvinbaart I'm not sure, but people have reported issues previously, and someone even submitted this to their repo: mockery/mockery#897. Posting this here just in case it helps you in any way.
Calvin Baart
@calvinbaart

Thanks! It seems my issue is related to some conditional compilation of classes in Mockery, not sure how PeachPie should handle that. Basically it has the following classes: MockeryTestCaseSetUpForV7AndPrevious and MockeryTestCaseSetUpForV8 and uses an if-statement to determine which of the two to alias:

if (class_exists('PHPUnit_Framework_TestCase') || version_compare(\PHPUnit\Runner\Version::id(), '8.0.0', '<')) {
    class_alias(MockeryTestCaseSetUpForV7AndPrevious::class, MockeryTestCaseSetUp::class);
} else {
    class_alias(MockeryTestCaseSetUpForV8::class, MockeryTestCaseSetUp::class);
}

That causes issues in PeachPie, PeachPie seems to think that MockeryTestCaseSetUp doesn't exist. (I guess that the if-statements aren't evaluated at compile time?)

I'm working on a more minimal test-case but haven't had much luck yet

Daniel Llewellyn
@diddledan
I haven't got a clue how to get PHPUnit running to test one of my projects in PeachPie.
Calvin Baart
@calvinbaart
https://github.com/calvinbaart/laravel-peachpie-sample/tree/feature/laravel-sdk/Laravel.Tests
I'm currently working on it here, trying to work-around some issues though
Calvin Baart
@calvinbaart
Finally figured out the issue with Mockery :) I have created a minimal test case for it here: peachpiecompiler/peachpie#465
Benjamin Fistein
@bfistein
Great, thanks @calvinbaart. As Jakub mentioned, this is because Bar cannot be resolved at compile time and has to be dynamically compiled during runtime, which is a feature that's on the roadmap, but not until after version 1.0. For now, the workaround is to add a use statement, as follows:
use Foo as Bar;
Calvin Baart
@calvinbaart
Yea, I'm current adding post-autoload-dump patches to work-around some issues when using composer packages...Hopefully Laravel itself doesn't use that too-much :)
Benjamin Fistein
@bfistein
Amazing work, really impressed and looking forward to your progress
Calvin Baart
@calvinbaart
Got laravel running with a controller implemented in C#. Still need to figure out a way to run Artisan so that I can do a view:cache step before compiling (view:cache compiles all the blade files to php files so that they can be compiled in)
Benjamin Fistein
@bfistein
That's pretty awesome. If you feel like writing up a tutorial about that or anything, we'd be more than happy to feature it on our blog under your name!
Calvin Baart
@calvinbaart
I'll write something up after making it a bit more....user-friendly. Still requires alof of user-actions (like the view:cache etc.) to make sure it even runs (and I haven't even touched anything database-related yet...) Still good to see that most of the routing stuff and the container system from laravel function in PeachPie.
Calvin Baart
@calvinbaart
Is there a way to check if a file has been compiled in? For example Laravel Blade currently caches its "compiled" blade files and I would like to check if they have been compiled in, otherwise I want to eval them (slower, but allows dynamic php files)
Calvin Baart
@calvinbaart

Well, with a few hacky-workarounds in the PeachPie compiler itself, some patches made to phpunit/mockery and the fixes made by Jakub I can finally run the full test suite without it crashing somewhere in the middle. Current results are:

Tests: 3742, Assertions: 5375, Errors: 1521, Failures: 151, Warnings: 7, Skipped: 17.

Calvin Baart
@calvinbaart
Seems that all the database-related unit tests fail because they use SQLite for them
Calvin Baart
@calvinbaart
Alright, setup travis-ci to autorun the unit tests: https://travis-ci.com/calvinbaart/laravel-peachpie-sample/builds/123644740 it will automatically pull in the latest peachpie master so that should give some diagnostics into the state of laravel
Benjamin Fistein
@bfistein
Really awesome. Mini promo tweet coming your way tomorrow afternoon.
Jakub Míšek
@jakubmisek
@calvinbaart add class_alias above - PeachPie evaluates "if" conditions in release mode but it doesn't matter; class_alias is a function that dynamically introduces a class alias into the runtime - it won't and can't be evaluated in compile-time.
Calvin Baart
@calvinbaart
@jakubmisek I would like to verify if #485 is now correct but I can't seem to run PHPUnit anymore since the latest changes. Seems to be related to the dynamic call to mb_substr I had earlier. Any suggestions how to fix that? I tried removing all compiled files but it still generates a dynamic call here :/
For example this single line: echo substr("hello", 1, null) . "\r\n"; causes a crash here
Calvin Baart
@calvinbaart
Jakub Míšek
@jakubmisek
@calvinbaart still the same crash?
Calvin Baart
@calvinbaart
@jakubmisek This exception in PHPUnit: https://pastebin.com/dy1PGB5g When I run the single line above I get a different exception though:
Unhandled Exception: System.NotImplementedException: costof(System.Object -> System.Int32)
   at Pchp.Core.Dynamic.ConvertExpression.BindCost(Expression arg, Type target)
   at Pchp.Core.Dynamic.OverloadBinder.ArgumentsBinder.BindCostOf(Int32 srcarg, Type ptype, Boolean ismandatory, Boolean ignorecost)
   at Pchp.Core.Dynamic.OverloadBinder.BindCostOf(MethodBase method, ArgumentsBinder args, BitArray costofargs, ConversionCost& minCost)
   at Pchp.Core.Dynamic.OverloadBinder.BindOverloadCall(Type treturn, Expression target, MethodBase[]& methods, Expression ctx, ArgumentsBinder args, Boolean isStaticCallSyntax, PhpTypeInfo lateStaticType)
   at Pchp.Core.Dynamic.OverloadBinder.BindOverloadCall(Type treturn, Expression target, MethodBase[] methods, Expression ctx, Expression[] args, Boolean isStaticCallSyntax, PhpTypeInfo lateStaticType)
   at Pchp.Core.Dynamic.CallBinder.Bind(DynamicMetaObject target, DynamicMetaObject[] args)
   at System.Dynamic.DynamicMetaObjectBinder.Bind(Object[] args, ReadOnlyCollection`1 parameters, LabelTarget returnLabel)
   at System.Runtime.CompilerServices.CallSiteBinder.BindCore[T](CallSite`1 site, Object[] args)
   at System.Dynamic.UpdateDelegates.UpdateAndExecute4[T0,T1,T2,T3,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3)
   at <Root>.main_php.<Main>(Context <ctx>, PhpArray <locals>, Object this, RuntimeTypeHandle <self>) in /Users/calvinbaart/Development/laravel-peachpie-sample/Laravel.Tests/main.php:line 12
   at <Script>.Main(String[] args)
The PHPUnit error seems to happen after this commit: peachpiecompiler/peachpie@e90646d or this one: peachpiecompiler/peachpie@6a8d3a8
Jakub Míšek
@jakubmisek
so this causes you the exception?
mb_substr("hello", 1, null) ;
Jakub Míšek
@jakubmisek
@calvinbaart the exception will be fixed, anyways, please check your dotnet-php.rsp file - there might be duplicit references (Peachpie.Library.dll)
Calvin Baart
@calvinbaart
no, only the normal substr causes an exception. mb_substr works. I'll check my rsp files just to be sure
Jakub Míšek
@jakubmisek
that makes sense, thanks
Jakub Míšek
@jakubmisek
substr had two overloads causing unnecessary dynamic invocation (and dynamic conversion of NULL to Nullable<int> was not implemented)
Calvin Baart
@calvinbaart
Seems to be working now :) Thanks! Eval fixes also work so alot more tests pass now (from 2300 fails to 1024 now, so about 1300 tests).
Tests: 3731, Assertions: 6527, Errors: 1024, Failures: 162, Warnings: 7, Skipped: 59.
Benjamin Fistein
@bfistein
That's a very reasonable error reduction rate with just 1 day's work fixing issues :)
Calvin Baart
@calvinbaart
Yes :) Great work by jakub! I'm still having a few issues with static constructors cross-assembly but still haven't been able to create a test case for it. I think if that issue is fixed and the currently pending issues another 200-300 tests will pass.
Jakub Míšek
@jakubmisek
looks better a better! What cross-assembly issue? @calvinbaart
Calvin Baart
@calvinbaart

@jakubmisek Actually two issues that I cant reproduce outside of the Laravel project:

  • When a class inherits from Illuminate.Database.Eloquent.Model and you call the static create function on that class it will crash because the default argument for the constructor is not used and instead NULL is passed. I get this exception then:
    23) Illuminate\Tests\Broadcasting\BroadcasterTest::testExtractingParametersWhileCheckingForUserAccess
    TypeError: Argument '1' should not be NULL
    /home/travis/build/calvinbaart/laravel-peachpie-sample/Laravel/src/Illuminate/Database/Eloquent/Model.php:162
    /home/travis/build/calvinbaart/laravel-peachpie-sample/Laravel/src/Illuminate/Broadcasting/Broadcasters/Broadcaster.php:206
    /home/travis/build/calvinbaart/laravel-peachpie-sample/Laravel/src/Illuminate/Broadcasting/Broadcasters/Broadcaster.php:166
    /home/travis/build/calvinbaart/laravel-peachpie-sample/Laravel/src/Illuminate/Broadcasting/Broadcasters/Broadcaster.php:98
    /home/travis/build/calvinbaart/laravel-peachpie-sample/Laravel/src/Illuminate/Support/Collection.php:1119
    /home/travis/build/calvinbaart/laravel-peachpie-sample/Laravel/src/Illuminate/Broadcasting/Broadcasters/Broadcaster.php:95
    /home/travis/build/calvinbaart/laravel-peachpie-sample/Laravel.Tests/tests/Broadcasting/BroadcasterTest.php:317
    /home/travis/build/calvinbaart/laravel-peachpie-sample/Laravel.Tests/tests/Broadcasting/BroadcasterTest.php:39
  • In some rare cases the traits of a class aren't initialised causing a NULL-pointer exception. Example being:
    8) Illuminate\Tests\Auth\AuthGuardTest::testLoginUsingIdLogsInWithUser
    PHPUnit\Framework\WrappedException: System.NullReferenceException: Object reference not set to an instance of an object.
     at Illuminate.Auth.SessionGuard.getProvider()
     at <>.getProvider(SessionGuard )
     at Mockery_12_Illuminate_Auth_SessionGuard._mockery_handleMethodCall(PhpValue method, PhpArray args)
     at Mockery_12_Illuminate_Auth_SessionGuard.getProvider(PhpValue[] <arguments>)
     at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
     at Illuminate.Tests.Auth.AuthGuardTest.testLoginUsingIdLogsInWithUser()
     at System.Dynamic.UpdateDelegates.UpdateAndExecute4[T0,T1,T2,T3,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3)
     at CallSite.Target(Closure , CallSite , TestCase , NameParam`1 , Context , UnpackingParam`1 )
     at PHPUnit.Framework.TestCase.runTest()

I'm still working on creating a small test case for these, but I haven't been successfull yet.

Jakub Míšek
@jakubmisek
seems more likely something in Illuminate.Auth.SessionGuard.getProvider ?
the first error needs a test smaller case, but can be fixed then
Calvin Baart
@calvinbaart
/**
 * Get the user provider used by the guard.
 *
 * @return \Illuminate\Contracts\Auth\UserProvider
 */
public function getProvider()
{
    return $this->provider;
}
Doesn't really do much to cause a null exception :/
Jakub Míšek
@jakubmisek
hm, can you check $this ?
Calvin Baart
@calvinbaart

I can check later, the getProvider method gets compiled to this:

public virtual PhpValue getProvider()
{
    //IL_0006: Unknown result type (might be due to invalid IL or missing references)
    return <>trait_GuardHelpers.getProvider();
}

So I guess trait_GuardHelpers is NULL causing it to crash.

Jakub Míšek
@jakubmisek
yep so it has to be debugged to see the value of <>trait_GuardHelpers
Calvin Baart
@calvinbaart
Yea, I'll check later (no debugger setup for C# yet....)
Calvin Baart
@calvinbaart
@jakubmisek I can't compile anymore after the fixes for #494 I'm getting this exception: https://pastebin.com/yzzYRbUS
Calvin Baart
@calvinbaart
Commenting out EmitThisOrNull in EmitConvertToIPhpCallable seems to fix the compile error (ofcourse it crashes at runtime afterwards)
Calvin Baart
@calvinbaart

Seems to be locally, Travis is still able to build. After the latest changes the failed tests dropped by from 1024 -> 631:

Tests: 3742, Assertions: 7499, Errors: 631, Failures: 163, Warnings: 10, Skipped: 89.

https://travis-ci.com/calvinbaart/laravel-peachpie-sample/builds/124250409

Jakub Míšek
@jakubmisek
@calvinbaart commenting EmitThisOrNull just caused msbuild to recompile. Seems likely outdated Peachpie.Runtime project
Calvin Baart
@calvinbaart
Yea, I'm currently removing everything to see if that solves it
Still getting the exception related to getProvider on Travis, thought that the fix for #494 would solve it. I'll look into that one further