Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change detection of PHAR in examples #565

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build/runtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
exit(1);
}

$_ENV['FLOW_PHAR_APP'] = 1;

\ini_set('memory_limit', -1);

(new SingleCommandApplication())
Expand Down
2 changes: 1 addition & 1 deletion examples/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types=1);

if ('' === \Phar::running(false)) {
if (!($_ENV['FLOW_PHAR_APP'] ?? false)) {
require __DIR__ . '/../vendor/autoload.php';
}

Expand Down
2 changes: 1 addition & 1 deletion examples/topics/aggregations/power_plant.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
->withEntry('consumption', concat(ref('consumption'), lit('%')))
->write(To::output(truncate: false));

if ('' !== \Phar::running(false)) {
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
return $flow;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/topics/aggregations/power_plant_bar_chart.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
)
);

if ('' !== \Phar::running(false)) {
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
return $flow;
}

Expand Down
4 changes: 2 additions & 2 deletions examples/topics/async/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php declare(strict_types=1);

if ('' !== \Phar::running(false)) {
print 'This example cannot be run in PHAR, please use CLI approach.';
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
print "This example cannot be run in PHAR, please use CLI approach.\n";

exit(1);
}
Expand Down
4 changes: 2 additions & 2 deletions examples/topics/db/db_clean.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php

if ('' !== \Phar::running(false)) {
print 'This example cannot be run in PHAR, please use CLI approach.';
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
print "This example cannot be run in PHAR, please use CLI approach.\n";

exit(1);
}
Expand Down
4 changes: 2 additions & 2 deletions examples/topics/db/db_source.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php

if ('' !== \Phar::running(false)) {
print 'This example cannot be run in PHAR, please use CLI approach.';
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
print "This example cannot be run in PHAR, please use CLI approach.\n";

exit(1);
}
Expand Down
4 changes: 2 additions & 2 deletions examples/topics/db/db_to_db_sync.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php declare(strict_types=1);

if ('' !== \Phar::running(false)) {
print 'This example cannot be run in PHAR, please use CLI approach.';
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
print "This example cannot be run in PHAR, please use CLI approach.\n";

exit(1);
}
Expand Down
4 changes: 2 additions & 2 deletions examples/topics/fs/remote/json_remote_stream.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php declare(strict_types=1);

if ('' !== \Phar::running(false)) {
print 'This example cannot be run in PHAR, please use CLI approach.';
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
print "This example cannot be run in PHAR, please use CLI approach.\n";

exit(1);
}
Expand Down
4 changes: 2 additions & 2 deletions examples/topics/fs/remote/json_remote_stream_glob.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php declare(strict_types=1);

