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

Warnings inside of Eval are thrown as fatal exceptions #502

Closed
calvinbaart opened this issue Aug 24, 2019 · 3 comments
Closed

Warnings inside of Eval are thrown as fatal exceptions #502

calvinbaart opened this issue Aug 24, 2019 · 3 comments

Comments

@calvinbaart
Copy link
Contributor

An example of this is using eval inside of eval, which produces this exception:

System.InvalidOperationException: Use of 'eval()' is discouraged. Construct allows execution of arbitrary code and is subject to performance and memory overhead.
   at Pchp.Core.DefaultErrorHandler.Throw(PhpError error, String message)
   at Peachpie.Library.Scripting.Script.<>c__DisplayClass15_0.<CreateInvalid>b__0(Context ctx, PhpArray locals, Object this, RuntimeTypeHandle self)
   at Peachpie.Library.Scripting.Script.Evaluate(Context ctx, PhpArray locals, Object this, RuntimeTypeHandle self)
   at Pchp.Core.Operators.Eval(Context ctx, PhpArray locals, Object this, RuntimeTypeHandle self, String code, String currentpath, Int32 line, Int32 column)
   at Mockery.Loader.EvalLoader.load(MockDefinition definition) in /home/travis/build/calvinbaart/laravel-peachpie-sample/Laravel.Tests/vendor/mockery/mockery/library/Mockery/Loader/EvalLoader.php:line 34
   at CallSite.Target(Closure , CallSite , PhpValue , Context , PhpValue& )
   at Mockery.Container.mock(PhpValue[] args) in /home/travis/build/calvinbaart/laravel-peachpie-sample/Laravel.Tests/vendor/mockery/mockery/library/Mockery/Container.php:line 230
   at <>.mock(Container , PhpValue[] )
   at Mockery.mock(Context <ctx>, PhpValue[] args)
   at Illuminate.Tests.Foundation.FoundationProviderRepositoryTest.testManifestIsProperlyRecompiled()
   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()
@jakubmisek
Copy link
Member

works for me, seems eval() only throws exception if the evaluated code cannot be compiled (contains error), warnings are ignored.

sample:

eval ( 'eval(\'$x = 666;\');' );
echo $x;

@jakubmisek
Copy link
Member

Maybe the evaluated code contains more warnings AND an error, and just the first problem was reported, but the real error was not?

@jakubmisek
Copy link
Member

closing, failed eval is caused by something else which is now reported properly

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

No branches or pull requests

2 participants