|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-06-25 20:17 UTC] maf dot michal at gmail dot com
Description: ------------ As I was running tests of one of my PHP libs using travis-ci I encountered some issue with late static binding. It seems to be not possible to override static property and access proper values with static:: keyword https://travis-ci.org/majkel89/tcpdf-warper/jobs/68057687 On the other hand the problem might be with reflection API that cannot override static properties any more. Non the less I provided full source code as long with tests scripts and results sets. PS: Would it be wiser to replace static property storing default arguments with inline array in getArguments both for performance and memory improvements ? This way the problem would be fixed. Test script: --------------- https://github.com/majkel89/tcpdf-warper/blob/master/tests/org/majkel/tcpdfwarper/AbstractOpTest.php#L141 Expected result: ---------------- https://travis-ci.org/majkel89/tcpdf-warper/jobs/68057674 Actual result: -------------- https://travis-ci.org/majkel89/tcpdf-warper/jobs/68057687 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 18:00:02 2025 UTC |
<?php class Base { protected static $prop = 'BASE'; public function getProp() { return static::$prop; } } class Mock extends Base { } $obj = new Mock; $excepted = 'REFLECTED'; $property = new ReflectionProperty('Base', 'prop'); $property->setAccessible(true); $property->setValue($excepted); $actual = $obj->getProp(); echo "Schould be `{$excepted}` and is `{$actual}`\n"; // exit($actual !== $excepted ? 1 : 0); ?>