if ('' !== \Phar::running(false)) {
print 'This example cannot be run in PHAR, please use CLI approach.';
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
print "This example cannot be run in PHAR, please use CLI approach.\n";

exit(1);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/topics/http/psr_http_dynamic.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function create(?Message\ResponseInterface $previousResponse = null) : ?M
->select('name', 'html_url', 'blog')
->write(To::output(false));

if ('' !== \Phar::running(false)) {
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
return $flow;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/topics/join/left_anti/left_anti_join.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
)
->write(To::output());

if ('' !== \Phar::running(false)) {
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
return $flow;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/topics/join/left_anti/left_anti_join_each.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private function findRowsInDatabase(Rows $rows) : Rows
)
->write(To::output());

if ('' !== \Phar::running(false)) {
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
return $flow;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/topics/transformations/aggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
->aggregate(Aggregation::sum(ref('a')))
->write(To::output(false));

if ('' !== \Phar::running(false)) {
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
return $flow;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/topics/transformations/array_expand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
->withEntry('expanded', array_expand(ref('array')))
->write(To::output(false));

if ('' !== \Phar::running(false)) {
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
return $flow;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/topics/transformations/array_unpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
->withEntry('unpacked', ref('array')->unpack())
->write(To::output(false));

if ('' !== \Phar::running(false)) {
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
return $flow;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/topics/transformations/filter_divide.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
->withEntry('new_b', ref('b')->multiply(lit(2))->multiply(lit(5)))
->write(To::output(false));

if ('' !== \Phar::running(false)) {
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
return $flow;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/topics/transformations/filter_mod.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
->filter(ref('b')->mod(lit(2))->equals(lit(0)))
->write(To::output(false));

if ('' !== \Phar::running(false)) {
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
return $flow;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/topics/transformations/group_by.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
->groupBy(ref('a'))
->write(To::output(false));

if ('' !== \Phar::running(false)) {
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
return $flow;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/topics/transformations/literals.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
->withEntry('number', lit(1))
->write(To::output(false));

if ('' !== \Phar::running(false)) {
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
return $flow;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/topics/transformations/math.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
->withEntry('d', ref('b')->minus(ref('a')))
->write(To::output(false));

if ('' !== \Phar::running(false)) {
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
return $flow;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/topics/transformations/size.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
->withEntry('array_size', ref('array')->size())
->write(To::output(false));

if ('' !== \Phar::running(false)) {
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
return $flow;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/topics/transformations/sort.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
->sortBy(ref('id')->desc())
->write(To::output(false));

if ('' !== \Phar::running(false)) {
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
return $flow;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/topics/transformations/when_null.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
)
->write(To::output(false));

if ('' !== \Phar::running(false)) {
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
return $flow;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/topics/transformations/when_odd.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
)
->write(To::output(false));

if ('' !== \Phar::running(false)) {
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
return $flow;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/topics/types/csv/csv_read.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
->drop(col('row'))
->limit(10_000);

if ('' !== \Phar::running(false)) {
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
return $flow;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/topics/types/csv/csv_read_partitioned.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
->sortBy(ref('id'))
->write(To::output());

if ('' !== \Phar::running(false)) {
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
return $flow;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/topics/types/csv/csv_read_partitioned_filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
->sortBy(ref('id'))
->write(To::output());

if ('' !== \Phar::running(false)) {
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
return $flow;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/topics/types/csv/csv_to_avro.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
->rename('last name', 'last_name')
->write(Avro::to(__FLOW_OUTPUT__ . '/dataset.avro'));

if ('' !== \Phar::running(false)) {
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
return $flow;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/topics/types/csv/csv_to_json.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
->drop(col('row'))
->write(Json::to(__FLOW_OUTPUT__ . '/dataset.json'));

if ('' !== \Phar::running(false)) {
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
return $flow;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/topics/types/csv/csv_to_parquet_100k.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
->drop(col('row'))
->write(Parquet::to(__FLOW_OUTPUT__ . '/dataset_100k.parquet', 100_000));

if ('' !== \Phar::running(false)) {
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
return $flow;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/topics/types/csv/csv_to_parquet_10k.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
->drop(col('row'))
->write(Parquet::to(__FLOW_OUTPUT__ . '/dataset_10k.parquet', 10_000));

if ('' !== \Phar::running(false)) {
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
return $flow;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/topics/types/csv/php_to_csv.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
->drop(col('row'))
->write(CSV::to(__FLOW_OUTPUT__ . '/dataset.csv'));

if ('' !== \Phar::running(false)) {
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
return $flow;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/topics/types/csv/php_to_csv_and_json.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
->write(CSV::to(__FLOW_OUTPUT__ . '/dataset.csv'))
->write(Json::to(__FLOW_OUTPUT__ . '/dataset.json'));

if ('' !== \Phar::running(false)) {
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
return $flow;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/topics/types/csv/php_to_csv_partition.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
->partitionBy('country_code', 't_shirt_color')
->write(CSV::to(__FLOW_OUTPUT__ . '/partitioned'));

if ('' !== \Phar::running(false)) {
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
return $flow;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/topics/types/xml/reading.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
->read(XML::from(__FLOW_DATA__ . '/simple_items.xml', 'root/items/item'))
->write(To::output(false));

if ('' !== \Phar::running(false)) {
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
return $flow;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/topics/types/xml/salaries.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
->rename('department_salary_sum', 'total_monthly_salaries')
->write(To::output(false));

if ('' !== \Phar::running(false)) {
if ($_ENV['FLOW_PHAR_APP'] ?? false) {
return $flow;
}

Expand Down
Loading