function list_diff($a, $b) { // print("a: ".listfmt($a)."<br />\n"); // print("b: ".listfmt($b)."<br />\n"); $o = array(); if (count($a) == 0) { foreach ($b as $new) { array_push($o, added($new)); } return $o; } $l = reset($a); $r = reset($b); // print("Comparing $l and $r<br />\n"); if ($l == $r) { array_push($o, same($l)); array_shift($a); array_shift($b); } else { // print("$l and $r are different; resynching\n"); list($added, $remain) = find_best_match($a, $b); if (count($added) > 0) { foreach ($added as $new) { array_push($o, added($new)); } $b = $remain; // print("Found ${added[0]}; ". count($remain). " Remain\n"); } else { array_push($o, deleted($l)); array_shift($a); // array_shift($b); } } $n = list_diff($a, $b); foreach ($n as $new) { $o[] = $new; } return $o; }
$path2 = dirname($path1); $path3 = str_replace($s, "%", $path2); print "dirname({$path}) == {$path3}\n"; } check_dirname("%foo%"); check_dirname("%foo"); check_dirname("%foo%bar"); check_dirname("%"); check_dirname("...%foo"); check_dirname(".%foo"); check_dirname("foobar%%%"); check_dirname("%%%.%."); function same($a, $b) { if ($a == $b) { print "OK\n"; } else { print "FAIL {$a} == {$b}\n"; } } if ('/' == $s) { same(".", dirname("d:\\foo\\bar.inc")); same(".", dirname("c:\\foo")); same(".", dirname("c:\\")); same(".", dirname("c:")); } else { same("d:\\foo", dirname("d:\\foo\\bar.inc")); same("c:\\", dirname("c:\\foo")); same("c:\\", dirname("c:\\")); same("c:", dirname("c:")); }
global_neuron('neuronet', 2)->sensor_set($second); global_neuron('neuronet', 6)->dendrites_read(); global_neuron('neuronet', 6)->decide(); $decision = global_neuron('neuronet', 6)->axon_get(); echo "{$first} == {$second} ?\nnetwork says: {$decision} (0=NO, 1=YES)\n"; return $decision; } /* We got nice function (in fact it hardly sux, like whole this network...) How to use it?: */ ///Learning: same(0, 0); //Ask neural_network('neuronet')->learn('true'); //Correct answer (teach) neural_network('neuronet')->learn('true'); //Correct answer (teach) same(1, 0); neural_network('neuronet')->learn('false'); neural_network('neuronet')->learn('false'); same(0, 1); neural_network('neuronet')->learn('false'); neural_network('neuronet')->learn('false'); ///Using superinteligent lifeform ehm... 3 neurones brain ;P echo "\nI hope it will work now: 8')\n\n"; same(0, 0); //Ask (without teaching) //Now, we like to print some stats neural_network('neuronet')->debug(); //Print some info about neuronet and it's neurons
echo "Upload not complete"; }*/ ?> <?php for ($i = 0; $i < count($_FILES['file']['name']); $i++) { $file = strtolower($_FILES['file']['name'][$i]); $sizefile = $_FILES['file']['name'][$i]; $type[$i] = strrchr($_FILES['file']['name'][$i], "."); $error[$i] = $_FILES['file']['error'][$i]; } for ($k = 0; $k < count($_FILES['file']['name']); $k++) { for ($j = $k + 1; $j < 5; $j++) { if ($_FILES['file']['name'][$k] == $_FILES['file']['name'][$j]) { $error[0] = 1; same(); } } } if ($error[0] == 0) { if (($type[0] == ".log" || $type[0] == "") && ($type[1] == ".log" || $type[1] == "") && ($type[2] == ".log" || $type[2] == "") && ($type[3] == ".log" || $type[3] == "") && ($type[4] == ".log" || $type[4] == "")) { echo "Upload complete"; ?> <center> <form action="test4.php" method="post" enctype="multipart/form-data"> <input type="submit" name="submit" value="Result" /> </form> </center> <?php for ($i = 0; $i < count($_FILES['file']['name']); $i++) { $today = date("m.d.y-H.i");
$childPath = __DIR__ . '/Fixtures/Child.php'; $project = $projectFactory->create('inheritance', [$childPath, __DIR__ . '/Fixtures/Foo.php', __DIR__ . '/Fixtures/BarInterface.php']); foreach ($project->getFiles() as $path => $file) { if ($childPath === $path) { same(<<<'PHP' <?php namespace bar; class Child extends Foo implements BarInterface { use BazTrait; public function test(float $a) { parent::test($a); } /** * {@inheritdoc} */ public function baz(array $a, int $b) : float{ } } PHP , $converter->convert($project, $file)); } } echo 'Good job! Everything is fine.' . PHP_EOL;
* @return float[] */ function array_no_types(array $ints, array $strings, array $someClasses) : array{ } PHP; same($expected, $converter->convert($project, $file)); } $projectFactory = ProjectFactory::createInstance(); $project = $projectFactory->create('typeAliasesWhitelisting', [__DIR__ . '/Fixtures/type_aliases_and_whitelisting.php']); foreach ($project->getFiles() as $path => $file) { $expected = <<<'PHP' <?php /** * @param integer $integer * @param boolean $boolean * @param real $real * @param double $double * @param callback $callback * @param void $void * @param mixed $mixed * @param unknown $unknown * @param Class $class */ function aliases(int $integer, bool $boolean, $real, float $double, callable $callback, $void, $mixed, $unkown, \Class $class) { } PHP; same($expected, $converter->convert($project, $file)); } echo 'Good job! Everything is fine.' . PHP_EOL;
<?php function same($left, $right) { echo $left === $right ? "true\n" : "false\n"; } function eq($left, $right) { echo $left == $right ? "true\n" : "false\n"; } function neq($left, $right) { echo $left != $right ? "true\n" : "false\n"; } same(false, 0); neq(0, "b"); eq(true, -1);