-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[modulite] fixed inheritance late static bindings (#908)
* added new tests for late static bindings in modulite * fixed logic when modulite not correctly handles late static binding with cross-module inheritance --------- Co-authored-by: Aleksandr Kirsanov <[email protected]>
- Loading branch information
Showing
36 changed files
with
1,425 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
tests/phpt/modulite/011_late_static_bindings/011_late_static_bindings.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
12
tests/phpt/modulite/011_late_static_bindings/Logs011/BaseLog011.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
15
tests/phpt/modulite/011_late_static_bindings/Messages011/.modulite.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
16 changes: 16 additions & 0 deletions
16
tests/phpt/modulite/011_late_static_bindings/Messages011/MessagesLogger011.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...e/012_package_not_required_in_derived_class/012_package_not_required_in_derived_class.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@ok | ||
KPHP_COMPOSER_ROOT={dir} | ||
<?php | ||
#ifndef KPHP | ||
require_once 'kphp_tester_include.php'; | ||
#endif | ||
require_once __DIR__ . '/vendor/autoload.php'; | ||
|
||
\Printer012\Printer012::print(); |
12 changes: 12 additions & 0 deletions
12
...phpt/modulite/012_package_not_required_in_derived_class/BasePrinter012/BasePrinter012.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
tests/phpt/modulite/012_package_not_required_in_derived_class/Printer012/.modulite.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
13 changes: 13 additions & 0 deletions
13
tests/phpt/modulite/012_package_not_required_in_derived_class/Printer012/Printer012.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
18
tests/phpt/modulite/012_package_not_required_in_derived_class/composer.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
] | ||
} |
10 changes: 10 additions & 0 deletions
10
...phpt/modulite/012_package_not_required_in_derived_class/packages/vk-strings/composer.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/" | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...pt/modulite/012_package_not_required_in_derived_class/packages/vk-strings/src/SomeStr.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
tests/phpt/modulite/012_package_not_required_in_derived_class/vendor/autoload.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
Oops, something went wrong.