peachpie
peachpie copied to clipboard
System.ArgumentNullException: Value cannot be null. (Parameter 'tinfo')
Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'tinfo')
at Pchp.Core.Context.Create(RuntimeTypeHandle caller, PhpTypeInfo tinfo, PhpValue[] arguments)
at <Root>.program_php.<Main>(Context <ctx>, PhpArray <locals>, Object this, RuntimeTypeHandle <self>) in /home/chenfa/proj/mytestall_dir/helloword/program.php:line 5
at <Script>.Main(String[] args)
This is program.php code:
<?php
$testClass = '\\vvtll\\People';
$p = new $testClass();
$p->sing();
This is People.php code in vvtll
namepace:
<?php
namespace vvtll;
class People
{
public function __construct()
{
echo 'people class test';
}
public function sing()
{
echo 'hello world';
}
}
my helloworld msbuildproj code:
<Project Sdk="Peachpie.NET.Sdk/1.0.0-dev">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<StartupObject>program.php</StartupObject>
<Description>Simpliest PHP project for .NET Core, a console application.</Description>
</PropertyGroup>
<ItemGroup>
<Compile Include="**/*.php" />
</ItemGroup>
<PropertyGroup>
<IlcOptimizationPreference>Speed</IlcOptimizationPreference>
<IlcFoldIdenticalMethodBodies>true</IlcFoldIdenticalMethodBodies>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.DotNet.ILCompiler" Version="7.0.0-alpha.1.21423.2" />
</ItemGroup>
</Project>
you're missing to include the file with People:
include 'People.php';
$testClass = '\\vvtll\\People';
$p = new $testClass();
Although; PeachPie should report a better error message.
Additionally, you can use composer.json
with "autoload" so the include won't be necessary
it is autoloaded by compose.json
it can not work with the magic compiler "Microsoft.DotNet.ILCompiler"