Skip to content

Commit bb5eb48

Browse files
authored
Fix scoping of PSR-0 based packages with global classes (#279)
Fix scoping of PSR-0 based packages with global classes #279
1 parent e5efabc commit bb5eb48

File tree

15 files changed

+263
-27
lines changed

15 files changed

+263
-27
lines changed

Makefile

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ tm: bin/phpunit
6262

6363
.PHONY: e2e
6464
e2e: ## Run end-to-end tests
65-
e2e: e2e_004 e2e_005 e2e_011 e2e_013 e2e_014 e2e_015 e2e_016 e2e_017 e2e_018 e2e_019 e2e_020 e2e_021 e2e_022 e2e_023 e2e_024 e2e_025 e2e_026 e2e_027 e2e_028
65+
e2e: e2e_004 e2e_005 e2e_011 e2e_013 e2e_014 e2e_015 e2e_016 e2e_017 e2e_018 e2e_019 e2e_020 e2e_021 e2e_022 e2e_023 e2e_024 e2e_025 e2e_026 e2e_027 e2e_028 e2e_029
6666

6767
PHPSCOPER=bin/php-scoper.phar
6868

@@ -316,6 +316,24 @@ e2e_028: bin/php-scoper.phar fixtures/set028-symfony/vendor
316316

317317
diff fixtures/set028-symfony/expected-output build/set028-symfony/output
318318

319+
.PHONY: e2e_029
320+
e2e_029: ## Run end-to-end tests for the fixture set 029 — EasyRdf
321+
e2e_029: bin/php-scoper fixtures/set029-easy-rdf/vendor
322+
php $(PHPSCOPER) add-prefix \
323+
--working-dir=fixtures/set029-easy-rdf \
324+
--output-dir=../../build/set029-easy-rdf \
325+
--no-config \
326+
--force \
327+
--no-interaction \
328+
--stop-on-failure
329+
330+
php fixtures/set029-easy-rdf/main.php > fixtures/set029-easy-rdf/expected-output
331+
332+
composer --working-dir=build/set029-easy-rdf dump-autoload --no-dev
333+
php build/set029-easy-rdf/main.php > build/set029-easy-rdf/output
334+
335+
diff fixtures/set029-easy-rdf/expected-output build/set029-easy-rdf/output
336+
319337
.PHONY: tb
320338
BLACKFIRE=blackfire
321339
tb: ## Run Blackfire profiling
@@ -417,6 +435,10 @@ fixtures/set028-symfony/vendor: fixtures/set028-symfony/composer.lock
417435
composer --working-dir=fixtures/set028-symfony install --no-dev --no-scripts
418436
touch $@
419437

438+
fixtures/set029-easy-rdf/vendor: fixtures/set029-easy-rdf/composer.lock
439+
composer --working-dir=fixtures/set029-easy-rdf install --no-dev
440+
touch $@
441+
420442
composer.lock: composer.json
421443
@echo composer.lock is not up to date.
422444

@@ -468,6 +490,9 @@ fixtures/set027-laravel/composer.lock: fixtures/set027-laravel/composer.json
468490
fixtures/set028-symfony/composer.lock: fixtures/set028-symfony/composer.json
469491
@echo fixtures/set028-symfony/composer.lock is not up to date.
470492

493+
fixtures/set029-easy-rdf/composer.lock: fixtures/set029-easy-rdf/composer.json
494+
@echo fixtures/set029-easy-rdf/composer.lock is not up to date.
495+
471496
bin/php-scoper.phar: bin/php-scoper src vendor scoper.inc.php box.json.dist
472497
$(BOX) compile
473498
touch $@
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"require": {
3+
"easyrdf/easyrdf": "^0.9.1"
4+
}
5+
}

fixtures/set029-easy-rdf/composer.lock

Lines changed: 80 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
14

fixtures/set029-easy-rdf/foaf.rdf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<rdf:RDF
3+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
4+
xmlns:foaf="http://xmlns.com/foaf/0.1/"
5+
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
6+
>
7+
<foaf:PersonalProfileDocument rdf:about="">
8+
<rdfs:label>Joe Bloggs' FOAF File</rdfs:label>
9+
<foaf:maker rdf:resource="http://www.example.com/joe#me" />
10+
<foaf:primaryTopic rdf:resource="http://www.example.com/joe#me" />
11+
</foaf:PersonalProfileDocument>
12+
13+
<foaf:Person rdf:about="http://www.example.com/joe#me">
14+
<foaf:title>Mr</foaf:title>
15+
<foaf:name xml:lang="en">Joe Bloggs</foaf:name>
16+
<foaf:firstName>Joe</foaf:firstName>
17+
<foaf:family_name>Bloggs</foaf:family_name>
18+
<foaf:homepage rdf:resource="http://www.example.com/joe/" />
19+
<foaf:currentProject>
20+
<foaf:Project>
21+
<foaf:name>Joe's Current Project</foaf:name>
22+
<foaf:homepage rdf:resource="http://www.example.com/project" />
23+
</foaf:Project>
24+
</foaf:currentProject>
25+
</foaf:Person>
26+
</rdf:RDF>

fixtures/set029-easy-rdf/main.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
$autoload = __DIR__.'/vendor/scoper-autoload.php';
6+
7+
if (false === file_exists($autoload)) {
8+
$autoload = __DIR__.'/vendor/autoload.php';
9+
}
10+
11+
require_once $autoload;
12+
13+
$foaf = new EasyRdf_Graph();
14+
$count = $foaf->parseFile(__DIR__.'/foaf.rdf');
15+
16+
echo $count.PHP_EOL;

specs/class/abstract.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public function a()
7272
}
7373
public abstract function b();
7474
}
75+
\class_alias('Humbug\\A', 'A', \false);
7576

7677
PHP
7778
,

specs/class/anonymous.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,11 @@ public function test() {
130130
interface B
131131
{
132132
}
133+
\class_alias('Humbug\\B', 'B', \false);
133134
interface C
134135
{
135136
}
137+
\class_alias('Humbug\\C', 'C', \false);
136138
new class
137139
{
138140
public function test()
@@ -160,6 +162,7 @@ public function test()
160162
};
161163
}
162164
}
165+
\class_alias('Humbug\\A', 'A', \false);
163166

164167
PHP
165168
,

specs/class/final.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ final class A {}
5858
final class A
5959
{
6060
}
61+
\class_alias('Humbug\\A', 'A', \false);
6162

6263
PHP
6364
],

specs/class/interface.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,16 @@ public function a();
7777
class C
7878
{
7979
}
80+
\class_alias('Humbug\\C', 'C', \false);
8081
class D
8182
{
8283
}
84+
\class_alias('Humbug\\D', 'D', \false);
8385
interface A extends \Humbug\C, \Humbug\D, \Iterator
8486
{
8587
public function a();
8688
}
89+
\class_alias('Humbug\\A', 'A', \false);
8790

8891
PHP
8992
],

0 commit comments

Comments
 (0)