Skip to content

Commit

Permalink
added new test cases from kPHP
Browse files Browse the repository at this point in the history
  • Loading branch information
Hidanio committed Sep 28, 2023
1 parent 7d24078 commit b6d2005
Show file tree
Hide file tree
Showing 34 changed files with 1,462 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@ok
<?php
#ifndef KPHP
require_once 'kphp_tester_include.php';
#endif

$_ = \Messages011\MessagesLogger011::log();
\Messages011\MessagesLogger011::create();
12 changes: 12 additions & 0 deletions tests/php/011_late_static_bindings/Logs011/BaseLog011.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Logs011;

abstract class BaseLog011 {
protected static function logAction(): bool {
return true;
}

protected static function createLog(): void {
}
}
15 changes: 15 additions & 0 deletions tests/php/011_late_static_bindings/Messages011/.modulite.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: "@messages011"
description: ""
namespace: "Messages011\\"

export:
- "MessagesLogger011"

force-internal:

require:
- "\\Logs011\\BaseLog011"
- "\\Logs011\\BaseLog011::createLog()"
- "\\Logs011\\BaseLog011::logAction()"

allow-internal-access:
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Messages011;

use Logs011\BaseLog011;

class MessagesLogger011 extends BaseLog011 {

public static function create(): void {
parent::createLog();
}

public static function log(): bool {
return parent::logAction();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@ok
KPHP_COMPOSER_ROOT={dir}
<?php
require_once __DIR__ . '/vendor/autoload.php';

\Printer012\Printer012::print();
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace BasePrinter012;

use Vk\TestSrt\SomeStr;

class BasePrinter012 {
final public static function basePrint(): void {
$r1 = new SomeStr();
echo "BasePrint\n";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: "@printer012"
description: ""
namespace: "Printer012\\"

# "Public API" of the modulite: classes, functions, constants, etc.
# Symbols not listed here will be internal.
export:
- "Printer012"

# Class members to exclude, they override "export".
force-internal:

# Dependencies: other modulites, global classes, defines, etc.
require:
- "\\BasePrinter012\\BasePrinter012"

# Granting partial access to internal symbols, "as an exception".
allow-internal-access:
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Printer012;

use BasePrinter012\BasePrinter012;

class Printer012 extends BasePrinter012 {

public static function print(): void {
self::basePrint();
echo "print\n";
}
}
18 changes: 18 additions & 0 deletions tests/php/012_package_not_required_in_derived_class/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "phpt/012",
"autoload": {
"psr-4": {
"BasePrinter012\\": "./BasePrinter012",
"Printer012\\": "./Printer012"
}
},
"require": {
"vk/strings": "*"
},
"repositories": [
{
"type": "path",
"url": "./packages/vk-strings"
}
]
}
37 changes: 37 additions & 0 deletions tests/php/012_package_not_required_in_derived_class/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "vk/strings",
"version": "0.0.1",
"type": "library",
"autoload": {
"psr-4": {
"Vk\\TestSrt\\": "src/"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Vk\TestSrt;

class SomeStr {
public static function concatStr(string $s1, string $s2): string {
return $s1 . $s2;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

// autoload.php @generated by Composer

if (PHP_VERSION_ID < 50600) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, $err);
} elseif (!headers_sent()) {
echo $err;
}
}
trigger_error(
$err,
E_USER_ERROR
);
}

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit451b6d5135cd4eb8e84df3fc66c39587::getLoader();
Loading

0 comments on commit b6d2005

Please sign in to comment.